Skip to content
This repository has been archived by the owner on Jun 15, 2024. It is now read-only.
/ deno_fluent Public archive

Fluent for Deno. Port of @the-moebius/fluent.

License

Notifications You must be signed in to change notification settings

dcdunkan/deno_fluent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fluent for Deno [better_fluent]

Deno port of the-moebius/fluent

Better Fluent integration for TypeScript/JavaScript. See the original repository for more information.

Usage

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.

Credits