Skip to content

Commit

Permalink
Enable Spanish translations
Browse files Browse the repository at this point in the history
cdauth committed Apr 26, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
1 parent 0661448 commit 301f044
Showing 7 changed files with 15 additions and 1 deletion.
3 changes: 3 additions & 0 deletions frontend/src/lib/utils/i18n.ts
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ import { type i18n } from "i18next";
import { defineComponent, ref, type Directive } from "vue";
import messagesEn from "../../i18n/en.json";
import messagesDe from "../../i18n/de.json";
import messagesEs from "../../i18n/es.json";
import messagesNbNo from "../../i18n/nb-NO.json";
import messagesRu from "../../i18n/ru.json";
import { LANG_COOKIE, LANG_QUERY, decodeQueryString, getAcceptHotI18n, getRawI18n, onI18nReady, setCurrentUnitsGetter } from "facilmap-utils";
@@ -14,13 +15,15 @@ const namespace = "facilmap-frontend";
onI18nReady((i18n) => {
i18n.addResourceBundle("en", namespace, messagesEn);
i18n.addResourceBundle("de", namespace, messagesDe);
i18n.addResourceBundle("es", namespace, messagesEs);
i18n.addResourceBundle("nb-NO", namespace, messagesNbNo);
i18n.addResourceBundle("ru", namespace, messagesRu);
});

