0.15.1 • Published 1 month ago

@snack-uikit/locale v0.15.1

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
1 month ago

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'; // or 'ru_RU' or 'custom_LANG'

  // ...
  <LocaleProvider lang={lang} locales={customTranslations}>
    {content}
  </LocaleProvider>

Changelog

LocaleProvider

Props

nametypedefault valuedescription
lang*string-
localesPartialObjectDeep<Record<string, { Table: { searchPlaceholder: string; noData: { title: string; }; noResults: { title: string; description: string; }; errorData: { title: string; description: string; }; rowsOptionsLabel: string; export: string; }; List: { ...; }; Chips: { ...; }; Fields: { ...; }; SearchPrivate: { ....-

useLocale

helper

Inner hook to use translations

0.11.0

7 months ago

0.13.0

4 months ago

0.15.0

2 months ago

0.15.1

2 months ago

0.12.0

5 months ago

0.12.1

4 months ago

0.14.0

4 months ago

0.12.2

4 months ago

0.9.0

9 months ago

0.10.0

9 months ago

0.8.0

10 months ago

0.7.1

12 months ago

0.7.0

1 year ago

0.6.0

1 year ago

0.5.0

1 year ago

0.4.0

1 year ago

0.3.0

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago