* Bump i18n-js from 3.9.2 to 4.0.2 Bumps [i18n-js](https://github.com/fnando/i18n) from 3.9.2 to 4.0.2. - [Release notes](https://github.com/fnando/i18n/releases) - [Changelog](https://github.com/fnando/i18n/blob/main/CHANGELOG.md) - [Commits](https://github.com/fnando/i18n/commits/v4.0.2) --- updated-dependencies: - dependency-name: i18n-js dependency-type: direct:production update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * update import of i18n * fix incorrect setting of locale Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Suzanne Aitchison <suzanne@forem.com>
17 lines
440 B
JavaScript
17 lines
440 B
JavaScript
import { I18n } from 'i18n-js';
|
|
|
|
const i18n = new I18n();
|
|
|
|
const translationsDiv = document.getElementById('i18n-translations');
|
|
if (translationsDiv) {
|
|
const translations = JSON.parse(translationsDiv.dataset.translations);
|
|
i18n.store(translations);
|
|
}
|
|
i18n.defaultLocale = 'en';
|
|
const { locale: userLocale } = document.body.dataset;
|
|
if (userLocale) {
|
|
i18n.locale = userLocale;
|
|
}
|
|
export function locale(term) {
|
|
return i18n.t(term);
|
|
}
|