| import {configureLocalization, updateWhenLocaleChanges} from '@lit/localize'; |
| import {LitElement} from 'lit'; |
| import MWI18nClient from '../common/mainWorldI18n/Client.js'; |
| import {allLocales, sourceLocale, targetLocales} from '../lit-locales/generated/locales.js'; |
| export class I18nLitElement extends LitElement { |
| updateWhenLocaleChanges(this); |
| this.#MWI18nClient = new MWI18nClient(); |
| if (typeof chrome !== 'undefined' && chrome.i18n) { |
| pLocale = Promise.resolve(chrome.i18n.getUILanguage()); |
| pLocale = this.#MWI18nClient.getUILanguage(); |
| pLocale.then(browserLocale => { |
| let locale = browserLocale.substr(0, 2).toLowerCase(); |
| if (locale == 'pt') locale = 'pt_BR'; |
| const sanitizedLocale = allLocales.includes(locale) ? locale : 'en'; |
| setLocale(sanitizedLocale); |
| export const {getLocale, setLocale} = configureLocalization({ |
| if (!allLocales.includes(locale)) locale = 'en'; |
| /* webpackMode: "eager" */ |
| /* webpackExclude: /locales\.json$/ */ |
| `../lit-locales/generated/${locale}.js`); |