From 7775526372d1739a8f7af0ddb13fab13a8402347 Mon Sep 17 00:00:00 2001 From: Observer KRypt0n_ Date: Fri, 28 Jan 2022 22:30:28 +0200 Subject: [PATCH] Several changes - updated readme - added localiztions for notifications - fixed possible errors in `Locales.bind()` method - added `Locales.translate()` method to translate something --- README.md | 15 +++++------- public/locales/de-de.yaml | 34 +++++++++++++++++++++++----- public/locales/en-us.yaml | 34 +++++++++++++++++++++++----- public/locales/es-es.yaml | 34 +++++++++++++++++++++++----- public/locales/fr-fr.yaml | 34 +++++++++++++++++++++++----- public/locales/id-id.yaml | 32 ++++++++++++++++++++++---- public/locales/it-it.yaml | 34 +++++++++++++++++++++++----- public/locales/ru-ru.yaml | 34 +++++++++++++++++++++++----- public/locales/uwu.yaml | 34 +++++++++++++++++++++++----- src/ts/launcher/Locales.ts | 28 ++++++++++++++++++++++- src/ts/launcher/State.ts | 8 ++----- src/ts/launcher/states/ApplyPatch.ts | 10 ++++---- src/ts/launcher/states/Launch.ts | 4 ++-- 13 files changed, 264 insertions(+), 71 deletions(-) diff --git a/README.md b/README.md index d2fe37a..7ea8b30 100644 --- a/README.md +++ b/README.md @@ -62,31 +62,26 @@ To work this launcher requires | curl | To download archives with game, voice data, runners and so on | | xdelta3 | To apply the patch to the game | | cabextract | To install fonts to the wine prefix | -| notify-send | To send system notifications | +| libnotify | To send system notifications | ## Install ### apt-get ```sh -sudo apt-get install unzip tar git curl xdelta3 cabextract notify-send +sudo apt-get install unzip tar git curl xdelta3 cabextract libnotify ``` ### pacman ```sh -sudo pacman -Syu unzip tar git curl xdelta3 cabextract notify-send +sudo pacman -Syu unzip tar git curl xdelta3 cabextract libnotify ``` ### dnf ```sh -sudo dnf install unzip tar git curl xdelta cabextract notify-send -``` - -### dnf -```sh -sudo dnf install unzip tar git xdelta cabextract +sudo dnf install unzip tar git curl xdelta cabextract libnotify ``` # Additional requirements @@ -142,7 +137,9 @@ This is our current roadmap goals. You can find older ones [here](repository/pag * Use `LauncherLib.getGameVersion` function instead of the `config.json`'s `version` property *(deprecated due to the new core functions)* * Fix button flickering at start when the launcher's state updates *(fixed due to the new framework usage and proper state updating)* * Add downloading pause button *(2.0.0 release)* +* Move launcher on [Empathize](https://github.com/empathizejs/framework) * Make notifications translations +* Add analytics window * Dark progress bar design * Statistics window * Changelog window diff --git a/public/locales/de-de.yaml b/public/locales/de-de.yaml index 2af917b..e304684 100644 --- a/public/locales/de-de.yaml +++ b/public/locales/de-de.yaml @@ -62,11 +62,6 @@ launcher: launch: Starten predownload: Update vorinstallieren - # Launcher update - update: - title: 'Launcher update verfügbar: {from} -> {to}' - body: Sie können das update von {repository} herunterladen - # Einstellungs Fenster settings: # General @@ -228,4 +223,31 @@ settings: # Table buttons buttons: add: Hinzufügen - delete: Löschen \ No newline at end of file + delete: Löschen + +# Notifications +notifications: + # Launcher update + launcher_update_available: + title: 'Launcher update verfügbar: {from} -> {to}' + body: Sie können das update von {repository} herunterladen + + # When telemetry servers are not disabled + telemetry_not_disabled: + title: An Anime Game Launcher + body: Telemetry servers are not disabled + + # Before patch applying when xdelta3 package is not downloaded + xdelta3_package_required: + title: An Anime Game Launcher + body: You must download xdelta3 package to apply the patch + + # If patch wasn't applied because of some error + patch_applying_error: + title: An Anime Game Launcher + body: Patch wasn't applied successfully. Please, check your log file to find a reason of it, or ask someone in our discord server + + # Patch repositories are not available + patch_repos_unavailable: + title: An Anime Game Launcher + body: All the patch repositories are not available. You'll be able to run the game, but launcher can't be sure is it patched properly \ No newline at end of file diff --git a/public/locales/en-us.yaml b/public/locales/en-us.yaml index 8c67638..b46faf9 100644 --- a/public/locales/en-us.yaml +++ b/public/locales/en-us.yaml @@ -62,11 +62,6 @@ launcher: launch: Launch predownload: Pre-download update - # Launcher update - update: - title: 'Launcher update available: {from} -> {to}' - body: You can download a new version of the launcher from the project's repository at {repository} - # Settings window settings: # General @@ -227,4 +222,31 @@ settings: # Table buttons buttons: add: Add - delete: Delete \ No newline at end of file + delete: Delete + +# Notifications +notifications: + # Launcher update + launcher_update_available: + title: 'Launcher update available: {from} -> {to}' + body: You can download a new version of the launcher from the project's repository at {repository} + + # When telemetry servers are not disabled + telemetry_not_disabled: + title: An Anime Game Launcher + body: Telemetry servers are not disabled + + # Before patch applying when xdelta3 package is not downloaded + xdelta3_package_required: + title: An Anime Game Launcher + body: You must download xdelta3 package to apply the patch + + # If patch wasn't applied because of some error + patch_applying_error: + title: An Anime Game Launcher + body: Patch wasn't applied successfully. Please, check your log file to find a reason of it, or ask someone in our discord server + + # Patch repositories are not available + patch_repos_unavailable: + title: An Anime Game Launcher + body: All the patch repositories are not available. You'll be able to run the game, but launcher can't be sure is it patched properly \ No newline at end of file diff --git a/public/locales/es-es.yaml b/public/locales/es-es.yaml index 24d3183..9e7701f 100644 --- a/public/locales/es-es.yaml +++ b/public/locales/es-es.yaml @@ -62,11 +62,6 @@ launcher: launch: Jugar predownload: Pre-descargar actualización - # Actualización del Launcher - update: - title: 'Actualización del launcher disponible: {from} -> {to}' - body: Puedes descargar una nueva versión del launcher desde el repositorio del proyecto en {repository} - # Ventana de opciones settings: # General @@ -226,4 +221,31 @@ settings: # Botones de la tabla buttons: add: Añadir - delete: Borrar \ No newline at end of file + delete: Borrar + +# Notifications +notifications: + # Actualización del Launcher + launcher_update_available: + title: 'Actualización del launcher disponible: {from} -> {to}' + body: Puedes descargar una nueva versión del launcher desde el repositorio del proyecto en {repository} + + # When telemetry servers are not disabled + telemetry_not_disabled: + title: An Anime Game Launcher + body: Telemetry servers are not disabled + + # Before patch applying when xdelta3 package is not downloaded + xdelta3_package_required: + title: An Anime Game Launcher + body: You must download xdelta3 package to apply the patch + + # If patch wasn't applied because of some error + patch_applying_error: + title: An Anime Game Launcher + body: Patch wasn't applied successfully. Please, check your log file to find a reason of it, or ask someone in our discord server + + # Patch repositories are not available + patch_repos_unavailable: + title: An Anime Game Launcher + body: All the patch repositories are not available. You'll be able to run the game, but launcher can't be sure is it patched properly \ No newline at end of file diff --git a/public/locales/fr-fr.yaml b/public/locales/fr-fr.yaml index 7c999bc..f73acce 100644 --- a/public/locales/fr-fr.yaml +++ b/public/locales/fr-fr.yaml @@ -63,11 +63,6 @@ launcher: launch: Lancer predownload: Pre-téléchargement de mise à jour - # Launcher update - update: - title: 'Mise à jour du Launcher disponible: {from} -> {to}' - body: Vous pouvez télécharger la nouvelle version du launcher via le dépôt ici {repository} - # Settings window settings: # General @@ -233,4 +228,31 @@ settings: # Table buttons buttons: add: Ajouter - delete: Supprimer \ No newline at end of file + delete: Supprimer + +# Notifications +notifications: + # Launcher update + launcher_update_available: + title: 'Mise à jour du Launcher disponible: {from} -> {to}' + body: Vous pouvez télécharger la nouvelle version du launcher via le dépôt ici {repository} + + # When telemetry servers are not disabled + telemetry_not_disabled: + title: An Anime Game Launcher + body: Telemetry servers are not disabled + + # Before patch applying when xdelta3 package is not downloaded + xdelta3_package_required: + title: An Anime Game Launcher + body: You must download xdelta3 package to apply the patch + + # If patch wasn't applied because of some error + patch_applying_error: + title: An Anime Game Launcher + body: Patch wasn't applied successfully. Please, check your log file to find a reason of it, or ask someone in our discord server + + # Patch repositories are not available + patch_repos_unavailable: + title: An Anime Game Launcher + body: All the patch repositories are not available. You'll be able to run the game, but launcher can't be sure is it patched properly \ No newline at end of file diff --git a/public/locales/id-id.yaml b/public/locales/id-id.yaml index bd65963..f4756fb 100644 --- a/public/locales/id-id.yaml +++ b/public/locales/id-id.yaml @@ -62,11 +62,6 @@ launcher: launch: Luncurkan predownload: Pembaruan pra-unduh - # Launcher update - update: - title: 'Pembaruan peluncur tersedia: {from} -> {to}' - body: Kamu dapat mengunduh versi baru peluncur dari repositori proyek di {repository} - # Settings window settings: # General @@ -227,3 +222,30 @@ settings: buttons: add: Tambah delete: Hapus + +# Notifications +notifications: + # Launcher update + launcher_update_available: + title: 'Pembaruan peluncur tersedia: {from} -> {to}' + body: Kamu dapat mengunduh versi baru peluncur dari repositori proyek di {repository} + + # When telemetry servers are not disabled + telemetry_not_disabled: + title: An Anime Game Launcher + body: Telemetry servers are not disabled + + # Before patch applying when xdelta3 package is not downloaded + xdelta3_package_required: + title: An Anime Game Launcher + body: You must download xdelta3 package to apply the patch + + # If patch wasn't applied because of some error + patch_applying_error: + title: An Anime Game Launcher + body: Patch wasn't applied successfully. Please, check your log file to find a reason of it, or ask someone in our discord server + + # Patch repositories are not available + patch_repos_unavailable: + title: An Anime Game Launcher + body: All the patch repositories are not available. You'll be able to run the game, but launcher can't be sure is it patched properly \ No newline at end of file diff --git a/public/locales/it-it.yaml b/public/locales/it-it.yaml index 8737694..53f2d3e 100644 --- a/public/locales/it-it.yaml +++ b/public/locales/it-it.yaml @@ -62,11 +62,6 @@ launcher: launch: Launch predownload: Pre-download update - # Launcher update - update: - title: 'Aggiornamento del launcher disponibile: {from} -> {to}' - body: Puoi scaricare una nuova versione del launcher dalla repository del progetto {repository} - # Settings window settings: # General @@ -225,4 +220,31 @@ settings: # Table buttons buttons: add: Add - delete: Delete \ No newline at end of file + delete: Delete + +# Notifications +notifications: + # Launcher update + launcher_update_available: + title: 'Aggiornamento del launcher disponibile: {from} -> {to}' + body: Puoi scaricare una nuova versione del launcher dalla repository del progetto {repository} + + # When telemetry servers are not disabled + telemetry_not_disabled: + title: An Anime Game Launcher + body: Telemetry servers are not disabled + + # Before patch applying when xdelta3 package is not downloaded + xdelta3_package_required: + title: An Anime Game Launcher + body: You must download xdelta3 package to apply the patch + + # If patch wasn't applied because of some error + patch_applying_error: + title: An Anime Game Launcher + body: Patch wasn't applied successfully. Please, check your log file to find a reason of it, or ask someone in our discord server + + # Patch repositories are not available + patch_repos_unavailable: + title: An Anime Game Launcher + body: All the patch repositories are not available. You'll be able to run the game, but launcher can't be sure is it patched properly \ No newline at end of file diff --git a/public/locales/ru-ru.yaml b/public/locales/ru-ru.yaml index 2c36203..90bd6f8 100644 --- a/public/locales/ru-ru.yaml +++ b/public/locales/ru-ru.yaml @@ -62,11 +62,6 @@ launcher: launch: Запустить predownload: Предзагрузить обновление - # Обновление лаунчера - update: - title: 'Доступно обновление лаунчера: {from} -> {to}' - body: Вы можете загрузить новую версию лаунчера из репозитория проекта по ссылке {repository} - # Окно настроек settings: # Основное @@ -226,4 +221,31 @@ settings: # Кнопки таблицы buttons: add: Добавить - delete: Удалить \ No newline at end of file + delete: Удалить + +# Уведомления +notifications: + # Обновление лаунчера + launcher_update_available: + title: 'Доступно обновление лаунчера: {from} -> {to}' + body: Вы можете загрузить новую версию лаунчера из репозитория проекта по ссылке {repository} + + # Когда сервера телеметрии не отключены + telemetry_not_disabled: + title: An Anime Game Launcher + body: Серверы телеметрии не отключены + + # Перед применением патча когда пакет xdelta3 не установлен + xdelta3_package_required: + title: An Anime Game Launcher + body: Вы обязаны установить пакет xdelta3 перед применением патча + + # Если патч не был применён по какой-то причине + patch_applying_error: + title: An Anime Game Launcher + body: Патч не был применён. Пожалуйста, проверьте ваш файл журнала отладки чтобы найти причину ошибки, или спросите кого-то в нашем дискорд сервере + + # Репозитории патча недоступны + patch_repos_unavailable: + title: An Anime Game Launcher + body: Все репозитории патча недоступны. Вы сможете запустить игру, однако лаунчер не может знать пропатчена ли она корректно \ No newline at end of file diff --git a/public/locales/uwu.yaml b/public/locales/uwu.yaml index 34bb74e..cd9a98d 100644 --- a/public/locales/uwu.yaml +++ b/public/locales/uwu.yaml @@ -62,11 +62,6 @@ launcher: launch: launch (◕▿◕✿) predownload: pwe-downwoad update - # Launcher update - update: - title: 'waunchew update avaiwable: {from} -> {to}' - body: you can downwoad the new vewsion of the waunchew fwom the pwoject's wepositowy at {repository} - # Settings window settings: # General @@ -226,4 +221,31 @@ settings: # Table buttons buttons: add: add - delete: dewete \ No newline at end of file + delete: dewete + +# Notifications +notifications: + # Launcher update + launcher_update_available: + title: 'waunchew update avaiwable: {from} -> {to}' + body: you can downwoad the new vewsion of the waunchew fwom the pwoject's wepositowy at {repository} + + # When telemetry servers are not disabled + telemetry_not_disabled: + title: An Anime Game Launcher + body: Telemetry servers are not disabled + + # Before patch applying when xdelta3 package is not downloaded + xdelta3_package_required: + title: An Anime Game Launcher + body: You must download xdelta3 package to apply the patch + + # If patch wasn't applied because of some error + patch_applying_error: + title: An Anime Game Launcher + body: Patch wasn't applied successfully. Please, check your log file to find a reason of it, or ask someone in our discord server + + # Patch repositories are not available + patch_repos_unavailable: + title: An Anime Game Launcher + body: All the patch repositories are not available. You'll be able to run the game, but launcher can't be sure is it patched properly \ No newline at end of file diff --git a/src/ts/launcher/Locales.ts b/src/ts/launcher/Locales.ts index e1674ad..fc6bb04 100644 --- a/src/ts/launcher/Locales.ts +++ b/src/ts/launcher/Locales.ts @@ -1,3 +1,4 @@ +import { get as svelteget } from 'svelte/store'; import { dictionary, locale } from 'svelte-i18n'; import YAML from 'yaml'; @@ -98,7 +99,12 @@ export default class Locales let message = currentDictionary[currentLocale] ?? currentDictionary['en-us']; for (const path of localeName.split('.')) - message = message[path]; + { + message = message[path] ?? null; + + if (message === null) + break; + } localizer(message); }; @@ -118,6 +124,26 @@ export default class Locales }); } + /** + * Get translation from the currently selected locale + */ + public static translate(message: string): string|object|null + { + const currentDictionary = svelteget(dictionary) as object; + + let translation = currentDictionary[svelteget(locale) ?? 'en-us'] ?? currentDictionary['en-us']; + + for (const path of message.split('.')) + { + translation = translation[path] ?? null; + + if (translation === null) + break; + } + + return translation; + } + /** * Checks if the specified language supported * by the game's API diff --git a/src/ts/launcher/State.ts b/src/ts/launcher/State.ts index db83153..0f16a81 100644 --- a/src/ts/launcher/State.ts +++ b/src/ts/launcher/State.ts @@ -103,10 +103,7 @@ export default class State for (const tag of tags.reverse()) if (semver.gt(tag.tag, Launcher.version)) { - const currentDictionary = svelteget(dictionary); - const currentLocale = svelteget(locale); - - const locales = (currentDictionary[currentLocale ?? 'en-us'] ?? currentDictionary['en-us'])['launcher']!['update'] as object; + const locales = Locales.translate('notifications.launcher_update_available') as object; Notification.show({ title: locales['title'].replace('{from}', Launcher.version).replace('{to}', tag.tag), @@ -399,8 +396,7 @@ export default class State state = 'game-launch-available'; Notification.show({ - title: 'An Anime Game Launcher', - body: 'All the patch repositories are not available. You\'ll be able to run the game, but launcher can\'t be sure is it patched properly', + ...(Locales.translate('notifications.patch_repos_unavailable') as { title: string, body: string }), icon: `${constants.paths.appDir}/public/images/baal64-transparent.png`, importance: 'critical' }); diff --git a/src/ts/launcher/states/ApplyPatch.ts b/src/ts/launcher/states/ApplyPatch.ts index 80f7d19..04aaee8 100644 --- a/src/ts/launcher/states/ApplyPatch.ts +++ b/src/ts/launcher/states/ApplyPatch.ts @@ -3,6 +3,7 @@ import { Notification } from '../../../empathize'; import Launcher from '../../Launcher'; import Patch from '../../Patch'; import constants from '../../Constants'; +import Locales from '../Locales'; export default (launcher: Launcher): Promise => { return new Promise(async (resolve) => { @@ -10,8 +11,7 @@ export default (launcher: Launcher): Promise => { if (!await Launcher.isPackageAvailable('xdelta3')) { Notification.show({ - title: 'An Anime Game Launcher', - body: 'You must download xdelta3 package to apply the patch', + ...(Locales.translate('notifications.xdelta3_package_required') as { title: string, body: string }), icon: `${constants.paths.appDir}/public/images/baal64-transparent.png`, importance: 'critical' }); @@ -78,8 +78,7 @@ export default (launcher: Launcher): Promise => { if (!result) { Notification.show({ - title: 'An Anime Game Launcher', - body: 'Patch wasn\'t applied successfully. Please, check your log file to find a reason of it, or ask someone in our discord server', + ...(Locales.translate('notifications.patch_applying_error') as { title: string, body: string }), icon: `${constants.paths.appDir}/public/images/baal64-transparent.png` }); } @@ -91,8 +90,7 @@ export default (launcher: Launcher): Promise => { } }).catch(() => { Notification.show({ - title: 'An Anime Game Launcher', - body: 'All the patch repositories are not available. You\'ll be able to run the game, but launcher can\'t be sure is it patched properly', + ...(Locales.translate('notifications.patch_repos_unavailable') as { title: string, body: string }), icon: `${constants.paths.appDir}/public/images/baal64-transparent.png`, importance: 'critical' }); diff --git a/src/ts/launcher/states/Launch.ts b/src/ts/launcher/states/Launch.ts index 965e910..0dc8195 100644 --- a/src/ts/launcher/states/Launch.ts +++ b/src/ts/launcher/states/Launch.ts @@ -5,6 +5,7 @@ import Launcher from '../../Launcher'; import constants from '../../Constants'; import Runners from '../../core/Runners'; import Game from '../../Game'; +import Locales from '../Locales'; declare const Neutralino; @@ -18,8 +19,7 @@ export default (launcher: Launcher): Promise => { if (!telemetry) { Notification.show({ - title: 'An Anime Game Launcher', - body: 'Telemetry servers are not disabled', + ...(Locales.translate('notifications.telemetry_not_disabled') as { title: string, body: string }), icon: `${constants.paths.appDir}/public/images/baal64-transparent.png`, importance: 'critical' });