wip: fallback behavior for missing/malformed messages instead of panicking

This commit is contained in:
Benjamin Singleton 2026-03-01 16:30:11 -06:00
parent e48b6c8708
commit 44ab34133c
6 changed files with 548 additions and 405 deletions

View file

@ -1,9 +1,5 @@
import type { Result } from "@/utils/types";
import {
FluentBundle,
FluentResource,
type FluentVariable,
} from "@fluent/bundle";
import { FluentBundle, FluentResource } from "@fluent/bundle";
import { unsafeAsync } from "@/utils/unsafe";
import type { Literal, Message, Pattern } from "@fluent/bundle/esm/ast";
@ -26,11 +22,8 @@ export async function loadFluentBundle(
}
const ftlFileText = ftlFileTextRes.ok;
console.log(ftlFileText);
const resource = new FluentResource(ftlFileText);
console.log(resource.body);
const bundle = new FluentBundle(localeId);
const errors = bundle.addResource(resource);
if (errors.length > 0) {
@ -129,7 +122,6 @@ export function computeAllVariants(
}
let variants: PatternVariant[] = [{ selectionChain: [], string: "" }];
console.log(pattern);
for (const element of pattern) {
if (typeof element === "string") {
variants = variants.map((variant) => ({