feat: add support i18n (#1468)

This commit is contained in:
JellyBrick
2023-12-01 01:30:46 +09:00
committed by GitHub
parent 7f71c36dc0
commit 7401cf69ad
65 changed files with 1226 additions and 303 deletions

View File

@ -2,6 +2,7 @@ import prompt from 'custom-electron-prompt';
import promptOptions from '@/providers/prompt-options';
import { createBackend } from '@/utils';
import { t } from '@/i18n';
export default createBackend({
start({ ipc: { handle }, window }) {
@ -10,8 +11,10 @@ export default createBackend({
async (captionLabels: Record<string, string>, currentIndex: string) =>
await prompt(
{
title: 'Choose Caption',
label: `Current Caption: ${captionLabels[currentIndex] || 'None'}`,
title: t('plugins.captions-selector.prompt.selector.title'),
label: t('plugins.captions-selector.prompt.selector.label', {
language: captionLabels[currentIndex] || t('plugins.captions-selector.prompt.selector.none'),
}),
type: 'select',
value: currentIndex,
selectOptions: captionLabels,

View File

@ -3,6 +3,7 @@ import { YoutubePlayer } from '@/types/youtube-player';
import backend from './back';
import renderer, { CaptionsSelectorConfig, LanguageOptions } from './renderer';
import { t } from '@/i18n';
export default createPlugin<
unknown,
@ -18,8 +19,8 @@ export default createPlugin<
},
CaptionsSelectorConfig
>({
name: 'Captions Selector',
description: 'Caption selector for YouTube Music audio tracks',
name: t('plugins.captions-selector.name'),
description: t('plugins.captions-selector.description'),
config: {
enabled: false,
disableCaptions: false,
@ -31,7 +32,7 @@ export default createPlugin<
const config = await getConfig();
return [
{
label: 'Automatically select last used caption',
label: t('plugins.captions-selector.menu.autoload'),
type: 'checkbox',
checked: config.autoload as boolean,
click(item) {
@ -39,7 +40,7 @@ export default createPlugin<
},
},
{
label: 'No captions by default',
label: t('plugins.captions-selector.menu.disable-captions'),
type: 'checkbox',
checked: config.disableCaptions as boolean,
click(item) {