Skip to content

armgit / dashy

Public Imported from GitHub
0

๐Ÿš€ A self-hostable personal dashboard built for you. Includes status-checking, widgets, themes, icon packs, a UI editor and tons more!

๐ŸŒ Updates alias for Chinese (#1920)

Alicia Sykesf5f98b2a4b07
diff --git a/src/utils/ConfigHelpers.js b/src/utils/ConfigHelpers.js
index a2944bf1..f970c8a9 100644
--- a/src/utils/ConfigHelpers.js
+++ b/src/utils/ConfigHelpers.js
@@ -89,13 +89,16 @@ export const getCustomKeyShortcuts = (sections) => {
/**
* Gets the users chosen language. Defaults to English.
+ * If for any reason a lang code changes, add to legacyAliases for backwards compat
* @returns {object} Language, including code, name and flag
*/
export const getUsersLanguage = () => {
const langCode = localStorage[localStorageKeys.LANGUAGE]
|| config.appConfig.language
|| defaultLanguage;
- const langObj = languages.find(lang => lang.code === langCode);
+ const legacyAliases = { cn: 'zh-CN' };
+ const resolvedCode = legacyAliases[langCode] || langCode;
+ const langObj = languages.find(lang => lang.code === resolvedCode);
return langObj;
};
@@ -106,6 +109,7 @@ export const getUsersLanguage = () => {
* @returns {Boolean} isValid
*/
export const targetValidator = (target) => {
+ if (!target) return true;
const acceptedTargets = ConfigSchema.properties.sections.items
.properties.items.items.properties.target.enum;
const isTargetValid = acceptedTargets.indexOf(target) !== -1;
diff --git a/src/utils/languages.js b/src/utils/languages.js
index 59e0c811..69bf9405 100644
--- a/src/utils/languages.js
+++ b/src/utils/languages.js
@@ -204,7 +204,7 @@ export const languages = [
},
{ // Chinese
name: '็ฎ€ไฝ“ไธญๆ–‡',
- code: 'cn',
+ code: 'zh-CN',
locale: zhCN,
flag: '๐Ÿ‡จ๐Ÿ‡ณ',
},