2022-04-23 04:57:02 +00:00
|
|
|
async function doTranslation() {
|
|
|
|
const config = await getCfg()
|
|
|
|
|
|
|
|
// See if the localization file exists
|
|
|
|
const localizations = await filesystem.readDirectory(`${NL_CWD}/languages`)
|
|
|
|
|
|
|
|
// Use english if the selected file does not exist
|
|
|
|
const selectedLanguage = localizations.find(f => f.entry === `${config.language}.json`)
|
|
|
|
|
|
|
|
// Use english if the selected file does not exist
|
|
|
|
if (!selectedLanguage) {
|
|
|
|
config.language = 'en'
|
|
|
|
}
|
|
|
|
|
|
|
|
const localization = await filesystem.readFile(`${NL_CWD}/languages/${config.language}.json`)
|
2022-04-24 07:32:17 +00:00
|
|
|
const engLocale = await filesystem.readFile(`${NL_CWD}/languages/en.json`)
|
2022-04-24 23:36:15 +00:00
|
|
|
engLocaleObj = JSON.parse(engLocale)
|
2022-04-23 04:57:02 +00:00
|
|
|
localeObj = JSON.parse(localization)
|
|
|
|
|
2022-04-27 21:28:58 +00:00
|
|
|
const set = (id, localeString) => document.getElementById(id).innerText = localeObj[localeString] || engLocaleObj[localeString]
|
2022-04-23 04:57:02 +00:00
|
|
|
|
|
|
|
// Begin filling in values
|
2022-04-25 05:40:03 +00:00
|
|
|
set('titleSection', 'appName')
|
2022-04-23 04:57:02 +00:00
|
|
|
|
2022-04-23 06:10:25 +00:00
|
|
|
const verSpan = document.createElement('span')
|
|
|
|
verSpan.id = 'version'
|
|
|
|
verSpan.innerHTML = ` v${NL_APPVERSION}`
|
|
|
|
|
|
|
|
document.querySelector('#titleSection').appendChild(verSpan)
|
|
|
|
|
2022-04-23 04:57:02 +00:00
|
|
|
// Play buttons
|
2022-04-24 23:36:15 +00:00
|
|
|
set('playOfficial', 'playOfficial')
|
|
|
|
set('playPrivate', 'playPrivate')
|
|
|
|
set('serverLaunch', 'launchLocalServer')
|
2022-04-23 04:57:02 +00:00
|
|
|
|
|
|
|
// File select buttons
|
2022-04-26 05:22:54 +00:00
|
|
|
set('gameExeSet', 'gameExeSet')
|
2022-04-24 23:36:15 +00:00
|
|
|
set('grasscutterFileSet', 'grasscutterFileSet')
|
2022-04-23 04:57:02 +00:00
|
|
|
|
|
|
|
// Private options
|
2022-04-23 06:48:15 +00:00
|
|
|
document.querySelector('#ip').placeholder = localeObj.ipPlaceholder
|
2022-04-24 07:32:17 +00:00
|
|
|
document.querySelector('#port').placeholder = localeObj.portPlaceholder
|
2022-04-23 04:57:02 +00:00
|
|
|
|
|
|
|
// Settings
|
2022-04-24 23:36:15 +00:00
|
|
|
set('fullSettingsTitle', 'settingsTitle')
|
|
|
|
set('scriptsTitle', 'scriptsSectionTitle')
|
|
|
|
set('killswitchTitle', 'killswitchOption')
|
|
|
|
set('killswitchSubtitle', 'killswitchSubtitle')
|
|
|
|
set('proxyTitle', 'proxyOption')
|
|
|
|
set('proxyInstall', 'proxyInstallBtn')
|
|
|
|
set('proxySubtitle', 'proxySubtitle')
|
|
|
|
set('updateBtn', 'updateOption')
|
|
|
|
set('updateTitle', 'updateOption')
|
|
|
|
set('updateSubtitle', 'updateSubtitle')
|
|
|
|
set('languageTitle', 'languageOption')
|
|
|
|
set('languageSubtitle', 'languageSubtitle')
|
|
|
|
set('serverLaunchTitle', 'enableServerLauncherOption')
|
|
|
|
set('serverSubtitle', 'enableServerLauncherSubtitle')
|
2022-04-25 03:01:52 +00:00
|
|
|
set('httpsTitle', 'httpsOption')
|
2022-04-24 23:36:15 +00:00
|
|
|
set('httpsSubtitle', 'httpsSubtitle')
|
2022-04-23 04:57:02 +00:00
|
|
|
|
|
|
|
// Intro popup
|
|
|
|
const popup = document.getElementById('firstTimeNotice')
|
|
|
|
const introSpan = popup.querySelector('span')
|
|
|
|
const boldIntroSpan = document.createElement('span')
|
|
|
|
|
|
|
|
boldIntroSpan.innerHTML = localeObj.introSen1 + '\n'
|
|
|
|
boldIntroSpan.classList.add('boldTitle')
|
|
|
|
|
|
|
|
introSpan.appendChild(boldIntroSpan)
|
|
|
|
|
|
|
|
introSpan.innerHTML += localeObj.introSen2 + '<br>'
|
|
|
|
introSpan.innerHTML += localeObj.introSen3 + '<br>'
|
|
|
|
introSpan.innerHTML += localeObj.introSen4 + '<br>'
|
|
|
|
|
2022-04-24 23:36:15 +00:00
|
|
|
set('firstTimeInstallBtn', 'proxyInstallBtn')
|
|
|
|
set('firstTimeDenyBtn', 'proxyInstallDeny')
|
2022-04-27 21:28:58 +00:00
|
|
|
|
|
|
|
// Login section
|
|
|
|
set('loginSectionTitle', 'authLoginTitle')
|
|
|
|
set('registerSectionTitle', 'authRegisterTitle')
|
|
|
|
set('loggingInToIndicator', 'loggingInTo')
|
|
|
|
set('registeringToIndicator', 'registeringFor')
|
|
|
|
set('loginUsernameIndicator', 'authUsername')
|
|
|
|
set('loginPasswordIndicator', 'authPassword')
|
|
|
|
set('registerUsernameIndicator', 'authUsername')
|
|
|
|
set('registerPasswordIndicator', 'authPassword')
|
|
|
|
set('registerConfirmIndicator', 'authConfirmPassword')
|
|
|
|
set('loginPopupContentBodyBtnLogin', 'authLoginBtn')
|
|
|
|
set('loginPopupContentBodyBtnRegister', 'authRegisterBtn')
|
|
|
|
set('noLoginBtn', 'launchWithoutAuth')
|
2022-04-30 08:58:58 +00:00
|
|
|
|
|
|
|
// update notification
|
|
|
|
set('updateNotifText', 'updateNotifText')
|
2022-04-23 04:57:02 +00:00
|
|
|
}
|