How to use the node-polyglot.transformPhrase function in node-polyglot

To help you get started, we’ve selected a few node-polyglot 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 flow-typed / flow-typed / definitions / npm / node-polyglot_v2.x.x / test_node-polyglot_v2.x.x.js View on Github external
phrases: {},
  locale: "foo",
  allowMissing: true,
  onMissingKey: (key, opts, locale) => {
    console.log(key.length, Object.keys(opts), locale.length);

    return "foo";
  }
});
new Polyglot();

// $ExpectError
new Polyglot("foo");

Polyglot.transformPhrase("foo").length;
Polyglot.transformPhrase("foo", {}).length;
Polyglot.transformPhrase("foo", {}, "en-US").length;

instance.extend({ foo: "bar" });

// $ExpectError
instance.extend("foo");

instance.has("foo");

// $ExpectError
instance.has(1);

instance.t("foo").length;
instance.t("foo", {}).length;

// $ExpectError
github flow-typed / flow-typed / definitions / npm / node-polyglot_v2.x.x / test_node-polyglot_v2.x.x.js View on Github external
locale: "foo",
  allowMissing: true,
  onMissingKey: (key, opts, locale) => {
    console.log(key.length, Object.keys(opts), locale.length);

    return "foo";
  }
});
new Polyglot();

// $ExpectError
new Polyglot("foo");

Polyglot.transformPhrase("foo").length;
Polyglot.transformPhrase("foo", {}).length;
Polyglot.transformPhrase("foo", {}, "en-US").length;

instance.extend({ foo: "bar" });

// $ExpectError
instance.extend("foo");

instance.has("foo");

// $ExpectError
instance.has(1);

instance.t("foo").length;
instance.t("foo", {}).length;

// $ExpectError
instance.t(2);
github Aalto-LeTech / a-plus / assets / js / translate.js View on Github external
function onMissingKey(key, opts, locale) {
  if (locale !== defaultLang) {
    console.warn('Missing translation for key: "' + key + '"');
  }
  return Polyglot.transformPhrase(key, opts, locale);
}
github Aalto-LeTech / a-plus / assets_src / translate-js / main.js View on Github external
function onMissingKey(key, opts, locale) {
  if (locale !== defaultLang) {
    console.warn('Missing translation for key: "' + key + '"')
  }
  return Polyglot.transformPhrase(key, opts, locale)
}
github Nexusoft / NexusInterface / src / shared / lib / intl.js View on Github external
const engTranslate = (string, data) =>
  Polyglot.transformPhrase(string, data, 'en');

node-polyglot

Give your JavaScript the ability to speak many languages.

BSD-2-Clause
Latest version published 5 months ago

Package Health Score

84 / 100
Full package analysis