From 1695b51cf8c199a3636a7f994a0bcf2c04d3d4b6 Mon Sep 17 00:00:00 2001 From: Kamesuta Date: Sat, 5 Aug 2023 17:25:35 +0900 Subject: [PATCH 01/21] First step to use Language .json file in ejs --- app/assets/js/langloader.js | 4 ++++ app/assets/lang/en_US.json | 5 +++++ app/landing.ejs | 2 +- index.js | 6 ++++++ 4 files changed, 16 insertions(+), 1 deletion(-) diff --git a/app/assets/js/langloader.js b/app/assets/js/langloader.js index 24ab84ae..866c9da8 100644 --- a/app/assets/js/langloader.js +++ b/app/assets/js/langloader.js @@ -18,4 +18,8 @@ exports.query = function(id){ exports.queryJS = function(id){ return exports.query(`js.${id}`) +} + +exports.queryEJS = function(id){ + return exports.query(`ejs.${id}`) } \ No newline at end of file diff --git a/app/assets/lang/en_US.json b/app/assets/lang/en_US.json index 25b34c24..20e879ce 100644 --- a/app/assets/lang/en_US.json +++ b/app/assets/lang/en_US.json @@ -2,6 +2,11 @@ "html": { "avatarOverlay": "Edit" }, + "ejs": { + "landing": { + "news": "NEWS" + } + }, "js": { "login": { "error": { diff --git a/app/landing.ejs b/app/landing.ejs index 7e747818..b70e484b 100644 --- a/app/landing.ejs +++ b/app/landing.ejs @@ -133,7 +133,7 @@ - NEWS + <%- lang('landing.news') %> diff --git a/index.js b/index.js index 24397812..8f01ab7a 100644 --- a/index.js +++ b/index.js @@ -12,6 +12,10 @@ const semver = require('semver') const { pathToFileURL } = require('url') const { AZURE_CLIENT_ID, MSFT_OPCODE, MSFT_REPLY_TYPE, MSFT_ERROR, SHELL_OPCODE } = require('./app/assets/js/ipcconstants') +// Setup Lang +const LangLoader = require('./app/assets/js/langloader') +LangLoader.loadLanguage('en_US') + // Setup auto updater. function initAutoUpdater(event, data) { @@ -237,6 +241,8 @@ function createWindow() { remoteMain.enable(win.webContents) ejse.data('bkid', Math.floor((Math.random() * fs.readdirSync(path.join(__dirname, 'app', 'assets', 'images', 'backgrounds')).length))) + ejse.data('Lang', LangLoader) + ejse.data('lang', LangLoader.queryEJS) win.loadURL(pathToFileURL(path.join(__dirname, 'app', 'app.ejs')).toString()) From 08b472facf246383ee46e4e4abdfe48e95a4faf3 Mon Sep 17 00:00:00 2001 From: Kamesuta Date: Thu, 31 Aug 2023 00:11:20 +0900 Subject: [PATCH 02/21] i18n for landing.ejs --- app/assets/lang/en_US.json | 30 +++++++++++++++++++- app/landing.ejs | 58 +++++++++++++++++++------------------- 2 files changed, 58 insertions(+), 30 deletions(-) diff --git a/app/assets/lang/en_US.json b/app/assets/lang/en_US.json index 20e879ce..c6025f31 100644 --- a/app/assets/lang/en_US.json +++ b/app/assets/lang/en_US.json @@ -4,7 +4,35 @@ }, "ejs": { "landing": { - "news": "NEWS" + "updateAvailableTooltip": "Update Available", + "usernamePlaceholder": "Username", + "usernameEditButton": "Edit", + "settingsTooltip": "Settings", + "mediaGitHubURL": "https://github.com/dscalzi/HeliosLauncher", + "mediaTwitterURL": "#", + "mediaInstagramURL": "#", + "mediaYouTubeURL": "#", + "mediaDiscordURL": "https://discord.gg/zNWUXdt", + "serverStatus": "SERVER", + "serverStatusPlaceholder": "OFFLINE", + "mojangStatus": "MOJANG STATUS", + "mojangStatusIcon": "•", + "mojangStatusTooltipTitle": "Services", + "mojangStatusNETitle": "Non Essential", + "newsButton": "NEWS", + "launchButton": "PLAY", + "launchButtonPlaceholder": "• No Server Selected", + "launchProgressLabel": "0%", + "launchDetails": "Please wait..", + "newsArticleTitle": "Lorem Ipsum", + "newsArticleDate": "Mar 15, 44 BC, 9:14 AM", + "newsArticleAuthor": "by Cicero", + "newsArticleComments": "0 Comments", + "newsNavigationStatus": "1 of 1", + "newsErrorLoadSpan": "Checking for News..", + "newsErrorFailedSpan": "Failed to Load News", + "newsErrorRetryButton": "Try Again", + "newsErrorNoneSpan": "No News" } }, "js": { diff --git a/app/landing.ejs b/app/landing.ejs index b70e484b..16b98f9d 100644 --- a/app/landing.ejs +++ b/app/landing.ejs @@ -3,7 +3,7 @@
-
Update Available
+
<%- lang('landing.updateAvailableTooltip') %>
@@ -11,9 +11,9 @@