fix(i18n): plugin name, description i18n

This commit is contained in:
JellyBrick
2023-12-02 02:33:25 +09:00
parent 123eabd77a
commit 5ae4f564b7
36 changed files with 72 additions and 74 deletions

View File

@ -12,8 +12,6 @@ export const loadI18n = async () =>
} }
}); });
loadI18n();
export const setLanguage = async (language: string) => await changeLanguage(language); export const setLanguage = async (language: string) => await changeLanguage(language);
export const t = i18t.bind(i18next); export const t = i18t.bind(i18next);

View File

@ -193,10 +193,10 @@ const showNeedToRestartDialog = (id: string) => {
], ],
title: t('main.dialog.need-to-restart.title'), title: t('main.dialog.need-to-restart.title'),
message: t('main.dialog.need-to-restart.message', { message: t('main.dialog.need-to-restart.message', {
pluginName: plugin?.name ?? id, pluginName: plugin?.name?.() ?? id,
}), }),
detail: t('main.dialog.need-to-restart.detail', { detail: t('main.dialog.need-to-restart.detail', {
pluginName: plugin?.name ?? id, pluginName: plugin?.name?.() ?? id,
}), }),
defaultId: 0, defaultId: 0,
cancelId: 1, cancelId: 1,

View File

@ -66,7 +66,7 @@ export const mainMenuTemplate = async (
const menuResult = Object.entries(getAllMenuTemplate()).map( const menuResult = Object.entries(getAllMenuTemplate()).map(
([id, template]) => { ([id, template]) => {
const pluginLabel = allPlugins[id]?.name ?? id; const pluginLabel = allPlugins[id]?.name?.() ?? id;
if (!config.plugins.isEnabled(id)) { if (!config.plugins.isEnabled(id)) {
return [ return [
@ -92,8 +92,8 @@ export const mainMenuTemplate = async (
const availablePlugins = Object.keys(allPlugins); const availablePlugins = Object.keys(allPlugins);
const pluginMenus = availablePlugins const pluginMenus = availablePlugins
.sort((a, b) => { .sort((a, b) => {
const aPluginLabel = allPlugins[a]?.name ?? a; const aPluginLabel = allPlugins[a]?.name?.() ?? a;
const bPluginLabel = allPlugins[b]?.name ?? b; const bPluginLabel = allPlugins[b]?.name?.() ?? b;
return aPluginLabel.localeCompare(bPluginLabel); return aPluginLabel.localeCompare(bPluginLabel);
}) })
@ -101,7 +101,7 @@ export const mainMenuTemplate = async (
const predefinedTemplate = menuResult.find((it) => it[0] === id); const predefinedTemplate = menuResult.find((it) => it[0] === id);
if (predefinedTemplate) return predefinedTemplate[1]; if (predefinedTemplate) return predefinedTemplate[1];
const pluginLabel = allPlugins[id]?.name ?? id; const pluginLabel = allPlugins[id]?.name?.() ?? id;
return pluginEnabledMenu(id, pluginLabel, true, innerRefreshMenu); return pluginEnabledMenu(id, pluginLabel, true, innerRefreshMenu);
}); });

View File

@ -43,8 +43,8 @@ interface AdblockerConfig {
} }
export default createPlugin({ export default createPlugin({
name: t('plugins.adblocker.name'), name: () => t('plugins.adblocker.name'),
description: t('plugins.adblocker.description'), description: () => t('plugins.adblocker.description'),
restartNeeded: false, restartNeeded: false,
config: { config: {
enabled: true, enabled: true,

View File

@ -8,8 +8,8 @@ import { t } from '@/i18n';
import type { VideoDataChanged } from '@/types/video-data-changed'; import type { VideoDataChanged } from '@/types/video-data-changed';
export default createPlugin({ export default createPlugin({
name: t('plugins.album-color-theme.name'), name: () => t('plugins.album-color-theme.name'),
description: t('plugins.album-color-theme.description'), description: () => t('plugins.album-color-theme.description'),
restartNeeded: true, restartNeeded: true,
config: { config: {
enabled: false, enabled: false,

View File

@ -25,8 +25,8 @@ const defaultConfig: AmbientModePluginConfig = {
}; };
export default createPlugin({ export default createPlugin({
name: t('plugins.ambient-mode.name'), name: () => t('plugins.ambient-mode.name'),
description: t('plugins.ambient-mode.description'), description: () => t('plugins.ambient-mode.description'),
restartNeeded: false, restartNeeded: false,
config: defaultConfig, config: defaultConfig,
stylesheets: [style], stylesheets: [style],

View File

@ -2,8 +2,8 @@ import { createPlugin } from '@/utils';
import { t } from '@/i18n'; import { t } from '@/i18n';
export default createPlugin({ export default createPlugin({
name: t('plugins.audio-compressor.name'), name: () => t('plugins.audio-compressor.name'),
description: t('plugins.audio-compressor.description'), description: () => t('plugins.audio-compressor.description'),
renderer() { renderer() {
document.addEventListener( document.addEventListener(

View File

@ -3,8 +3,8 @@ import style from './style.css?inline';
import { t } from '@/i18n'; import { t } from '@/i18n';
export default createPlugin({ export default createPlugin({
name: t('plugins.blur-nav-bar.name'), name: () => t('plugins.blur-nav-bar.name'),
description: t('plugins.blur-nav-bar.description'), description: () => t('plugins.blur-nav-bar.description'),
restartNeeded: true, restartNeeded: true,
stylesheets: [style], stylesheets: [style],
renderer() {}, renderer() {},

View File

@ -2,8 +2,8 @@ import { createPlugin } from '@/utils';
import { t } from '@/i18n'; import { t } from '@/i18n';
export default createPlugin({ export default createPlugin({
name: t('plugins.bypass-age-restrictions.name'), name: () => t('plugins.bypass-age-restrictions.name'),
description: t('plugins.bypass-age-restrictions.description'), description: () => t('plugins.bypass-age-restrictions.description'),
restartNeeded: true, restartNeeded: true,
// See https://github.com/zerodytrash/Simple-YouTube-Age-Restriction-Bypass#userscript // See https://github.com/zerodytrash/Simple-YouTube-Age-Restriction-Bypass#userscript

View File

@ -19,8 +19,8 @@ export default createPlugin<
}, },
CaptionsSelectorConfig CaptionsSelectorConfig
>({ >({
name: t('plugins.captions-selector.name'), name: () => t('plugins.captions-selector.name'),
description: t('plugins.captions-selector.description'), description: () => t('plugins.captions-selector.description'),
config: { config: {
enabled: false, enabled: false,
disableCaptions: false, disableCaptions: false,

View File

@ -9,8 +9,8 @@ export default createPlugin<
isCompactSidebarDisabled: () => boolean; isCompactSidebarDisabled: () => boolean;
} }
>({ >({
name: t('plugins.compact-sidebar.name'), name: () => t('plugins.compact-sidebar.name'),
description: t('plugins.compact-sidebar.description'), description: () => t('plugins.compact-sidebar.description'),
restartNeeded: false, restartNeeded: false,
config: { config: {
enabled: false, enabled: false,

View File

@ -30,8 +30,8 @@ export default createPlugin<
}, },
CrossfadePluginConfig CrossfadePluginConfig
>({ >({
name: t('plugins.crossfade.name'), name: () => t('plugins.crossfade.name'),
description: t('plugins.crossfade.description'), description: () => t('plugins.crossfade.description'),
restartNeeded: true, restartNeeded: true,
config: { config: {
enabled: false, enabled: false,

View File

@ -21,8 +21,8 @@ export default createPlugin<
}, },
DisableAutoPlayPluginConfig DisableAutoPlayPluginConfig
>({ >({
name: t('plugins.disable-autoplay.name'), name: () => t('plugins.disable-autoplay.name'),
description: t('plugins.disable-autoplay.description'), description: () => t('plugins.disable-autoplay.description'),
restartNeeded: false, restartNeeded: false,
config: { config: {
enabled: false, enabled: false,

View File

@ -36,8 +36,8 @@ export type DiscordPluginConfig = {
}; };
export default createPlugin({ export default createPlugin({
name: t('plugins.discord.name'), name: () => t('plugins.discord.name'),
description: t('plugins.discord.description'), description: () => t('plugins.discord.description'),
restartNeeded: false, restartNeeded: false,
config: { config: {
enabled: false, enabled: false,

View File

@ -26,8 +26,8 @@ export const defaultConfig: DownloaderPluginConfig = {
}; };
export default createPlugin({ export default createPlugin({
name: t('plugins.downloader.name'), name: () => t('plugins.downloader.name'),
description: t('plugins.downloader.description'), description: () => t('plugins.downloader.description'),
restartNeeded: true, restartNeeded: true,
config: defaultConfig, config: defaultConfig,
stylesheets: [style], stylesheets: [style],

View File

@ -2,8 +2,8 @@ import { createPlugin } from '@/utils';
import { t } from '@/i18n'; import { t } from '@/i18n';
export default createPlugin({ export default createPlugin({
name: t('plugins.exponential-volume.name'), name: () => t('plugins.exponential-volume.name'),
description: t('plugins.exponential-volume.description'), description: () => t('plugins.exponential-volume.description'),
restartNeeded: true, restartNeeded: true,
config: { config: {
enabled: false, enabled: false,

View File

@ -10,8 +10,8 @@ export interface InAppMenuConfig {
hideDOMWindowControls: boolean; hideDOMWindowControls: boolean;
} }
export default createPlugin({ export default createPlugin({
name: t('plugins.in-app-menu.name'), name: () => t('plugins.in-app-menu.name'),
description: t('plugins.in-app-menu.description'), description: () => t('plugins.in-app-menu.description'),
restartNeeded: true, restartNeeded: true,
config: { config: {
enabled: enabled:

View File

@ -34,8 +34,8 @@ export interface LastFmPluginConfig {
} }
export default createPlugin({ export default createPlugin({
name: t('plugins.last-fm.name'), name: () => t('plugins.last-fm.name'),
description: t('plugins.last-fm.description'), description: () => t('plugins.last-fm.description'),
restartNeeded: true, restartNeeded: true,
config: { config: {
enabled: false, enabled: false,

View File

@ -24,8 +24,8 @@ type LumiaData = {
}; };
export default createPlugin({ export default createPlugin({
name: t('plugins.lumiastream.name'), name: () => t('plugins.lumiastream.name'),
description: t('plugins.lumiastream.description'), description: () => t('plugins.lumiastream.description'),
restartNeeded: true, restartNeeded: true,
config: { config: {
enabled: false, enabled: false,

View File

@ -10,8 +10,8 @@ export type LyricsGeniusPluginConfig = {
}; };
export default createPlugin({ export default createPlugin({
name: t('plugins.lyrics-genius.name'), name: () => t('plugins.lyrics-genius.name'),
description: t('plugins.lyrics-genius.description'), description: () => t('plugins.lyrics-genius.description'),
restartNeeded: true, restartNeeded: true,
config: { config: {
enabled: false, enabled: false,

View File

@ -8,8 +8,8 @@ import forwardHTML from './templates/forward.html?raw';
import backHTML from './templates/back.html?raw'; import backHTML from './templates/back.html?raw';
export default createPlugin({ export default createPlugin({
name: t('plugins.navigation.name'), name: () => t('plugins.navigation.name'),
description: t('plugins.navigation.description'), description: () => t('plugins.navigation.description'),
restartNeeded: true, restartNeeded: true,
config: { config: {
enabled: true, enabled: true,

View File

@ -3,8 +3,8 @@ import { createPlugin } from '@/utils';
import { t } from '@/i18n'; import { t } from '@/i18n';
export default createPlugin({ export default createPlugin({
name: t('plugins.no-google-login.name'), name: () => t('plugins.no-google-login.name'),
description: t('plugins.no-google-login.description'), description: () => t('plugins.no-google-login.description'),
restartNeeded: true, restartNeeded: true,
config: { config: {
enabled: false, enabled: false,

View File

@ -36,8 +36,8 @@ export const defaultConfig: NotificationsPluginConfig = {
}; };
export default createPlugin({ export default createPlugin({
name: t('plugins.notifications.name'), name: () => t('plugins.notifications.name'),
description: t('plugins.notifications.description'), description: () => t('plugins.notifications.description'),
restartNeeded: true, restartNeeded: true,
config: defaultConfig, config: defaultConfig,
menu: onMenu, menu: onMenu,

View File

@ -19,8 +19,8 @@ export type PictureInPicturePluginConfig = {
}; };
export default createPlugin({ export default createPlugin({
name: t('plugins.picture-in-picture.name'), name: () => t('plugins.picture-in-picture.name'),
description: t('plugins.picture-in-picture.description'), description: () => t('plugins.picture-in-picture.description'),
restartNeeded: true, restartNeeded: true,
config: { config: {
'enabled': false, 'enabled': false,

View File

@ -3,8 +3,8 @@ import { onPlayerApiReady, onUnload } from './renderer';
import { t } from '@/i18n'; import { t } from '@/i18n';
export default createPlugin({ export default createPlugin({
name: t('plugins.playback-speed.name'), name: () => t('plugins.playback-speed.name'),
description: t('plugins.playback-speed.description'), description: () => t('plugins.playback-speed.description'),
restartNeeded: false, restartNeeded: false,
config: { config: {
enabled: false, enabled: false,

View File

@ -30,8 +30,8 @@ export type PreciseVolumePluginConfig = {
}; };
export default createPlugin({ export default createPlugin({
name: t('plugins.precise-volume.name'), name: () => t('plugins.precise-volume.name'),
description: t('plugins.precise-volume.description'), description: () => t('plugins.precise-volume.description'),
restartNeeded: true, restartNeeded: true,
config: { config: {
enabled: false, enabled: false,

View File

@ -9,8 +9,8 @@ import { t } from '@/i18n';
import type { YoutubePlayer } from '@/types/youtube-player'; import type { YoutubePlayer } from '@/types/youtube-player';
export default createPlugin({ export default createPlugin({
name: t('plugins.quality-changer.name'), name: () => t('plugins.quality-changer.name'),
description: t('plugins.quality-changer.description'), description: () => t('plugins.quality-changer.description'),
restartNeeded: false, restartNeeded: false,
config: { config: {
enabled: false, enabled: false,

View File

@ -16,8 +16,8 @@ export type ShortcutsPluginConfig = {
}; };
export default createPlugin({ export default createPlugin({
name: t('plugins.shortcuts.name'), name: () => t('plugins.shortcuts.name'),
description: t('plugins.shortcuts.description'), description: () => t('plugins.shortcuts.description'),
restartNeeded: true, restartNeeded: true,
config: { config: {
enabled: false, enabled: false,

View File

@ -8,8 +8,8 @@ export type SkipSilencesPluginConfig = {
}; };
export default createPlugin({ export default createPlugin({
name: t('plugins.skip-silences.name'), name: () => t('plugins.skip-silences.name'),
description: t('plugins.skip-silences.description'), description: () => t('plugins.skip-silences.description'),
restartNeeded: true, restartNeeded: true,
config: { config: {
enabled: false, enabled: false,

View File

@ -25,8 +25,8 @@ export type SponsorBlockPluginConfig = {
let currentSegments: Segment[] = []; let currentSegments: Segment[] = [];
export default createPlugin({ export default createPlugin({
name: t('plugins.sponsorblock.name'), name: () => t('plugins.sponsorblock.name'),
description: t('plugins.sponsorblock.description'), description: () => t('plugins.sponsorblock.description'),
restartNeeded: true, restartNeeded: true,
config: { config: {
enabled: false, enabled: false,

View File

@ -12,8 +12,8 @@ import { mediaIcons } from '@/types/media-icons';
import { t } from '@/i18n'; import { t } from '@/i18n';
export default createPlugin({ export default createPlugin({
name: t('plugins.taskbar-mediacontrol.name'), name: () => t('plugins.taskbar-mediacontrol.name'),
description: t('plugins.taskbar-mediacontrol.description'), description: () => t('plugins.taskbar-mediacontrol.description'),
restartNeeded: true, restartNeeded: true,
config: { config: {
enabled: false, enabled: false,

View File

@ -6,8 +6,8 @@ import registerCallback from '@/providers/song-info';
import { t } from '@/i18n'; import { t } from '@/i18n';
export default createPlugin({ export default createPlugin({
name: t('plugins.touchbar.name'), name: () => t('plugins.touchbar.name'),
description: t('plugins.touchbar.description'), description: () => t('plugins.touchbar.description'),
restartNeeded: true, restartNeeded: true,
config: { config: {
enabled: false, enabled: false,

View File

@ -19,8 +19,8 @@ interface Data {
} }
export default createPlugin({ export default createPlugin({
name: t('plugins.tuna-obs.name'), name: () => t('plugins.tuna-obs.name'),
description: t('plugins.tuna-obs.description'), description: () => t('plugins.tuna-obs.description'),
restartNeeded: true, restartNeeded: true,
config: { config: {
enabled: false, enabled: false,

View File

@ -18,8 +18,8 @@ export type VideoTogglePluginConfig = {
}; };
export default createPlugin({ export default createPlugin({
name: t('plugins.video-toggle.name'), name: () => t('plugins.video-toggle.name'),
description: t('plugins.video-toggle.description'), description: () => t('plugins.video-toggle.description'),
restartNeeded: true, restartNeeded: true,
config: { config: {
enabled: false, enabled: false,

View File

@ -58,8 +58,8 @@ export type VisualizerPluginConfig = {
}; };
export default createPlugin({ export default createPlugin({
name: t('plugins.visualizer.name'), name: () => t('plugins.visualizer.name'),
description: t('plugins.visualizer.description'), description: () => t('plugins.visualizer.description'),
restartNeeded: true, restartNeeded: true,
config: { config: {
enabled: false, enabled: false,

View File

@ -44,9 +44,9 @@ export interface PluginDef<
RendererProperties, RendererProperties,
Config extends PluginConfig = PluginConfig, Config extends PluginConfig = PluginConfig,
> { > {
name: string; name: () => string;
authors?: Author[]; authors?: Author[];
description?: string; description?: () => string;
config?: Config; config?: Config;
menu?: ( menu?: (