@superset-ui/translation
i18n
locales and translation for Superset
SupersetTranslation
Example usage
import { configure, t, tn } from '@superset-ui/translation';
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);
Development
@data-ui/build-config
is used to manage the build configuration for this package including babel
builds, jest testing, eslint, and prettier.
v0.9.0
✨ Features
- Add
useLegacyApi
field to ChartMetadata
. This flag will help us determine whether to use the new /api/v1/query
endpoint or the legacy one. - Add two generics to
Registry<V, W>
V
is type of value in the registryW
is type of value returned from loader
function when using .registerLoader(key, loader)
.W
can be either V
, Promise<V>
or V | Promise<V>
- Set
W=V
when does not support asynchronous loader. Making return type of .get()
become V
instead of Promise<V>
- By default,
W
is set to V | Promise<V>
to support both synchronous and asynchronous loaders.
- Include and link TypeScript declaration for package
jed
with @superset-ui/translation
distribution.
🛠️ Internal
- Convert
@superset-ui/number-format
to TypeScript - Convert
@superset-ui/time-format
to TypeScript - Convert
@superset-ui/translation
to TypeScript
💔 BREAKING CHANGES
- Make number formatter always returns
string
. This is different from previous behavior.
|Value|formatted value (before)|formatted value (after)|
|------------|------------|-----------|
| null
| null
| 'null'
|
| undefined
| undefined
| 'undefined'
|
| NaN
| NaN
| 'NaN'
|
- Make time formatter always returns
string
. This is different from previous behavior.
|Value|formatted value (before)|formatted value (after)|
|------------|------------|-----------|
| null
| null
| 'null'
|
| undefined
| undefined
| 'undefined'
|
| NaN
| NaN
| 'NaN'
|