Fluent for Deno [better_fluent]
Deno port of the-moebius/fluent
Better Fluent integration for TypeScript/JavaScript. See the original repository for more information.
import { Fluent } from "https://deno.land/x/better_fluent/mod.ts";
// Instantiate a Fluent class
const fluent = new Fluent();
// Add translations
await fluent.addTranslation({
locales: "en",
source: `
-brand-name = Super Project
welcome =
Welcome, {$name}, to the {-brand-name}!
Your balance is: {
NUMBER($value, maximumFractionDigits: 2)
}
You have { NUMBER($applesCount) ->
[0] no apples
[one] {$applesCount} apple
*[other] {$applesCount} apples
}`,
});
const output = fluent.translate("en", "welcome", {
name: "Slava",
value: 100.12345,
applesCount: 5,
});
console.log(output);
See more examples here.
- @slavafomin - original repository (Node.js)
- @roj1512 - deno port of @fluent/bundle and @fluent/langneg