The swiss army knife of lossless video/audio editing
i18n improvements #29
Mikael Finstad471f5d7716d8
diff --git a/src/App.jsx b/src/App.jsxindex cbf0c782..a10baa2e 100644--- a/src/App.jsx+++ b/src/App.jsx@@ -50,6 +50,7 @@ import {openDirToast, askForHtml5ifySpeed, isMasBuild, isStoreBuild,} from './util';import { openSendReportDialog } from './reporting';+import { fallbackLng } from './i18n';import loadingLottie from './7077-magic-flow.json';@@ -222,7 +223,7 @@ const App = memo(() => {useEffect(() => safeSetConfig('language', language), [language]);useEffect(() => {- if (language != null) i18n.changeLanguage(language).catch(console.error);+ i18n.changeLanguage(language || fallbackLng).catch(console.error);}, [language]);// This useEffect must be placed after all usages of firstUpdateRef.currentdiff --git a/src/Settings.jsx b/src/Settings.jsxindex 620d7b62..12717d8e 100644--- a/src/Settings.jsx+++ b/src/Settings.jsx@@ -22,6 +22,7 @@ const Settings = memo(({setLanguage(l);}+ // https://www.electronjs.org/docs/api/localesconst langNames = {en: 'English',nb: 'Norsk',diff --git a/src/i18n.js b/src/i18n.jsindex bfaee88a..f10d407d 100644--- a/src/i18n.js+++ b/src/i18n.js@@ -11,6 +11,23 @@ const { join } = require('path');const getLangPath = (subPath) => (isDev ? join('public', subPath) : join(app.getAppPath(), 'build', subPath));+// Weblate hardcodes different lang codes than electron+// https://www.electronjs.org/docs/api/locales+const mapLang = (lng) => ({+ nb: 'nb_NO',+ no: 'nb_NO',+ nn: 'nb_NO',+ zh: 'zh_Hans',+ 'zh-CN': 'zh_Hans',+ 'zh-TW': 'zh_Hans',+ fr: 'fr',+ 'fr-CA': 'fr',+ 'fr-CH': 'fr',+ 'fr-FR': 'fr',+}[lng] || lng);++export const fallbackLng = 'en';+// https://github.com/i18next/i18next/issues/869i18n.use(Backend)@@ -23,7 +40,7 @@ i18n// for all options read: https://www.i18next.com/overview/configuration-options// See also i18next-scanner.config.js.init({- fallbackLng: 'en',+ fallbackLng,// debug: isDev,// saveMissing: isDev,// updateMissing: isDev,@@ -38,8 +55,8 @@ i18ncontextSeparator: false,backend: {- loadPath: getLangPath('locales/{{lng}}/{{ns}}.json'),- addPath: getLangPath('locales/{{lng}}/{{ns}}.missing.json'),+ loadPath: (lng, ns) => getLangPath(`locales/${mapLang(lng)}/${ns}.json`),+ addPath: (lng, ns) => getLangPath(`locales/${mapLang(lng)}/${ns}.missing.json`),},interpolation: {