if (import.meta.hot) {
import.meta.hot!.accept(`../../i18n/en.json`, getAcceptHotI18n("en", namespace));
import.meta.hot!.accept(`../../i18n/de.json`, getAcceptHotI18n("de", namespace));
import.meta.hot!.accept(`../../i18n/es.json`, getAcceptHotI18n("es", namespace));
import.meta.hot!.accept(`../../i18n/nb-NO.json`, getAcceptHotI18n("nb-NO", namespace));
import.meta.hot!.accept(`../../i18n/ru.json`, getAcceptHotI18n("ru", namespace));
}
3 changes: 3 additions & 0 deletions leaflet/src/utils/i18n.ts
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@
import type { i18n } from "i18next";
import messagesDe from "../i18n/de.json";
import messagesEn from "../i18n/en.json";
import messagesEs from "../i18n/es.json";
import messagesNbNo from "../i18n/nb-NO.json";
import messagesRu from "../i18n/ru.json";
import { getAcceptHotI18n, getRawI18n, onI18nReady } from "facilmap-utils";
@@ -11,6 +12,7 @@ const namespace = "facilmap-leaflet";
onI18nReady((i18n) => {
i18n.addResourceBundle("en", namespace, messagesEn);
i18n.addResourceBundle("de", namespace, messagesDe);
i18n.addResourceBundle("es", namespace, messagesEs);
i18n.addResourceBundle("nb-NO", namespace, messagesNbNo);
i18n.addResourceBundle("ru", namespace, messagesRu);
});
@@ -19,6 +21,7 @@ if (import.meta.hot) {
if (import.meta.hot) {
import.meta.hot!.accept(`../i18n/en.json`, getAcceptHotI18n("en", namespace));
import.meta.hot!.accept(`../i18n/de.json`, getAcceptHotI18n("de", namespace));
import.meta.hot!.accept(`../i18n/es.json`, getAcceptHotI18n("es", namespace));
import.meta.hot!.accept(`../i18n/nb-NO.json`, getAcceptHotI18n("nb-NO", namespace));
import.meta.hot!.accept(`../i18n/ru.json`, getAcceptHotI18n("ru", namespace));
}
2 changes: 2 additions & 0 deletions server/src/i18n.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { defaultI18nGetter, getRawI18n, onI18nReady, setLanguageDetector, setI18nGetter, isCustomLanguageDetector, isCustomI18nGetter, LANG_QUERY, LANG_COOKIE, setCurrentUnitsGetter } from "facilmap-utils";
import messagesEn from "./i18n/en.json";
import messagesDe from "./i18n/de.json";
import messagesEs from "./i18n/es.json";
import messagesNbNo from "./i18n/nb-NO.json";
import messagesRu from "./i18n/ru.json";
import type { i18n } from "i18next";
@@ -39,6 +40,7 @@ declare module 'domain' {
onI18nReady((i18n) => {
i18n.addResourceBundle("en", namespace, messagesEn);
i18n.addResourceBundle("de", namespace, messagesDe);
i18n.addResourceBundle("es", namespace, messagesEs);
i18n.addResourceBundle("nb-NO", namespace, messagesNbNo);
i18n.addResourceBundle("ru", namespace, messagesRu);
});
2 changes: 1 addition & 1 deletion utils/src/i18n-utils.ts
Original file line number Diff line number Diff line change
@@ -2,7 +2,7 @@ import { Units } from "facilmap-types";
import i18next, { type CustomPluginOptions, type Module, type Newable, type i18n } from "i18next";
import LanguageDetector from "i18next-browser-languagedetector";

export const LANGUAGES = ["en", "de", "nb-NO", "ru"];
export const LANGUAGES = ["en", "de", "es", "nb-NO", "ru"];

export const DEFAULT_LANGUAGE = "en";

4 changes: 4 additions & 0 deletions utils/src/i18n.ts
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@ import type { i18n } from "i18next";
import { getAcceptHotI18n, getRawI18n, onI18nReady } from "./i18n-utils";
import messagesDe from "./i18n/de.json";
import messagesEn from "./i18n/en.json";
import messagesEs from "./i18n/es.json";
import messagesNbNo from "./i18n/nb-NO.json";
import messagesRu from "./i18n/ru.json";

@@ -11,6 +12,7 @@ const namespace = "facilmap-utils";
onI18nReady((i18n) => {
i18n.addResourceBundle("en", namespace, messagesEn);
i18n.addResourceBundle("de", namespace, messagesDe);
i18n.addResourceBundle("es", namespace, messagesEs);
i18n.addResourceBundle("nb-NO", namespace, messagesNbNo);
i18n.addResourceBundle("ru", namespace, messagesRu);
});
@@ -19,6 +21,7 @@ if (import.meta.hot) {
if (import.meta.hot) {
import.meta.hot!.accept(`./i18n/en.json`, getAcceptHotI18n("en", namespace));
import.meta.hot!.accept(`./i18n/de.json`, getAcceptHotI18n("de", namespace));
import.meta.hot!.accept(`./i18n/es.json`, getAcceptHotI18n("es", namespace));
import.meta.hot!.accept(`./i18n/nb-NO.json`, getAcceptHotI18n("nb-NO", namespace));
import.meta.hot!.accept(`./i18n/ru.json`, getAcceptHotI18n("ru", namespace));
}
@@ -37,6 +40,7 @@ export function getLocalizedLanguageList(): Record<string, string> {
return {
"en": getI18n().t("i18n.language-en", { lng: "en" }),
"de": getI18n().t("i18n.language-de", { lng: "de" }),
"es": getI18n().t("i18n.language-es", { lng: "es" }),
"nb-NO": getI18n().t("i18n.language-nb-no", { lng: "nb-NO" }),
"ru": getI18n().t("i18n.language-ru", { lng: "ru" })
};
1 change: 1 addition & 0 deletions utils/src/i18n/de.json
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
"i18n": {
"language-en": "Englisch",
"language-de": "Deutsch",
"language-es": "Spanisch",
"language-nb-no": "Norwegisch Bokmål (Norwegen)",
"language-ru": "Russian"
},
1 change: 1 addition & 0 deletions utils/src/i18n/en.json
Original file line number Diff line number Diff line change
@@ -17,6 +17,7 @@
"i18n": {
"language-en": "English",
"language-de": "German",
"language-es": "Spanish",
"language-nb-no": "Norwegian Bokmål (Norway)",
"language-ru": "Russian"
},

0 comments on commit 301f044

Please sign in to comment.