mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2024-12-19 16:33:04 +03:00
Added telemetry servers notification localization
Also now localization files can contain references to the constant properties
This commit is contained in:
parent
ba8b1fea59
commit
320f679f6d
18 changed files with 75 additions and 46 deletions
|
@ -31,5 +31,6 @@
|
|||
"Skip": "Überspringen",
|
||||
"SkipAndDontAsk": "Überspingen und nicht noch mal fragen",
|
||||
"LauncherUpdateTitle": "Launcher update verfügbar: ",
|
||||
"LauncherUpdateBody": "Sie können eine neue Version des Launchers aus dem Repository des Projekts unter https://notabug.org/nobody/an-anime-game-launcher herunterladen."
|
||||
"LauncherUpdateBody": "Sie können eine neue Version des Launchers aus dem Repository des Projekts unter {uri.launcher} herunterladen.",
|
||||
"TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!"
|
||||
}
|
|
@ -31,5 +31,6 @@
|
|||
"Skip": "Skip",
|
||||
"SkipAndDontAsk": "Skip and don't ask again",
|
||||
"LauncherUpdateTitle": "Launcher update available: ",
|
||||
"LauncherUpdateBody": "You can download a new version of the launcher from the project's repository at https://notabug.org/nobody/an-anime-game-launcher"
|
||||
"LauncherUpdateBody": "You can download a new version of the launcher from the project's repository at {uri.launcher}",
|
||||
"TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!"
|
||||
}
|
|
@ -31,5 +31,6 @@
|
|||
"Skip": "Skip",
|
||||
"SkipAndDontAsk": "Skip and don't ask again",
|
||||
"LauncherUpdateTitle": "Launcher update available: ",
|
||||
"LauncherUpdateBody": "You can download a new version of the launcher from the project's repository at https://notabug.org/nobody/an-anime-game-launcher"
|
||||
"LauncherUpdateBody": "You can download a new version of the launcher from the project's repository at {uri.launcher}",
|
||||
"TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!"
|
||||
}
|
|
@ -31,5 +31,6 @@
|
|||
"Skip": "Skip",
|
||||
"SkipAndDontAsk": "Skip and don't ask again",
|
||||
"LauncherUpdateTitle": "Launcher update available: ",
|
||||
"LauncherUpdateBody": "You can download a new version of the launcher from the project's repository at https://notabug.org/nobody/an-anime-game-launcher"
|
||||
"LauncherUpdateBody": "You can download a new version of the launcher from the project's repository at {uri.launcher}",
|
||||
"TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!"
|
||||
}
|
|
@ -31,5 +31,6 @@
|
|||
"Skip": "Skip",
|
||||
"SkipAndDontAsk": "Skip and don't ask again",
|
||||
"LauncherUpdateTitle": "Launcher update available: ",
|
||||
"LauncherUpdateBody": "You can download a new version of the launcher from the project's repository at https://notabug.org/nobody/an-anime-game-launcher"
|
||||
"LauncherUpdateBody": "You can download a new version of the launcher from the project's repository at {uri.launcher}",
|
||||
"TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!"
|
||||
}
|
|
@ -31,5 +31,6 @@
|
|||
"Skip": "Skip",
|
||||
"SkipAndDontAsk": "Skip and don't ask again",
|
||||
"LauncherUpdateTitle": "Launcher update available: ",
|
||||
"LauncherUpdateBody": "You can download a new version of the launcher from the project's repository at https://notabug.org/nobody/an-anime-game-launcher"
|
||||
"LauncherUpdateBody": "You can download a new version of the launcher from the project's repository at {uri.launcher}",
|
||||
"TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!"
|
||||
}
|
|
@ -31,5 +31,6 @@
|
|||
"Skip": "スキップ",
|
||||
"SkipAndDontAsk": "スキップして二度と聞かない",
|
||||
"LauncherUpdateTitle": "ランチャーのアップデートが可能 ",
|
||||
"LauncherUpdateBody": "ランチャーの新バージョンは、プロジェクトのリポジトリ(https://notabug.org/nobody/an-anime-game-launcher)からダウンロードできます。"
|
||||
"LauncherUpdateBody": "ランチャーの新バージョンは、プロジェクトのリポジトリ({uri.launcher})からダウンロードできます。",
|
||||
"TelemetryNotDisabled": "{placeholders.uppercase.company}のテレメトリサーバは無効になっていません!"
|
||||
}
|
|
@ -31,5 +31,6 @@
|
|||
"Skip": "Skip",
|
||||
"SkipAndDontAsk": "Skip and don't ask again",
|
||||
"LauncherUpdateTitle": "Launcher update available: ",
|
||||
"LauncherUpdateBody": "You can download a new version of the launcher from the project's repository at https://notabug.org/nobody/an-anime-game-launcher"
|
||||
"LauncherUpdateBody": "You can download a new version of the launcher from the project's repository at {uri.launcher}",
|
||||
"TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!"
|
||||
}
|
|
@ -31,5 +31,6 @@
|
|||
"Skip": "Skip",
|
||||
"SkipAndDontAsk": "Skip and don't ask again",
|
||||
"LauncherUpdateTitle": "Launcher update available: ",
|
||||
"LauncherUpdateBody": "You can download a new version of the launcher from the project's repository at https://notabug.org/nobody/an-anime-game-launcher"
|
||||
"LauncherUpdateBody": "You can download a new version of the launcher from the project's repository at {uri.launcher}",
|
||||
"TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!"
|
||||
}
|
|
@ -31,5 +31,6 @@
|
|||
"Skip": "Пропустить",
|
||||
"SkipAndDontAsk": "Пропустить и не спрашивать",
|
||||
"LauncherUpdateTitle": "Доступно обновление лаунчера: ",
|
||||
"LauncherUpdateBody": "Вы можете скачать новую версию лаунчера с репозитория проекта: https://notabug.org/nobody/an-anime-game-launcher"
|
||||
"LauncherUpdateBody": "Вы можете скачать новую версию лаунчера с репозитория проекта: {uri.launcher}",
|
||||
"TelemetryNotDisabled": "Серверы сбора телеметрии {placeholders.uppercase.company} не отключены!"
|
||||
}
|
|
@ -31,5 +31,6 @@
|
|||
"Skip": "Skip",
|
||||
"SkipAndDontAsk": "Skip and don't ask again",
|
||||
"LauncherUpdateTitle": "Launcher update available: ",
|
||||
"LauncherUpdateBody": "You can download a new version of the launcher from the project's repository at https://notabug.org/nobody/an-anime-game-launcher"
|
||||
"LauncherUpdateBody": "You can download a new version of the launcher from the project's repository at {uri.launcher}",
|
||||
"TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!"
|
||||
}
|
|
@ -31,5 +31,6 @@
|
|||
"Skip": "Skip",
|
||||
"SkipAndDontAsk": "Skip and don't ask again",
|
||||
"LauncherUpdateTitle": "Launcher update available: ",
|
||||
"LauncherUpdateBody": "You can download a new version of the launcher from the project's repository at https://notabug.org/nobody/an-anime-game-launcher"
|
||||
"LauncherUpdateBody": "You can download a new version of the launcher from the project's repository at {uri.launcher}",
|
||||
"TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!"
|
||||
}
|
|
@ -31,5 +31,6 @@
|
|||
"Skip": "省略",
|
||||
"SkipAndDontAsk": "跳过,不要再问",
|
||||
"LauncherUpdateTitle": "启动器更新可用:",
|
||||
"LauncherUpdateBody": "你可以从项目的资源库中下载新版本的启动器,网址是:https://notabug.org/nobody/an-anime-game-launcher"
|
||||
"LauncherUpdateBody": "你可以从项目的资源库中下载新版本的启动器,网址是:{uri.launcher}",
|
||||
"TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!"
|
||||
}
|
|
@ -31,5 +31,6 @@
|
|||
"Skip": "跳過",
|
||||
"SkipAndDontAsk": "跳過,不要再詢問我",
|
||||
"LauncherUpdateTitle": "啟動器有新的更新可用:",
|
||||
"LauncherUpdateBody": "您可以從此專案的資源庫中下載新版本的啟動器,網址是:https://notabug.org/nobody/an-anime-game-launcher"
|
||||
"LauncherUpdateBody": "您可以從此專案的資源庫中下載新版本的啟動器,網址是:{uri.launcher}",
|
||||
"TelemetryNotDisabled": "{placeholders.uppercase.company}'s telemetry servers don't disabled!"
|
||||
}
|
|
@ -197,8 +197,8 @@ $(() => {
|
|||
console.log(`${constants.placeholders.uppercase.company}'s telemetry servers doesn't disabled!`);
|
||||
|
||||
ipcRenderer.send('notification', {
|
||||
title: document.title, // FIXME add translation
|
||||
body: `${constants.placeholders.uppercase.company}'s telemetry servers doesn't disabled!`
|
||||
title: document.title,
|
||||
body: LauncherUI.i18n.translate('TelemetryNotDisabled')
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@ export class LauncherUI
|
|||
{
|
||||
if (!this._i18n)
|
||||
this._i18n = i18n;
|
||||
|
||||
return this._i18n;
|
||||
}
|
||||
|
||||
|
|
|
@ -138,7 +138,6 @@ export class Tools
|
|||
|
||||
let matches = /^[dwxr\-]+ [\w/]+[ ]+(\d+) [0-9\-]+ [0-9\:]+ (.+)/.exec(line);
|
||||
|
||||
// TODO: compressedSize?
|
||||
if (matches)
|
||||
{
|
||||
total += parseInt(matches[1]);
|
||||
|
|
|
@ -1,46 +1,61 @@
|
|||
const path = require('path');
|
||||
const fs = require('fs');
|
||||
|
||||
import { constants } from './constants';
|
||||
|
||||
export class i18n
|
||||
{
|
||||
public static readonly localesDir = path.join(path.dirname(__dirname), '..', 'locales');
|
||||
public static readonly localesDir = path.join(path.dirname(__dirname), '..', 'locales');
|
||||
|
||||
public static loadedLanguage: any;
|
||||
public static loadedLanguage: any;
|
||||
|
||||
public static translate (phrase: string)
|
||||
{
|
||||
if (i18n.loadedLanguage === undefined)
|
||||
this.setLang(navigator.language);
|
||||
public static translate (phrase: string): string
|
||||
{
|
||||
if (i18n.loadedLanguage === undefined)
|
||||
this.setLang(navigator.language);
|
||||
|
||||
return i18n.loadedLanguage[phrase] ?? phrase;
|
||||
}
|
||||
let translation = i18n.loadedLanguage[phrase] ?? phrase;
|
||||
let item;
|
||||
|
||||
public static setLang (lang: string)
|
||||
{
|
||||
lang = lang.toLowerCase();
|
||||
while ((item = /\{([a-zA-Z\.]+)\}/g.exec(translation)) !== null)
|
||||
{
|
||||
let value = constants;
|
||||
|
||||
// Test if the locale is the same string so if it's de-de or id-id remove -de or -id like navigator.language does.
|
||||
let samecode = new RegExp(`(${lang.replace(/-.*$/, '')}.*){2}`, 'g');
|
||||
// @ts-expect-error
|
||||
item[1].split('.').forEach(ref => value = value[ref]);
|
||||
|
||||
if (samecode.test(lang))
|
||||
lang = lang.replace(/-.*$/, '');
|
||||
translation = translation.replace(item[0], value);
|
||||
}
|
||||
|
||||
switch (lang)
|
||||
{
|
||||
case 'ja-jp':
|
||||
lang = 'ja';
|
||||
return translation;
|
||||
}
|
||||
|
||||
break;
|
||||
public static setLang (lang: string)
|
||||
{
|
||||
lang = lang.toLowerCase();
|
||||
|
||||
case 'vi-vn':
|
||||
lang = 'vi';
|
||||
// Test if the locale is the same string so if it's de-de or id-id remove -de or -id like navigator.language does.
|
||||
let samecode = new RegExp(`(${lang.replace(/-.*$/, '')}.*){2}`, 'g');
|
||||
|
||||
break;
|
||||
}
|
||||
if (samecode.test(lang))
|
||||
lang = lang.replace(/-.*$/, '');
|
||||
|
||||
i18n.loadedLanguage = JSON.parse(fs.readFileSync(path.join(this.localesDir,
|
||||
fs.existsSync(path.join(this.localesDir, lang + '.json')) ?
|
||||
lang + '.json' : 'en.json'
|
||||
)));
|
||||
}
|
||||
switch (lang)
|
||||
{
|
||||
case 'ja-jp':
|
||||
lang = 'ja';
|
||||
|
||||
break;
|
||||
|
||||
case 'vi-vn':
|
||||
lang = 'vi';
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
i18n.loadedLanguage = JSON.parse(fs.readFileSync(path.join(this.localesDir,
|
||||
fs.existsSync(path.join(this.localesDir, lang + '.json')) ?
|
||||
lang + '.json' : 'en.json'
|
||||
)));
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue