Change Vue page to use i18n plugin

This commit is contained in:
umbor
2023-06-10 23:17:48 +08:00
parent c53f5f9c49
commit 513f81798c
15 changed files with 127 additions and 91 deletions

View File

@@ -111,21 +111,21 @@ async function subscribe() {
</script>
<template>
<ab-popup v-model:show="show" title="Add Bangumi" css="w-360px">
<ab-popup v-model:show="show" :title="$t('topbar.add.title')" css="w-360px">
<div v-if="!analysis.next" space-y-12px>
<ab-setting
v-model:data="rss"
label="RSS Link"
:label="$t('topbar.add.rsslink')"
type="input"
:prop="{
placeholder: 'Please enter the RSS link',
placeholder: $t('topbar.add.placeholder'),
}"
:bottom-line="true"
></ab-setting>
<div flex="~ justify-end">
<ab-button size="small" :loading="analysis.loading" @click="analyser"
>Analyse</ab-button
>{{$t('topbar.add.analyse')}}</ab-button
>
</div>
</div>

View File

@@ -7,22 +7,22 @@ const { user, update } = useAuth();
</script>
<template>
<ab-popup v-model:show="show" title="Change Account" css="w-365px">
<ab-popup v-model:show="show" :title="$t('topbar.profile.poptitle')" css="w-365px">
<div space-y-16px>
<ab-label label="Username">
<ab-label :label="$t('topbar.profile.username')">
<input
v-model="user.username"
type="text"
placeholder="username"
:placeholder="$t('topbar.profile.username')"
ab-input
/>
</ab-label>
<ab-label label="Password">
<ab-label :label="$t('topbar.profile.password')">
<input
v-model="user.password"
type="password"
placeholder="password"
:placeholder="$t('topbar.profile.password')"
ab-input
/>
</ab-label>
@@ -30,7 +30,7 @@ const { user, update } = useAuth();
<div line></div>
<div flex="~ justify-end">
<ab-button size="small" @click="update">Update</ab-button>
<ab-button size="small" @click="update">{{$t('topbar.profile.updatebtn')}}</ab-button>
</div>
</div>
</ab-popup>

View File

