Locale
Installation
npm i @snack-uikit/locale
Usage
You need to wrap your app into <LocaleProvider>
to make translations work.
If you don't do it then default (en_GB) translations will be applied if applicable.
Also you can pass custom translations or replace/modify existing.
Note
When changing translations of existing languages, you can specify only the fields you want to change, as they will be merged with the default fields.
But when passing a custom language, you will have to specify all translations.
Example
import { LocaleProvider, OverrideLocales } from '@snack-uikit/locale';
const customTraslations: OverrideLocales = {
en_GB: {
Table: {
searchPlaceholder: 'custom',
},
},
custom_LANG: {
Table: {
searchPlaceholder: 'custom',
},
},
};
const lang = 'en_GB';
<LocaleProvider lang={lang} locales={customTranslations}>
{content}
</LocaleProvider>
Changelog
LocaleProvider
Props
name | type | default value | description |
---|
lang* | string | - | |
locales | OverrideLocales | - | |
useLocale
helper
Inner hook to use translations