Skip to content

Commit

Permalink
fix: I fucked up the i18n
Browse files Browse the repository at this point in the history
  • Loading branch information
vgskye committed Feb 12, 2024
1 parent d0b6a63 commit bfa7a8c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions src/lib/i18n.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,23 +11,23 @@ getLocale().then(systemLocale => {

export function trans(id: string, data?: Record<string, string | number | undefined>) {
if (locale && langs[locale] && langs[locale][id]) {
const text = langs[locale][id];
let text = langs[locale][id];
for (const key in data) {
if (Object.prototype.hasOwnProperty.call(data, key)) {
const element = data[key];
if (element !== undefined)
text.replaceAll(`{{${key}}}`, element.toString())
text = text.replaceAll(`{{${key}}}`, element.toString())
}
}
return text
}
if (langs[defaultLocale] && langs[defaultLocale][id]) {
const text = langs[defaultLocale][id];
let text = langs[defaultLocale][id];
for (const key in data) {
if (Object.prototype.hasOwnProperty.call(data, key)) {
const element = data[key];
if (element !== undefined)
text.replaceAll(`{{${key}}}`, element.toString())
text = text.replaceAll(`{{${key}}}`, element.toString())
}
}
return text
Expand Down
14 changes: 7 additions & 7 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -24,34 +24,34 @@
if (payload[1] == 'start') {
switch (payload[0]) {
case 'clean_old':
installProgress = trans('clean_old');
installProgress = trans('progress.clean_old');
break;
case 'load_pack':
installProgress = trans('load_pack');
installProgress = trans('progress.load_pack');
currentStep = 1;
break;
case 'download_files':
installProgress = trans('download_files');
installProgress = trans('progress.download_files');
totalMods = payload[2] as number;
break;
case 'download_file':
installProgress = trans('download_file', {
installProgress = trans('progress.download_file', {
file: payload[3],
idx: (payload[2] as number) + 1,
total: totalMods
});
currentStep = (payload[2] as number) + 2;
break;
case 'extract_overrides':
installProgress = trans('extract_overrides');
installProgress = trans('progress.extract_overrides');
currentStep = totalMods + 2;
break;
case 'install_loader':
installProgress = trans('install_loader');
installProgress = trans('progress.install_loader');
currentStep = totalMods + 3;
break;
case 'add_profile':
installProgress = trans('add_profile');
installProgress = trans('progress.add_profile');
currentStep = totalMods + 4;
break;
}
Expand Down

0 comments on commit bfa7a8c

Please sign in to comment.