Add left sidebar translation

This commit is contained in:
月月
2024-09-15 16:10:30 +08:00
parent 1e3f49a3f8
commit 73334862c6
13 changed files with 132 additions and 100 deletions
+3 -15
View File
@@ -35,19 +35,10 @@ async function loadLanguage(lang) {
currentLanguage = lang;
}
// Set the current language
function setLanguage(lang) {
try {
loadLanguage(lang);
} catch (error) {
console.error(`Failed to set language, language code: ${lang}:`, error);
}
}
// Get translation, if no corresponding value, return the key
function setString(key) {
function getString(key) {
if (!translations[currentLanguage]?.[key]) {
console.log(':' + key);
console.log('Not found:' + key);
}
return translations[currentLanguage]?.[key] || key;
}
@@ -63,7 +54,4 @@ function init() {
}
}
export { setString, init, setLanguage };
export { getString, init };