@@ -1,6 +1,8 @@
<script lang="ts" setup>
import type { BangumiRule } from '#/bangumi';
import { useI18n } from 'vue-i18n';
const { t } = useI18n({ useScope: 'global' });
const emit = defineEmits<{
(e: 'apply', rule: BangumiRule): void;
(e: 'enable', id: number): void;
@@ -52,9 +54,9 @@ function emitEnable() {
const popupTitle = computed(() => {
if (rule.value.deleted) {
return 'Enable Rule';
return t('homepage.rule.enablerule');
} else {
return 'Edit Rule';
return t('homepage.rule.editrule');
}
});
@@ -70,15 +72,15 @@ const boxSize = computed(() => {
<template>
<ab-popup v-model:show="show" :title="popupTitle" :css="boxSize">
<div v-if="rule.deleted">
<div>Do you want to enable this rule?</div>
<div>{{$t('homepage.rule.enablehit')}}</div>
<div line my-8px></div>
<div fx-cer justify-center space-x-10px>
<ab-button size="small" type="warn" @click="() => emitEnable()"
>Yes</ab-button
>{{$t('homepage.rule.yesbtn')}}</ab-button
>
<ab-button size="small" @click="() => close()">No</ab-button>
<ab-button size="small" @click="() => close()">{{$t('homepage.rule.nobtn')}}</ab-button>
</div>
</div>
@@ -90,28 +92,28 @@ const boxSize = computed(() => {
size="small"
type="warn"
@click="() => showDeleteFileDialog('disable')"
>Disable</ab-button
>{{$t('homepage.rule.disable')}}</ab-button
>
<ab-button
size="small"
type="warn"
@click="() => showDeleteFileDialog('delete')"
>Delete</ab-button
>{{$t('homepage.rule.delete')}}</ab-button
>
<ab-button size="small" @click="emitApply">Apply</ab-button>
<ab-button size="small" @click="emitApply">{{$t('homepage.rule.apply')}}</ab-button>
</div>
</div>
<ab-popup v-model:show="deleteFileDialog.show" title="Delete">
<div>Delete Local File?</div>
<div>{{$t('homepage.rule.deletehit')}}</div>
<div line my-8px></div>
<div fx-cer justify-center space-x-10px>
<ab-button size="small" type="warn" @click="() => emitdeleteFile(true)"
>Yes</ab-button
>{{$t('homepage.rule.yesbtn')}}</ab-button
>
<ab-button size="small" @click="() => emitdeleteFile(false)"
>No</ab-button
>{{$t('homepage.rule.nobtn')}}</ab-button
>
</div>
</ab-popup>

View File

@@ -1,7 +1,9 @@
<script lang="ts" setup>
import type { BangumiRule } from '#/bangumi';
import type { SettingItem } from '#/components';
import { useI18n } from 'vue-i18n';
const { t } = useI18n({ useScope: 'global' });
const rule = defineModel<BangumiRule>('rule', {
required: true,
});
@@ -9,7 +11,7 @@ const rule = defineModel<BangumiRule>('rule', {
const items: SettingItem<BangumiRule>[] = [
{
configKey: 'official_title',
label: 'Officical Ttile',
label: t('homepage.rule.officaltitle'),
type: 'input',
prop: {
type: 'text',
@@ -17,7 +19,7 @@ const items: SettingItem<BangumiRule>[] = [
},
{
configKey: 'year',
label: 'Year',
label: t('homepage.rule.year'),
type: 'input',
css: 'w-72px',
prop: {
@@ -26,7 +28,7 @@ const items: SettingItem<BangumiRule>[] = [
},
{
configKey: 'season',
label: 'Season',
label: t('homepage.rule.season'),
type: 'input',
css: 'w-72px',
prop: {
@@ -36,7 +38,7 @@ const items: SettingItem<BangumiRule>[] = [
},
{
configKey: 'offset',
label: 'Offset',
label: t('homepage.rule.offset'),
type: 'input',
css: 'w-72px',
prop: {
@@ -45,7 +47,7 @@ const items: SettingItem<BangumiRule>[] = [
},
{
configKey: 'filter',
label: 'Exclude',
label: t('homepage.rule.exclude'),
type: 'dynamic-tags',
bottomLine: true,
},

View File

@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/vue';
import { AddOne, More } from '@icon-park/vue-next';
import { Earth, AddOne, More } from '@icon-park/vue-next';
withDefaults(
defineProps<{
@@ -17,13 +17,22 @@ withDefaults(
}
);
defineEmits(['clickAdd']);
defineEmits(['clickAdds']);
</script>
<template>
<Menu>
<div rel>
<div fx-cer space-x-16px>
<Earth
theme="outline"
size="24"
fill="#fff"
is-btn
btn-click
@click="() => $emit('changeLang')"
/>
<AddOne
theme="outline"
size="24"

View File

@@ -9,7 +9,8 @@ import {
Play,
SettingTwo,
} from '@icon-park/vue-next';
import { useI18n } from 'vue-i18n';
const { t } = useI18n({ useScope: 'global' });
const props = withDefaults(
defineProps<{
open?: boolean;
@@ -28,39 +29,39 @@ const items = [
{
id: 1,
icon: Home,
label: 'HomePage',
label: t('sidebar.homepage'),
path: '/bangumi',
},
{
id: 2,
icon: Calendar,
label: 'Calendar',
label: t('sidebar.calendar'),
path: '/calendar',
hidden: true,
},
{
id: 3,
icon: Play,
label: 'Player',
label: t('sidebar.player'),
path: '/player',
},
{
id: 4,
icon: Download,
label: 'Downloader',
label: t('sidebar.downloader'),
path: '/downloader',
hidden: true,
},
{
id: 5,
icon: Log,
label: 'Log',
label: t('sidebar.log'),
path: '/log',
},
{
id: 6,
icon: SettingTwo,
label: 'Config',
label: t('sidebar.config'),
path: '/config',
},
];
@@ -88,7 +89,7 @@ const items = [
@click="toggle"
>
<div :class="[!show && 'abs opacity-0']" transition-opacity>
<div text-h1>Menu</div>
<div text-h1>{{$t('sidebar.title')}}</div>
</div>
<MenuUnfold
@@ -138,7 +139,7 @@ const items = [
@click="logout"
>
<Logout :size="24" />
<div text-h2>Logout</div>
<div text-h2>{{$t('sidebar.logout')}}</div>
</div>
</div>
</div>

View File

@@ -7,7 +7,8 @@ import {
Refresh,
Format,
} from '@icon-park/vue-next';
import { useI18n } from 'vue-i18n';
const { t, locale } = useI18n({ useScope: 'global' });
const search = ref('');
const show = ref(false);
const showAdd = ref(false);
@@ -19,37 +20,37 @@ const { running } = storeToRefs(useProgramStore());
const items = [
{
id: 1,
label: 'Start',
label: t('topbar.start'),
icon: PlayOne,
handle: start,
},
{
id: 2,
label: 'Pause',
label: t('topbar.pause'),
icon: Pause,
handle: pause,
},
{
id: 3,
label: 'Restart',
label: t('topbar.restart'),
icon: Refresh,
handle: restart,
},
{
id: 4,
label: 'Shutdown',
label: t('topbar.shutdown'),
icon: Power,
handle: shutdown,
},
{
id: 5,
label: 'Reset Rule',
label: t('topbar.resetrule'),
icon: Format,
handle: resetRule,
},
{
id: 6,
label: 'Profile',
label: t('topbar.profile.title'),
icon: Me,
handle: () => {
show.value = true;
@@ -64,6 +65,14 @@ onBeforeMount(() => {
onUnmounted(() => {
offUpdate();
});
function changeLocale(){
if(t.value === 'zh-CN'){
t.value = locale.value = 'en'
} else {
t.value = locale.value = 'zh-CN';
}
}
</script>
<template>
@@ -76,10 +85,11 @@ onUnmounted(() => {
<ab-search v-model:value="search" hidden />
<div ml-auto>
<ab-status-bar
<ab-status-bar
:items="items"
:running="running"
@click-add="() => (showAdd = true)"
@change-lang="() => changeLocale()"
></ab-status-bar>
</div>

View File

@@ -1,7 +1,9 @@
<script lang="ts" setup>
import type { Downloader, DownloaderType } from '#/config';
import type { SettingItem } from '#/components';
import { useI18n } from 'vue-i18n';
const { t } = useI18n({ useScope: 'global' });
const { getSettingGroup } = useConfigStore();
const downloader = getSettingGroup('downloader');
@@ -10,7 +12,7 @@ const downloaderType: DownloaderType = ['qbittorrent'];
const items: SettingItem<Downloader>[] = [
{
configKey: 'type',
label: 'Downloader Type',
label: t('config.downloaderset.type'),
type: 'select',
css: 'w-115px',
prop: {
@@ -19,7 +21,7 @@ const items: SettingItem<Downloader>[] = [
},
{
configKey: 'host',
label: 'Host',
label: t('config.downloaderset.host'),
type: 'input',
prop: {
type: 'text',
@@ -28,7 +30,7 @@ const items: SettingItem<Downloader>[] = [
},
{
configKey: 'username',
label: 'Username',
label: t('config.downloaderset.username'),
type: 'input',
prop: {
type: 'text',
@@ -37,7 +39,7 @@ const items: SettingItem<Downloader>[] = [
},
{
configKey: 'password',
label: 'Password',
label: t('config.downloaderset.password'),
type: 'input',
prop: {
type: 'text',
@@ -47,7 +49,7 @@ const items: SettingItem<Downloader>[] = [
},
{
configKey: 'path',
label: 'Download Path',
label: t('config.downloaderset.path'),
type: 'input',
prop: {
type: 'text',
@@ -56,14 +58,14 @@ const items: SettingItem<Downloader>[] = [
},
{
configKey: 'ssl',
label: 'SSL',
label: t('config.downloaderset.ssl'),
type: 'switch',
},
];
</script>
<template>
<ab-fold-panel title="Downloader Setting">
<ab-fold-panel :title="$t('config.downloaderset.title')">
<div space-y-12px>
<ab-setting
v-for="i in items"

View File

@@ -1,7 +1,9 @@
<script lang="ts" setup>
import type { BangumiManage, RenameMethod } from '#/config';
import type { SettingItem } from '#/components';
import { useI18n } from 'vue-i18n';
const { t } = useI18n({ useScope: 'global' });
const { getSettingGroup } = useConfigStore();
const manage = getSettingGroup('bangumi_manage');
@@ -10,12 +12,12 @@ const renameMethod: RenameMethod = ['normal', 'pn', 'advance', 'none'];
const items: SettingItem<BangumiManage>[] = [
{
configKey: 'enable',
label: 'Enable',
label: t('config.manageset.enable'),
type: 'switch',
},
{
configKey: 'rename_method',
label: 'Rename Method',
label: t('config.manageset.method'),
type: 'select',
prop: {
items: renameMethod,
@@ -24,24 +26,24 @@ const items: SettingItem<BangumiManage>[] = [
},
{
configKey: 'eps_complete',
label: 'Eps complete',
label: t('config.manageset.eps'),
type: 'switch',
},
{
configKey: 'group_tag',
label: 'Add Group Tag',
label: t('config.manageset.grouptag'),
type: 'switch',
},
{
configKey: 'remove_bad_torrent',
label: 'Delete Bad Torrent',
label: t('config.manageset.deletebadtorr'),
type: 'switch',
},
];
</script>
<template>
<ab-fold-panel title="Manage Setting">
<ab-fold-panel :title="$t('config.manageset.title')">
<div space-y-12px>
<ab-setting
v-for="i in items"

View File

@@ -1,7 +1,9 @@
<script lang="ts" setup>
import type { Log, Program } from '#/config';
import type { SettingItem } from '#/components';
import { useI18n } from 'vue-i18n'
const { t } = useI18n({ useScope: 'global' })
const { getSettingGroup } = useConfigStore();
const program = getSettingGroup('program');
@@ -10,7 +12,7 @@ const log = getSettingGroup('log');
const programItems: SettingItem<Program>[] = [
{
configKey: 'rss_time',
label: 'Interval Time of Rss',
label: t('config.normalset.rssintvl'),
type: 'input',
css: 'w-72px',
prop: {
@@ -20,7 +22,7 @@ const programItems: SettingItem<Program>[] = [
},
{
configKey: 'rename_time',
label: 'Interval Time of Rename',
label: t('config.normalset.renameintvl'),
type: 'input',
css: 'w-72px',
prop: {
@@ -30,7 +32,7 @@ const programItems: SettingItem<Program>[] = [
},
{
configKey: 'webui_port',
label: 'WebUI Port',
label: t('config.normalset.webport'),
type: 'input',
css: 'w-72px',
prop: {
@@ -43,13 +45,13 @@ const programItems: SettingItem<Program>[] = [
const logItems: SettingItem<Log> = {
configKey: 'debug_enable',
label: 'Debug',
label: t('config.normalset.debug'),
type: 'switch',
};
</script>
<template>
<ab-fold-panel title="Normal Setting">
<ab-fold-panel :title="$t('config.normalset.title')">
<div space-y-12px>
<ab-setting
v-for="i in programItems"

View File

@@ -1,7 +1,9 @@
<script lang="ts" setup>
import type { Notification, NotificationType } from '#/config';
import type { SettingItem } from '#/components';
import { useI18n } from 'vue-i18n';
const { t } = useI18n({ useScope: 'global' });
const { getSettingGroup } = useConfigStore();
const notification = getSettingGroup('notification');
@@ -10,13 +12,13 @@ const notificationType: NotificationType = ['telegram', 'server-chan', 'bark', '
const items: SettingItem<Notification>[] = [
{
configKey: 'enable',
label: 'Enable',
label: t("config.notificationset.enable"),
type: 'switch',
bottomLine: true,
},
{
configKey: 'type',
label: 'Type',
label: t("config.notificationset.type"),
type: 'select',
css: 'w-140px',
prop: {
@@ -25,7 +27,7 @@ const items: SettingItem<Notification>[] = [
},
{
configKey: 'token',
label: 'Token',
label: t("config.notificationset.token"),
type: 'input',
prop: {
type: 'text',
@@ -34,7 +36,7 @@ const items: SettingItem<Notification>[] = [
},
{
configKey: 'chat_id',
label: 'Chat ID',
label: t("config.notificationset.chatid"),
type: 'input',
prop: {
type: 'text',
@@ -45,7 +47,7 @@ const items: SettingItem<Notification>[] = [
</script>
<template>
<ab-fold-panel title="Notification Setting">
<ab-fold-panel :title="$t('config.notificationset.title')">
<div space-y-12px>
<ab-setting
v-for="i in items"

View File

@@ -6,7 +6,9 @@ import type {
RssParserType,
} from '#/config';
import type { SettingItem } from '#/components';
import { useI18n } from 'vue-i18n';
const { t } = useI18n({ useScope: 'global' });
const { getSettingGroup } = useConfigStore();
const parser = getSettingGroup('rss_parser');
@@ -19,12 +21,12 @@ const parserMethods: RssParserMethodType = ['tmdb', 'mikan', 'parser'];
const items: SettingItem<RssParser>[] = [
{
configKey: 'enable',
label: 'Enable',
label: t('config.parserset.enable'),
type: 'switch',
},
{
configKey: 'type',
label: 'Source',
label: t('config.parserset.source'),
type: 'select',
css: 'w-115px',
prop: {
@@ -33,7 +35,7 @@ const items: SettingItem<RssParser>[] = [
},
{
configKey: 'token',
label: 'Token',
label: t('config.parserset.token'),
type: 'input',
prop: {
type: 'text',
@@ -42,7 +44,7 @@ const items: SettingItem<RssParser>[] = [
},
{
configKey: 'custom_url',
label: 'Custom Url',
label: t('config.parserset.url'),
type: 'input',
prop: {
type: 'text',
@@ -52,7 +54,7 @@ const items: SettingItem<RssParser>[] = [
},
{
configKey: 'language',
label: 'Language',
label: t('config.parserset.language'),
type: 'select',
prop: {
items: langs,
@@ -60,7 +62,7 @@ const items: SettingItem<RssParser>[] = [
},
{
configKey: 'parser_type',
label: 'Parser Type',
label: t('config.parserset.type'),
type: 'select',
prop: {
items: parserMethods,
@@ -68,14 +70,14 @@ const items: SettingItem<RssParser>[] = [
},
{
configKey: 'filter',
label: 'Exclude',
label: t('config.parserset.exclude'),
type: 'dynamic-tags',
},
];
</script>
<template>
<ab-fold-panel title="Parser Setting">
<ab-fold-panel :title="$t('config.parserset.title')">
<div space-y-12px>
<ab-setting
v-for="i in items"

View File

@@ -3,19 +3,19 @@ const { types, type, url } = storeToRefs(usePlayerStore());
</script>
<template>
<ab-fold-panel title="Media Player Setting">
<ab-fold-panel :title="$t('config.mediaplayerset.title')">
<div space-y-12px>
<ab-setting
v-model:data="type"
type="select"
label="type"
:label="$t('config.mediaplayerset.type')"
:prop="{ items: types }"
></ab-setting>
<ab-setting
v-model:data="url"
type="input"
label="url"
:label="$t('config.mediaplayerset.url')"
:prop="{ placeholder: 'media player url' }"
></ab-setting>
</div>

View File

@@ -1,7 +1,9 @@
<script lang="ts" setup>
import type { Proxy, ProxyType } from '#/config';
import type { SettingItem } from '#/components';
import { useI18n } from 'vue-i18n';
const { t } = useI18n({ useScope: 'global' });
const { getSettingGroup } = useConfigStore();
const proxy = getSettingGroup('proxy');
@@ -10,12 +12,12 @@ const proxyType: ProxyType = ['http', 'https', 'socks5'];
const items: SettingItem<Proxy>[] = [
{
configKey: 'enable',
label: 'Enable',
label: t('config.proxyset.enable'),
type: 'switch',
},
{
configKey: 'type',
label: 'Proxy Type',
label: t('config.proxyset.type'),
type: 'select',
prop: {
items: proxyType,
@@ -24,7 +26,7 @@ const items: SettingItem<Proxy>[] = [
},
{
configKey: 'host',
label: 'Host',
label: t('config.proxyset.host'),
type: 'input',
prop: {
type: 'text',
@@ -33,7 +35,7 @@ const items: SettingItem<Proxy>[] = [
},
{
configKey: 'port',
label: 'Port',
label: t('config.proxyset.port'),
type: 'input',
prop: {
type: 'text',
@@ -42,7 +44,7 @@ const items: SettingItem<Proxy>[] = [
},
{
configKey: 'username',
label: 'Username',
label: t('config.proxyset.username'),
type: 'input',
prop: {
type: 'text',
@@ -51,7 +53,7 @@ const items: SettingItem<Proxy>[] = [
},
{
configKey: 'password',
label: 'Password',
label: t('config.proxyset.password'),
type: 'input',
prop: {
type: 'text',
@@ -62,7 +64,7 @@ const items: SettingItem<Proxy>[] = [
</script>
<template>
<ab-fold-panel title="Proxy Setting">
<ab-fold-panel :title="$t('config.proxyset.title')">
<div space-y-12px>
<ab-setting
v-for="i in items"

View File

@@ -8,9 +8,9 @@ definePage({
<template>
<div f-cer layout-container>
<ab-container title="Login" w-365px>
<ab-container :title="$t('login.title')" w-365px>
<div space-y-16px>
<ab-label label="Username">
<ab-label :label="$t('login.username')">
<input
v-model="user.username"
type="text"
@@ -19,7 +19,7 @@ definePage({
/>
</ab-label>
<ab-label label="Password">
<ab-label :label="$t('login.password')">
<input
v-model="user.password"
type="password"
@@ -32,13 +32,13 @@ definePage({
<div line></div>
<div flex="~ justify-end">
<ab-button size="small" @click="login">Login</ab-button>
<ab-button size="small" @click="login">{{$t('login.loginbtn')}}</ab-button>
</div>
</div>
</ab-container>
<div bg="#C7C4AB" text-white rounded-4px py-4px px-2em text-main>
<div>Default: admin adminadmin</div>
<div>{{$t('login.default')}}: admin adminadmin</div>
</div>
</div>
</template>