diff --git a/src/api/focus/keymap/db.js b/src/api/focus/keymap/db.js index c41fdbac2..e9de7ca09 100644 --- a/src/api/focus/keymap/db.js +++ b/src/api/focus/keymap/db.js @@ -21,8 +21,7 @@ import { Base, USQwerty } from "./db/base"; import { constants } from "./db/constants"; import { withModifiers } from "./db/modifiers"; -import enLangMap from "./cldr_languages/en"; -import nlLangMap from "./cldr_languages/nl"; +import { languageMaps } from "./language_maps"; global.chrysalis_keymapdb_instance = null; @@ -39,10 +38,7 @@ class KeymapDB { this.loadLayouts(); this.constants = constants; this.supported_layouts = {}; - this.layout_langs = { - en: enLangMap, - nl: nlLangMap, - }; + this.layout_langs = languageMaps; } return global.chrysalis_keymapdb_instance; diff --git a/src/api/focus/keymap/language_maps.js b/src/api/focus/keymap/language_maps.js new file mode 100644 index 000000000..f48792ade --- /dev/null +++ b/src/api/focus/keymap/language_maps.js @@ -0,0 +1,11 @@ +// This file is auto-generated. Do not edit manually. +export const languageMaps = { + "de": require("./cldr_languages/de.json"), + "en": require("./cldr_languages/en.json"), + "es": require("./cldr_languages/es.json"), + "fr": require("./cldr_languages/fr.json"), + "id": require("./cldr_languages/id.json"), + "nb-NO": require("./cldr_languages/nb_no.json"), + "nl": require("./cldr_languages/nl.json"), + "zh-Hans": require("./cldr_languages/zh_hans.json") +}; diff --git a/src/renderer/i18n.js b/src/renderer/i18n.js index dc8a871f5..62243c0ad 100644 --- a/src/renderer/i18n.js +++ b/src/renderer/i18n.js @@ -1,35 +1,43 @@ -// -*- mode: js-jsx -*- -/* Chrysalis -- Kaleidoscope Command Center - * Copyright (C) 2018-2022 Keyboardio, Inc. - * - * This program is free software: you can redistribute it and/or modify it under - * the terms of the GNU General Public License as published by the Free Software - * Foundation, version 3. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -import English from "@renderer/i18n/en"; -import Dutch from "@renderer/i18n/nl"; +// This file is auto-generated. Do not edit manually. +import de from "@renderer/i18n/de"; +import en from "@renderer/i18n/en"; +import es from "@renderer/i18n/es"; +import fr from "@renderer/i18n/fr"; +import id from "@renderer/i18n/id"; +import nb_NO from "@renderer/i18n/nb-NO"; +import nl from "@renderer/i18n/nl"; +import zh_Hans from "@renderer/i18n/zh-Hans"; import i18n from "i18next"; import { initReactI18next } from "react-i18next"; const resources = { - en: { - messages: English, + "de": { + messages: de, + }, + "en": { + messages: en, + }, + "es": { + messages: es, + }, + "fr": { + messages: fr, + }, + "id": { + messages: id, + }, + "nb-NO": { + messages: nb_NO, + }, + "nl": { + messages: nl, }, - nl: { - messages: Dutch, + "zh-Hans": { + messages: zh_Hans, }, }; -i18n // eslint-disable-line import/no-named-as-default-member +i18n .use(initReactI18next) .init({ react: { @@ -51,7 +59,7 @@ i18n.refreshHardware = (device) => { Object.keys(i18n.options.resources).forEach((code) => { const key = "devices." + device?.info.vendor + "." + device?.info.product + ".updateInstructions"; const instructions = { - updateInstructions: i18n.exists(key) ? i18n.t(key) : undefined, // eslint-disable-line import/no-named-as-default-member + updateInstructions: i18n.exists(key) ? i18n.t(key) : undefined, }; i18n.addResource(code, "messages", "hardware", instructions); }); diff --git a/src/renderer/screens/Preferences/ui/LookAndFeelPreferences.js b/src/renderer/screens/Preferences/ui/LookAndFeelPreferences.js index 10dd18c68..16f3f301d 100644 --- a/src/renderer/screens/Preferences/ui/LookAndFeelPreferences.js +++ b/src/renderer/screens/Preferences/ui/LookAndFeelPreferences.js @@ -133,13 +133,21 @@ function LookAndFeelPreferences(props) { }; const languages = Object.keys(i18n.options.resources).map((code) => { - const t = i18n.getFixedT(code); + // Check if this specific language has the translation + const translation = i18n.t("this_translation_language", { + lng: code, + fallbackLng: [], // Empty array means no fallback for just this translation + }); + + // If we got back the translation key, it means translation is missing + if (translation === "this_translation_language") return null; + return ( - {t("this_translation_language")} + {translation} ); - }); + }).filter(Boolean); const systemSvg = (