mirror of
https://github.com/maputnik/editor.git
synced 2026-09-14 16:27:27 +00:00
64b4e5a67c
## Launch Checklist - [x] Adds Azerbaijani (`az`) as a supported UI language, following the same pattern as the existing Turkish (`tr`) locale. - [x] `src/locales/az/translation.json` — full translation, 202 keys (matches `tr`/`de` key set exactly). - [x] Registered `az` in `i18next.config.ts` (`locales` array) and `src/i18n.ts` (`supportedLanguages`), alphabetically ordered. - [x] Added `az` row to the `src/locales/README.md` contributors table. - [ ] Link to related issues. - [ ] Include before/after visuals or gifs if this PR includes visual changes. (N/A — translation-only change, no UI layout changes.) - [ ] Write tests for all new functionality. (N/A — no new functionality, translation strings only.) - [ ] Add an entry to `CHANGELOG.md` under the `## main` section. (Not done — the prior Turkish locale PR (#1886) did not add a CHANGELOG entry either, so following existing precedent.) Terminology used consistently throughout: Layer → Qat, Style → Üslub, Source → Mənbə, Zoom → Yaxınlaşma, Filter → Süzgəc.
47 lines
1.5 KiB
TypeScript
47 lines
1.5 KiB
TypeScript
import i18n from "i18next";
|
|
import detector from "i18next-browser-languagedetector";
|
|
import resourcesToBackend from "i18next-resources-to-backend";
|
|
import { initReactI18next } from "react-i18next";
|
|
|
|
export const supportedLanguages = {
|
|
"az": "Azərbaycan",
|
|
"de": "Deutsch",
|
|
"en": "English",
|
|
"fr": "Français",
|
|
"he": "עברית",
|
|
"it": "Italiano",
|
|
"ja": "日本語",
|
|
"ko": "한국어",
|
|
"tr": "Türkçe",
|
|
"zh": "简体中文"
|
|
} as const;
|
|
|
|
i18n
|
|
.use(detector) // detect user language from browser settings
|
|
.use(
|
|
resourcesToBackend((lang: string, ns: string) => {
|
|
if (lang === "en") {
|
|
// English is the default language, so we don't need to load any resources for it.
|
|
return {};
|
|
}
|
|
return import(`./locales/${lang}/${ns}.json`);
|
|
})
|
|
)
|
|
.use(initReactI18next) // required to initialize react-i18next
|
|
.init({
|
|
supportedLngs: Object.keys(supportedLanguages),
|
|
keySeparator: false, // we do not use keys in form messages.welcome
|
|
nsSeparator: false,
|
|
interpolation: {
|
|
escapeValue: false // React already escapes for us
|
|
},
|
|
saveMissing: true, // this needs to be set for missingKeyHandler to work
|
|
fallbackLng: false, // we set the fallback to false so we can get the correct language in the missingKeyHandler
|
|
missingKeyHandler: (lngs, _ns, key) => {
|
|
if (lngs[0] === "en") { return; }
|
|
console.warn(`Missing translation for "${key}" in "${lngs.join(", ")}"`);
|
|
}
|
|
});
|
|
|
|
export { i18n };
|