mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2025-03-08 09:07:57 +03:00
Add I18N system
This commit is contained in:
parent
4b1a75ce33
commit
fe91ba3a94
4 changed files with 60 additions and 0 deletions
12
public/locales/de.json
Normal file
12
public/locales/de.json
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"Install": "Installieren",
|
||||
"Launch": "Starten",
|
||||
"Runners": "Runners",
|
||||
"Langs": "Sprachen",
|
||||
"Voice": "Sprachpaket",
|
||||
"SettingsTitle": "Einstellungen",
|
||||
"GeneralSettings": "Generell",
|
||||
"Downloading": "wird Heruntergeladen...",
|
||||
"GameDownloaded": "Spiel würde erfolgreich heruntergeladen",
|
||||
"ApplyPatch": "Patch wird angewendet"
|
||||
}
|
12
public/locales/en-us.json
Normal file
12
public/locales/en-us.json
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"Install": "Install",
|
||||
"Launch": "Launch",
|
||||
"Runners": "Runners",
|
||||
"Langs": "Languages",
|
||||
"Voice": "Voice Pack",
|
||||
"SettingsTitle": "Settings",
|
||||
"GeneralSettings": "General",
|
||||
"Downloading": "Downloading...",
|
||||
"GameDownloaded": "Game was successfully installed",
|
||||
"ApplyPatch": "Applying patch..."
|
||||
}
|
12
public/locales/en.json
Normal file
12
public/locales/en.json
Normal file
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
"Install": "Install",
|
||||
"Launch": "Launch",
|
||||
"Runners": "Runners",
|
||||
"Langs": "Languages",
|
||||
"Voice": "Voice Pack",
|
||||
"SettingsTitle": "Settings",
|
||||
"GeneralSettings": "General",
|
||||
"Downloading": "Downloading...",
|
||||
"GameDownloaded": "Game was successfully installed",
|
||||
"ApplyPatch": "Applying patch..."
|
||||
}
|
24
src/ts/i18n.ts
Normal file
24
src/ts/i18n.ts
Normal file
|
@ -0,0 +1,24 @@
|
|||
const path = require("path");
|
||||
const fs = require('fs');
|
||||
let loadedLanguage: any;
|
||||
|
||||
function i18n(): any {
|
||||
if(fs.existsSync(path.join(path.dirname(__dirname), 'locales', navigator.language.toLowerCase() + '.json'))) {
|
||||
loadedLanguage = JSON.parse(fs.readFileSync(path.join(path.dirname(__dirname), 'locales', navigator.language.toLowerCase() + '.json'), 'utf8'));
|
||||
}
|
||||
else {
|
||||
loadedLanguage = JSON.parse(fs.readFileSync(path.join(path.dirname(__dirname), 'locales', 'en.json'), 'utf8'));
|
||||
}
|
||||
};
|
||||
|
||||
i18n.prototype.translate = function(phrase: any) {
|
||||
let translation = loadedLanguage[phrase];
|
||||
|
||||
if(translation === undefined) {
|
||||
translation = phrase;
|
||||
}
|
||||
|
||||
return translation
|
||||
}
|
||||
|
||||
module.exports = i18n;
|
Loading…
Add table
Reference in a new issue