Added telemetry servers notification localization

Also now localization files can contain references to the constant properties
This commit is contained in:
Observer KRypt0n_ 2021-11-03 16:34:46 +02:00
parent ba8b1fea59
commit 320f679f6d
No known key found for this signature in database
GPG key ID: DC5D4EC1303465DA
18 changed files with 75 additions and 46 deletions

View file

@ -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!"
}

View file

@ -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!"
}

View file

@ -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!"
}

View file

@ -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!"
}

View file

@ -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!"
}

View file

@ -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!"
}

View file

@ -31,5 +31,6 @@
"Skip": "スキップ",
"SkipAndDontAsk": "スキップして二度と聞かない",
"LauncherUpdateTitle": "ランチャーのアップデートが可能 ",
"LauncherUpdateBody": "ランチャーの新バージョンは、プロジェクトのリポジトリhttps://notabug.org/nobody/an-anime-game-launcherからダウンロードできます。"
"LauncherUpdateBody": "ランチャーの新バージョンは、プロジェクトのリポジトリ({uri.launcher})からダウンロードできます。",
"TelemetryNotDisabled": "{placeholders.uppercase.company}のテレメトリサーバは無効になっていません!"
}

View file

@ -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!"
}

View file

@ -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!"
}

View file

@ -31,5 +31,6 @@
"Skip": "Пропустить",
"SkipAndDontAsk": "Пропустить и не спрашивать",
"LauncherUpdateTitle": "Доступно обновление лаунчера: ",
"LauncherUpdateBody": "Вы можете скачать новую версию лаунчера с репозитория проекта: https://notabug.org/nobody/an-anime-game-launcher"
"LauncherUpdateBody": "Вы можете скачать новую версию лаунчера с репозитория проекта: {uri.launcher}",
"TelemetryNotDisabled": "Серверы сбора телеметрии {placeholders.uppercase.company} не отключены!"
}

View file

@ -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!"
}

View file

@ -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!"
}

View file

@ -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!"
}

View file

@ -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!"
}

View file

@ -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')
});
}

View file

@ -28,6 +28,7 @@ export class LauncherUI
{
if (!this._i18n)
this._i18n = i18n;
return this._i18n;
}

View file

@ -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]);

View file

@ -1,18 +1,33 @@
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 loadedLanguage: any;
public static translate (phrase: string)
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;
while ((item = /\{([a-zA-Z\.]+)\}/g.exec(translation)) !== null)
{
let value = constants;
// @ts-expect-error
item[1].split('.').forEach(ref => value = value[ref]);
translation = translation.replace(item[0], value);
}
return translation;
}
public static setLang (lang: string)