How to use the @fluent/bundle.FluentNumber function in @fluent/bundle

To help you get started, we’ve selected a few @fluent/bundle examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / fluent__bundle / fluent__bundle-tests.ts View on Github external
// FluentResource examples:
const resource = new FluentResource(`test=Some other message with args arg1={$arg1} and arg2={$arg2}`);
bundle.addResource(resource, { allowOverrides: true });
const msg = bundle.getMessage('test');
if (msg && msg.value) {
    const args = {
        $arg1: "#1",
        $arg2: "#2"
    };
    const errors: Error[] = [];
    const formatted: string = bundle.formatPattern(msg.value, args, errors);
    console.log(formatted);
}

// Fluent type examples:
const num = new FluentNumber(6);
const err = new FluentError('argh');
const dt = new FluentDateTime(new Date(2000, 0, 1));

// Scope examples:
class DummyScope implements Scope {
    cloneForTermReference(args: object): Scope {
        return this;
    }
    reportError(error: string): void {
    }
    memoizeIntlObject(
        ctor: new (locales: string[], opts: OptsType) => ObjectType,
        opts: OptsType,
    ): ObjectType {
        return new ctor([], opts);
    }
github spacemeowx2 / LiveHelper / src / langs / index.tsx View on Github external
STRLEN ([str]: FluentValue[]) {
    return new FluentNumber(str.value.toString().length)
  },
  MINUS ([a, b]: FluentValue[]) {
github spacemeowx2 / LiveHelper / src / langs / index.tsx View on Github external
DIV ([a, b]: FluentValue[]) {
    return new FluentNumber(a.value / b.value)
  },
  STRLEN ([str]: FluentValue[]) {