diff --git a/public/locales/de.json b/public/locales/de.json index 676a6f6..22c5173 100644 --- a/public/locales/de.json +++ b/public/locales/de.json @@ -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!" } \ No newline at end of file diff --git a/public/locales/en-us.json b/public/locales/en-us.json index d6ab86b..0d47fab 100644 --- a/public/locales/en-us.json +++ b/public/locales/en-us.json @@ -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!" } \ No newline at end of file diff --git a/public/locales/en.json b/public/locales/en.json index 049e6d0..9e30161 100644 --- a/public/locales/en.json +++ b/public/locales/en.json @@ -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!" } \ No newline at end of file diff --git a/public/locales/es.json b/public/locales/es.json index 049e6d0..9e30161 100644 --- a/public/locales/es.json +++ b/public/locales/es.json @@ -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!" } \ No newline at end of file diff --git a/public/locales/fr.json b/public/locales/fr.json index 049e6d0..9e30161 100644 --- a/public/locales/fr.json +++ b/public/locales/fr.json @@ -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!" } \ No newline at end of file diff --git a/public/locales/id.json b/public/locales/id.json index 049e6d0..9e30161 100644 --- a/public/locales/id.json +++ b/public/locales/id.json @@ -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!" } \ No newline at end of file diff --git a/public/locales/ja.json b/public/locales/ja.json index faa9f3c..7b1a93e 100644 --- a/public/locales/ja.json +++ b/public/locales/ja.json @@ -31,5 +31,6 @@ "Skip": "スキップ", "SkipAndDontAsk": "スキップして二度と聞かない", "LauncherUpdateTitle": "ランチャーのアップデートが可能 ", - "LauncherUpdateBody": "ランチャーの新バージョンは、プロジェクトのリポジトリ(https://notabug.org/nobody/an-anime-game-launcher)からダウンロードできます。" + "LauncherUpdateBody": "ランチャーの新バージョンは、プロジェクトのリポジトリ({uri.launcher})からダウンロードできます。", + "TelemetryNotDisabled": "{placeholders.uppercase.company}のテレメトリサーバは無効になっていません!" } \ No newline at end of file diff --git a/public/locales/ko.json b/public/locales/ko.json index 049e6d0..9e30161 100644 --- a/public/locales/ko.json +++ b/public/locales/ko.json @@ -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!" } \ No newline at end of file diff --git a/public/locales/pt.json b/public/locales/pt.json index 049e6d0..9e30161 100644 --- a/public/locales/pt.json +++ b/public/locales/pt.json @@ -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!" } \ No newline at end of file diff --git a/public/locales/ru.json b/public/locales/ru.json index 5e4c319..eeb8cc6 100644 --- a/public/locales/ru.json +++ b/public/locales/ru.json @@ -31,5 +31,6 @@ "Skip": "Пропустить", "SkipAndDontAsk": "Пропустить и не спрашивать", "LauncherUpdateTitle": "Доступно обновление лаунчера: ", - "LauncherUpdateBody": "Вы можете скачать новую версию лаунчера с репозитория проекта: https://notabug.org/nobody/an-anime-game-launcher" + "LauncherUpdateBody": "Вы можете скачать новую версию лаунчера с репозитория проекта: {uri.launcher}", + "TelemetryNotDisabled": "Серверы сбора телеметрии {placeholders.uppercase.company} не отключены!" } \ No newline at end of file diff --git a/public/locales/th.json b/public/locales/th.json index 049e6d0..9e30161 100644 --- a/public/locales/th.json +++ b/public/locales/th.json @@ -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!" } \ No newline at end of file diff --git a/public/locales/vi.json b/public/locales/vi.json index 049e6d0..9e30161 100644 --- a/public/locales/vi.json +++ b/public/locales/vi.json @@ -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!" } \ No newline at end of file diff --git a/public/locales/zh-cn.json b/public/locales/zh-cn.json index 5bdfe6b..b417236 100644 --- a/public/locales/zh-cn.json +++ b/public/locales/zh-cn.json @@ -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!" } \ No newline at end of file diff --git a/public/locales/zh-tw.json b/public/locales/zh-tw.json index 2012a2c..efa87db 100644 --- a/public/locales/zh-tw.json +++ b/public/locales/zh-tw.json @@ -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!" } \ No newline at end of file diff --git a/src/ts/index.ts b/src/ts/index.ts index 4c5c273..ac9e463 100644 --- a/src/ts/index.ts +++ b/src/ts/index.ts @@ -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') }); } diff --git a/src/ts/lib/LauncherUI.ts b/src/ts/lib/LauncherUI.ts index b685f71..fc5fe82 100644 --- a/src/ts/lib/LauncherUI.ts +++ b/src/ts/lib/LauncherUI.ts @@ -28,6 +28,7 @@ export class LauncherUI { if (!this._i18n) this._i18n = i18n; + return this._i18n; } diff --git a/src/ts/lib/Tools.ts b/src/ts/lib/Tools.ts index 03747c5..60dae6f 100644 --- a/src/ts/lib/Tools.ts +++ b/src/ts/lib/Tools.ts @@ -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]); diff --git a/src/ts/lib/i18n.ts b/src/ts/lib/i18n.ts index d25caac..ca48a7f 100644 --- a/src/ts/lib/i18n.ts +++ b/src/ts/lib/i18n.ts @@ -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' + ))); + } }