mirror of
https://github.com/an-anime-team/an-anime-game-launcher.git
synced 2024-12-19 08:21:47 +03:00
Some minor changes
This commit is contained in:
parent
2a6c3d5780
commit
98425483fa
5 changed files with 20 additions and 11 deletions
|
@ -35,6 +35,6 @@
|
|||
<img src="../images/gear.png">
|
||||
</div>
|
||||
|
||||
<button class="button" id="launch">Launch</button>
|
||||
<button class="button" id="launch" i18id="Launch">Launch</button>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -55,7 +55,7 @@ export class LauncherUI
|
|||
break;
|
||||
|
||||
case 'game-update-available':
|
||||
$('#launch').text('Update');
|
||||
$('#launch').text('Update'); // FIXME i18n.translate
|
||||
|
||||
break;
|
||||
|
||||
|
@ -155,4 +155,14 @@ export class LauncherUI
|
|||
{
|
||||
Genshinlib.getBackgroundUri().then(uri => $('body').css('background-image', `url(${uri})`));
|
||||
}
|
||||
|
||||
public static updateLang (lang: string|null = null): void
|
||||
{
|
||||
if (lang !== null)
|
||||
i18n.setLang(lang);
|
||||
|
||||
$('*[i18id]').each((i, element) => {
|
||||
element.innerText = i18n.translate(element.getAttribute('i18id')?.toString()!);
|
||||
});
|
||||
}
|
||||
}
|
|
@ -20,7 +20,7 @@ export class i18n
|
|||
// 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');
|
||||
|
||||
if (samecode.test(lang.toLowerCase()))
|
||||
if (samecode.test(lang))
|
||||
lang = lang.replace(/-.*$/, '');
|
||||
|
||||
switch (lang)
|
||||
|
|
|
@ -37,9 +37,7 @@ $(() => {
|
|||
|
||||
ipcRenderer.on('change-lang', (event: void, data: any) => {
|
||||
LauncherUI.updateBackground();
|
||||
LauncherUI.setState(LauncherUI.launcherState);
|
||||
|
||||
i18n.setLang(data.lang);
|
||||
LauncherUI.updateLang();
|
||||
});
|
||||
|
||||
let rpc: any;
|
||||
|
|
|
@ -6,6 +6,7 @@ const { exec } = require('child_process');
|
|||
import $ from 'cash-dom';
|
||||
import { i18n } from './i18n';
|
||||
import { Genshinlib } from './Genshinlib';
|
||||
import { LauncherUI } from './LauncherUI';
|
||||
|
||||
$(() => {
|
||||
|
||||
|
@ -37,13 +38,13 @@ $(() => {
|
|||
$('#drpc').on('change', () => ipcRenderer.send('rpcstate', {}));
|
||||
|
||||
$('#voice-list').on('change', (e) => {
|
||||
let activeVP = Genshinlib.getConfig().lang.voice;
|
||||
let activeVP = Genshinlib.lang.voice;
|
||||
|
||||
if (activeVP != e.target.value)
|
||||
{
|
||||
Genshinlib.updateConfig({
|
||||
lang: {
|
||||
launcher: Genshinlib.getConfig().lang.launcher,
|
||||
launcher: Genshinlib.lang.launcher,
|
||||
voice: e.target.value
|
||||
}
|
||||
});
|
||||
|
@ -79,12 +80,12 @@ $(() => {
|
|||
});
|
||||
|
||||
// Send language updates
|
||||
i18n.setLang(e.target.value);
|
||||
LauncherUI.updateLang(e.target.value);
|
||||
ipcRenderer.send('change-lang', { 'lang': e.target.value });
|
||||
|
||||
$('*[i18id]').each((i, element) => {
|
||||
/*$('*[i18id]').each((i, element) => {
|
||||
element.innerText = i18n.translate(element.getAttribute('i18id')?.toString()!);
|
||||
});
|
||||
});*/
|
||||
|
||||
$(`#language-list option[value="${activeLang}"]`).removeProp('selected');
|
||||
$(`#language-list option[value="${e.target.value}"]`).prop('selected', true);
|
||||
|
|
Loading…
Reference in a new issue