tree: 34f1a953572efd4294dfc7014e86940d3f3ef817 [path history] [tgz]
  1. types/
  2. index.ts
  3. README.md
  4. Translator.ts
  5. TranslatorSingleton.ts
superset-frontend/packages/superset-ui-core/src/translation/README.md

@superset-ui/core/translation

i18n locales and translation for Superset.

SupersetTranslation

Example usage

import { configure, t, tn } from '@superset-ui/core';

configure({
  languagePack: {...},
});

console.log(t('text to be translated'));
console.log(tn('singular text', 'plural text', value));

API

configure({ [languagePack] })

  • Initialize the translator
  • Initialize with the default language if no languagePack is specified.

t(text[, args])

  • Translate text.
  • If args is provided, substitute args into the sprintf placeholders specified within text translation.

For example

t('Hello %(name)s', user);

See sprintf-js for more details on how to define placeholders.

tn(singular, plural, num, [, args])

  • Translate and choose between singular and plural based on num.
  • If args is provided, substitute args into the sprintf placeholders specified within singular or plural translations.

For example

tn('%d duck', '%d ducks', 2, 2);