Add localization support (#333)

* Add updated i18n config and en locale
This commit is contained in:
Jeff 2023-10-30 19:22:45 -07:00 committed by GitHub
parent 11863fd4c1
commit 8430b1ec95
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
90 changed files with 2679 additions and 908 deletions

View file

@ -5,8 +5,10 @@ import {
SettingsSection,
} from '/@/renderer/features/settings/components/settings-section';
import { useDiscordSetttings, useSettingsStoreActions } from '/@/renderer/store';
import { useTranslation } from 'react-i18next';
export const DiscordSettings = () => {
const { t } = useTranslation();
const settings = useDiscordSetttings();
const { setSettings } = useSettingsStoreActions();
@ -25,10 +27,19 @@ export const DiscordSettings = () => {
}}
/>
),
description:
'Enable playback status in Discord rich presence. Image keys include: "icon", "playing", and "paused"',
description: t('setting.discordRichPresence', {
context: 'description',
discord: 'Discord',
icon: 'icon',
paused: 'paused',
playing: 'playing',
postProcess: 'sentenceCase',
}),
isHidden: !isElectron(),
title: 'Discord rich presence',
title: t('setting.discordRichPresence', {
discord: 'Discord',
postProcess: 'sentenceCase',
}),
},
{
control: (
@ -44,9 +55,17 @@ export const DiscordSettings = () => {
}}
/>
),
description: 'The Discord application ID (defaults to 1165957668758900787)',
description: t('setting.discordApplicationId', {
context: 'description',
defaultId: '1165957668758900787',
discord: 'Discord',
postProcess: 'sentenceCase',
}),
isHidden: !isElectron(),
title: 'Discord application ID',
title: t('setting.discordApplicationId', {
discord: 'Discord',
postProcess: 'sentenceCase',
}),
},
{
control: (
@ -67,9 +86,15 @@ export const DiscordSettings = () => {
}}
/>
),
description: 'The time in seconds between each update (minimum 15 seconds)',
description: t('setting.discordUpdateInterval', {
context: 'description',
postProcess: 'sentenceCase',
}),
isHidden: !isElectron(),
title: 'Rich presence update interval (seconds)',
title: t('setting.discordUpdateInterval', {
discord: 'Discord',
postProcess: 'sentenceCase',
}),
},
{
control: (
@ -85,9 +110,14 @@ export const DiscordSettings = () => {
}}
/>
),
description: 'When enabled, the rich presence will update while player is idle',
description: t('setting.discordIdleStatus', {
context: 'description',
postProcess: 'sentenceCase',
}),
isHidden: !isElectron(),
title: 'Show rich presence when idle',
title: t('setting.discordIdleStatus', {
postProcess: 'sentenceCase',
}),
},
];

View file

@ -1,4 +1,5 @@
import isElectron from 'is-electron';
import { useTranslation } from 'react-i18next';
import { useWindowSettings, useSettingsStoreActions } from '../../../../store/settings.store';
import {
SettingsSection,
@ -9,6 +10,7 @@ import { Switch } from '/@/renderer/components';
const localSettings = isElectron() ? window.electron.localSettings : null;
export const UpdateSettings = () => {
const { t } = useTranslation();
const settings = useWindowSettings();
const { setSettings } = useSettingsStoreActions();
@ -31,9 +33,12 @@ export const UpdateSettings = () => {
}}
/>
),
description: 'Enabling this option will disable checking for new versions on startup',
description: t('setting.disableAutomaticUpdates', {
context: 'description',
postProcess: 'sentenceCase',
}),
isHidden: !isElectron(),
title: 'Disable automatic updates',
title: t('setting.disableAutomaticUpdates', { postProcess: 'sentenceCase' }),
},
];

View file

@ -1,5 +1,6 @@
import isElectron from 'is-electron';
import { Platform } from '/@/renderer/types';
import { useTranslation } from 'react-i18next';
import { useWindowSettings, useSettingsStoreActions } from '../../../../store/settings.store';
import {
SettingsSection,
@ -17,6 +18,7 @@ const WINDOW_BAR_OPTIONS = [
const localSettings = isElectron() ? window.electron.localSettings : null;
export const WindowSettings = () => {
const { t } = useTranslation();
const settings = useWindowSettings();
const { setSettings } = useSettingsStoreActions();
@ -43,12 +45,15 @@ export const WindowSettings = () => {
toast.info({
autoClose: false,
id: 'restart-toast',
message:
'Restart to apply changes... close the notification to restart Feishin',
message: t('common.forceRestartRequired', {
postProcess: 'sentenceCase',
}),
onClose: () => {
window.electron.ipc!.send('app-restart');
},
title: 'Restart required',
title: t('common.restartRequired', {
postProcess: 'sentenceCase',
}),
});
} else {
toast.update({
@ -69,9 +74,12 @@ export const WindowSettings = () => {
}}
/>
),
description: 'Adjust the style of the application window bar',
description: t('setting.windowBarStyle', {
context: 'description',
postProcess: 'sentenceCase',
}),
isHidden: !isElectron(),
title: 'Window bar style',
title: t('setting.windowBarStyle', { postProcess: 'sentenceCase' }),
},
{
control: (
@ -91,9 +99,12 @@ export const WindowSettings = () => {
}}
/>
),
description: 'Minimize the application to the system tray',
description: t('setting.minimizeToTray', {
context: 'description',
postProcess: 'sentenceCase',
}),
isHidden: !isElectron(),
title: 'Minimize to tray',
title: t('setting.minimizeToTray', { postProcess: 'sentenceCase' }),
},
{
control: (
@ -113,9 +124,12 @@ export const WindowSettings = () => {
}}
/>
),
description: 'Exit the application to the system tray',
description: t('setting.exitToTray', {
context: 'description',
postProcess: 'sentenceCase',
}),
isHidden: !isElectron(),
title: 'Exit to tray',
title: t('setting.exitToTray', { postProcess: 'sentenceCase' }),
},
];