-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
603 additions
and
488 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
{ | ||
"version": "3.2.4.3", | ||
"translations":{ | ||
"en": { | ||
"input": "Enter your message", | ||
"send": "Send", | ||
"settings": "Settings", | ||
"api-settings": "API Settings", | ||
"history": "Chat History", | ||
"sync": "Sync", | ||
"clear": "Clear Memory", | ||
"save": "Save", | ||
"language": "Language", | ||
"invalid-uuid": "Please enter a valid UUID", | ||
"unknown-error": "Unknown Error", | ||
"uuid-not-found": "UUID does not exist", | ||
"memory-clear": "Are you sure you want to clear the memory?", | ||
"model": "Model", | ||
"custom": "Custom" | ||
}, | ||
"zh-cn": { | ||
"input": "输入你的消息", | ||
"send": "发送", | ||
"settings": "设置", | ||
"api-settings": "API 设置", | ||
"history": "聊天记录", | ||
"sync": "同步", | ||
"clear": "清空记忆", | ||
"save": "保存", | ||
"language": "语言", | ||
"invalid-uuid": "请输入有效的UUID", | ||
"unknown-error": "未知错误", | ||
"uuid-not-found": "UUID不存在", | ||
"memory-clear": "确定要清除记忆吗?", | ||
"model": "模型", | ||
"custom": "自定义" | ||
}, | ||
"zh-hk": { | ||
"version": "3.2.4.2", | ||
"input": "輸入你的消息", | ||
"send": "發送", | ||
"settings": "設置", | ||
"api-settings": "API 設置", | ||
"history": "聊天記錄", | ||
"sync": "同步", | ||
"clear": "清空記憶", | ||
"save": "保存", | ||
"language": "語言", | ||
"invalid-uuid": "請輸入有效的UUID", | ||
"unknown-error": "未知錯誤", | ||
"uuid-not-found": "UUID不存在", | ||
"memory-clear": "確定要清除記憶嗎?", | ||
"model": "模型", | ||
"custom": "自定義" | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
async function loadTranslations() { | ||
const response = await fetch('/static/locales.json'); | ||
const data = await response.json(); | ||
return data; | ||
} | ||
|
||
function translatePage(translations, lang) { | ||
document.querySelectorAll('[data-i18n]').forEach(element => { | ||
const key = element.getAttribute('data-i18n'); | ||
if (translations[lang] && translations[lang][key]) { | ||
element.textContent = translations[lang][key]; | ||
} else { | ||
element.textContent = key; | ||
} | ||
}); | ||
|
||
document.querySelectorAll('[data-i18n-title]').forEach(element => { | ||
const key = element.getAttribute('data-i18n-title'); | ||
if (translations[lang] && translations[lang][key]) { | ||
element.setAttribute('title', translations[lang][key]); | ||
} else { | ||
element.setAttribute('title', key); | ||
} | ||
}); | ||
|
||
const messageElement = document.getElementById('message'); | ||
if (messageElement) { | ||
if (translations[lang] && translations[lang]['input']) { | ||
messageElement.placeholder = translations[lang]['input']; | ||
} else { | ||
messageElement.placeholder = 'Enter your message'; | ||
} | ||
} | ||
} | ||
|
||
function translate(key) { | ||
const lang = localStorage.getItem('language') || 'en'; | ||
const allTranslations = JSON.parse(localStorage.getItem('allTranslations')) || {}; | ||
return allTranslations[lang][key] || key; | ||
} | ||
|
||
async function setLanguage(lang) { | ||
const allTranslations = JSON.parse(localStorage.getItem('allTranslations')) || {}; | ||
translatePage(allTranslations, lang); | ||
localStorage.setItem('language', lang); | ||
} | ||
|
||
document.addEventListener('DOMContentLoaded', async () => { | ||
const savedLanguage = localStorage.getItem('language') || 'en'; | ||
const storedVersion = localStorage.getItem('translations_version'); | ||
const data = await loadTranslations(); | ||
const currentVersion = data.version; | ||
const allTranslations = data.translations; | ||
|
||
if (storedVersion !== currentVersion) { | ||
localStorage.setItem('allTranslations', JSON.stringify(allTranslations)); | ||
localStorage.setItem('translations_version', currentVersion); | ||
} | ||
|
||
translatePage(allTranslations, savedLanguage); | ||
const translations = JSON.parse(localStorage.getItem('allTranslations')) || allTranslations; | ||
document.getElementById('language-select').value = savedLanguage; | ||
await setLanguage(savedLanguage, translations); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
Oops, something went wrong.