npm.io
0.1.0 • Published 2 months ago

@primeuix/locale

Licence
SEE LICENSE IN LICENSE.md
Version
0.1.0
Deps
1
Size
9 kB
Vulns
0
Weekly
0

PrimeUIX Locale

Shared locale and i18n layer for PrimeUI libraries. Manages language registration, switching, and translation lookup through a singleton instance so locale state is consistent across PrimeVue, PrimeReact, and PrimeNG within the same application.

Locales are deep-merged against a fallback language, so partial translations are safe — only the keys that differ need to be provided.

import Locale from '@primeuix/locale';

Locale.init({
    lang: 'de',
    fallback: 'en',
    locales: { en: { accept: 'Accept' }, de: { accept: 'Akzeptieren' } }
});

Locale.use('de');
Locale.get(); // { accept: 'Akzeptieren' }

Language changes emit a locale:change event via LocaleService, which Prime framework libraries listen to in order to trigger re-renders.

License

Licensed under the PrimeUI License - Copyright (c) PrimeTek Informatics

Keywords