Skip to content

Commit

Permalink
feat: i18n support for new API dialog
Browse files Browse the repository at this point in the history
  • Loading branch information
HoraceHuang-ui committed Jan 28, 2024
1 parent 34ecdd8 commit 9b75bc2
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 10 deletions.
6 changes: 4 additions & 2 deletions electron/main/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,12 @@ async function createWindow() {
function convertObjectToJson(obj: any) {
if (typeof obj !== "object" || obj === null || obj === undefined) return obj;
const entries = Object.entries(obj)
.filter(([key, value]) => !key.startsWith("_") && !(value instanceof EnkaClient)) // filter out private properties and EnkaClient instance, which has circular object
// filter out private properties and EnkaClient instance, which has circular object
.filter(([key, value]) => !key.startsWith("_") && !(value instanceof EnkaClient))
.map(([key, value]) => [key, convertObjectToJson(value)]);
if (obj instanceof TextAssets) {
entries.push(["text", obj instanceof DynamicTextAssets ? obj.getNullableReplacedText() : obj.getNullable()]); // convert TextAssets to string
// convert TextAssets to string
entries.push(["text", obj instanceof DynamicTextAssets ? obj.getNullableReplacedText() : obj.getNullable()]);
}
if (obj instanceof Array) {
const arr = []
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/en_US.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
"mainpage_title": "miHoYo miXeD Launcher",
"mainpage_buttonText": "Launch {game}",
"genshin_launcherContentsUrl": "https://sdk-os-static.mihoyo.com/hk4e_global/mdk/launcher/api/content?filter_adv=false&key=gcStgarh&language=en-us&launcher_id=10",
"gs_apiChangeTitle": "Welcome to miXeD!",
"gs_apiChangeText": "Due to API change, this update will wipe your Genshin Impact player data, please retrieve again. Apologies for inconvenience!",
"gs_enkaLangCode": "en",
"gs_emptyPlayerTip": "Player details will be displayed here",
"gs_showcaseTip": "Player details unavailable, please enable 'Show Character Details' in game and try again.",
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/fr_FR.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
"mainpage_title": "miHoYo miXeD Launcher",
"mainpage_buttonText": "Lancer {game}",
"genshin_launcherContentsUrl": "https://sdk-os-static.mihoyo.com/hk4e_global/mdk/launcher/api/content?filter_adv=false&key=gcStgarh&language=fr-fr&launcher_id=10",
"gs_apiChangeTitle": "Welcome to miXeD!",
"gs_apiChangeText": "Due to API change, this update will wipe your Genshin Impact player data, please retrieve again. Apologies for inconvenience!",
"gs_enkaLangCode": "fr",
"gs_emptyPlayerTip": "Les détails du joueur s'afficheront ici",
"gs_showcaseTip": "Player details unavailable, please enable 'Show Character Details' in game and try again.",
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/ja_JP.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
"mainpage_title": "miHoYo miXeD ランチャー",
"mainpage_buttonText": "{game}を起動!",
"genshin_launcherContentsUrl": "https://sdk-os-static.mihoyo.com/hk4e_global/mdk/launcher/api/content?filter_adv=false&key=gcStgarh&language=ja-jp&launcher_id=10",
"gs_apiChangeTitle": "Welcome to miXeD!",
"gs_apiChangeText": "Due to API change, this update will wipe your Genshin Impact player data, please retrieve again. Apologies for inconvenience!",
"gs_enkaLangCode": "ja",
"gs_emptyPlayerTip": "キャラの詳細がここに表示されます",
"gs_showcaseTip": "キャラの詳細情報が利用できません。ゲーム内で「キャラクターの詳細を表示」を有効にして、もう一度お試しください。",
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/ru_RU.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
"mainpage_title": "Запуск miHoYo miXeD",
"mainpage_buttonText": "Запустить {game}",
"genshin_launcherContentsUrl": "https://sdk-os-static.mihoyo.com/hk4e_global/mdk/launcher/api/content?filter_adv=false&key=gcStgarh&language=ru-ru&launcher_id=10",
"gs_apiChangeTitle": "Welcome to miXeD!",
"gs_apiChangeText": "Due to API change, this update will wipe your Genshin Impact player data, please retrieve again. Apologies for inconvenience!",
"gs_enkaLangCode": "ru",
"gs_emptyPlayerTip": "Информация о игроке будет отображена здесь",
"gs_showcaseTip": "Информация о игроке недоступна. Включите 'Отображение деталей персонажей' в игре и попробуйте снова.",
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/zh_CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
"mainpage_title": "米哈游聚合启动器",
"mainpage_buttonText": "{game}启动",
"genshin_launcherContentsUrl": "https://sdk-static.mihoyo.com/hk4e_cn/mdk/launcher/api/content?filter_adv=false&key=eYd89JmJ&language=zh-cn&launcher_id=18",
"gs_apiChangeTitle": "欢迎使用miXeD!",
"gs_apiChangeText": "由于API变更,此次更新将清除您的原神账号信息,请您重新获取。为您带来不便敬请谅解!",
"gs_enkaLangCode": "chs",
"gs_emptyPlayerTip": "此处将显示角色的详细信息",
"gs_showcaseTip": "当前暂无详细信息,请在游戏内打开“显示角色详情”后再试。",
Expand Down
2 changes: 2 additions & 0 deletions src/i18n/zh_TW.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@
"mainpage_title": "米哈游聚合啓動器",
"mainpage_buttonText": "{game}啓動",
"genshin_launcherContentsUrl": "https://sdk-os-static.mihoyo.com/hk4e_global/mdk/launcher/api/content?filter_adv=false&key=gcStgarh&language=zh-tw&launcher_id=10",
"gs_apiChangeTitle": "歡迎使用miXeD!",
"gs_apiChangeText": "由於API變更,此次更新將清除您的原神賬戶信息,請您重新獲取。爲您帶來不便敬請諒解!",
"gs_enkaLangCode": "zh-TW",
"gs_emptyPlayerTip": "此處將顯示角色的詳細信息",
"gs_showcaseTip": "當前暫無詳細信息,請在游戲内打開”顯示角色詳情“后再試。",
Expand Down
10 changes: 2 additions & 8 deletions src/pages/MainPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,14 @@ onMounted(async () => {
window.store.get('newApi').then((resp: boolean) => {
if (!resp) {
useDialog(dialogComponent(dialogStyle.value), {}, {
title: '欢迎使用miXeD!',
msg: '由于API变更,此次更新将清除您的原神账号信息,请您重新获取。为您带来不便敬请谅解!',
title: translate('gs_apiChangeTitle'),
msg: translate('gs_apiChangeText'),
showCancel: false
})
window.store.delete('genshinInfo')
window.store.set('newApi', true, false)
}
})
// window.enka.getGenshinPlayer('193320369', 'chs').then((resp: any) => {
// console.log(resp)
// }).catch((err) => {
// console.error(err)
// })
})
const genshin = async () => {
Expand Down

0 comments on commit 9b75bc2

Please sign in to comment.