Remove unplugin-vue-i18n and change language file format

去除unplugin-vue-i18n,语言文件改为json格式,把i18n-ally的localespaths设置为"src/locales/lang"就可以用。缺少downloader及calendar及format问题也一并修改。
This commit is contained in:
umbor
2023-06-12 13:08:36 +08:00
parent 5dd0d84a79
commit a9c037e69c
27 changed files with 394 additions and 516 deletions

View File

@@ -124,9 +124,9 @@ async function subscribe() {
></ab-setting>
<div flex="~ justify-end">
<ab-button size="small" :loading="analysis.loading" @click="analyser"
>{{$t('topbar.add.analyse')}}</ab-button
>
<ab-button size="small" :loading="analysis.loading" @click="analyser">{{
$t('topbar.add.analyse')
}}</ab-button>
</div>
</div>

View File

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

View File

@@ -1,8 +1,7 @@
<script lang="ts" setup>
import type { BangumiRule } from '#/bangumi';
import { useI18n } from 'vue-i18n';
import type { BangumiRule } from '#/bangumi';
const { t } = useI18n({ useScope: 'global' });
const emit = defineEmits<{
(e: 'apply', rule: BangumiRule): void;
(e: 'enable', id: number): void;
@@ -12,7 +11,7 @@ const emit = defineEmits<{
opts: { id: number; deleteFile: boolean }
): void;
}>();
const { t } = useI18n({ useScope: 'global' });
const show = defineModel('show', { default: false });
const rule = defineModel<BangumiRule>('rule', {
required: true,
@@ -72,15 +71,17 @@ const boxSize = computed(() => {
<template>
<ab-popup v-model:show="show" :title="popupTitle" :css="boxSize">
<div v-if="rule.deleted">
<div>{{$t('homepage.rule.enablehit')}}</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()"
>{{$t('homepage.rule.yesbtn')}}</ab-button
>
<ab-button size="small" @click="() => close()">{{$t('homepage.rule.nobtn')}}</ab-button>
<ab-button size="small" type="warn" @click="() => emitEnable()">{{
$t('homepage.rule.yesbtn')
}}</ab-button>
<ab-button size="small" @click="() => close()">{{
$t('homepage.rule.nobtn')
}}</ab-button>
</div>
</div>
@@ -92,29 +93,37 @@ const boxSize = computed(() => {
size="small"
type="warn"
@click="() => showDeleteFileDialog('disable')"
>{{$t('homepage.rule.disable')}}</ab-button
>{{ $t('homepage.rule.disable') }}</ab-button
>
<ab-button
size="small"
type="warn"
@click="() => showDeleteFileDialog('delete')"
>{{$t('homepage.rule.delete')}}</ab-button
>{{ $t('homepage.rule.delete') }}</ab-button
>
<ab-button size="small" @click="emitApply">{{$t('homepage.rule.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="$t('homepage.rule.delete')">
<div>{{$t('homepage.rule.deletehit')}}</div>
<ab-popup
v-model:show="deleteFileDialog.show"
:title="$t('homepage.rule.delete')"
>
<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)"
>{{$t('homepage.rule.yesbtn')}}</ab-button
>
<ab-button size="small" @click="() => emitdeleteFile(false)"
>{{$t('homepage.rule.nobtn')}}</ab-button
<ab-button
size="small"
type="warn"
@click="() => emitdeleteFile(true)"
>{{ $t('homepage.rule.yesbtn') }}</ab-button
>
<ab-button size="small" @click="() => emitdeleteFile(false)">{{
$t('homepage.rule.nobtn')
}}</ab-button>
</div>
</ab-popup>
</ab-popup>

View File

@@ -1,7 +1,7 @@
<script lang="ts" setup>
import { useI18n } from 'vue-i18n';
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', {

View File

@@ -1,6 +1,6 @@
<script lang="ts" setup>
import { Menu, MenuButton, MenuItem, MenuItems } from '@headlessui/vue';
import { Earth, AddOne, More } from '@icon-park/vue-next';
import { AddOne, Earth, More } from '@icon-park/vue-next';
withDefaults(
defineProps<{
@@ -32,7 +32,7 @@ defineEmits(['clickAdds']);
btn-click
@click="() => $emit('changeLang')"
/>
<AddOne
theme="outline"
size="24"

View File

@@ -10,7 +10,7 @@ import {
SettingTwo,
} from '@icon-park/vue-next';
import { useI18n } from 'vue-i18n';
const { t } = useI18n({ useScope: 'global' });
const props = withDefaults(
defineProps<{
open?: boolean;
@@ -19,7 +19,7 @@ const props = withDefaults(
open: false,
}
);
const { t } = useI18n({ useScope: 'global' });
const show = ref(props.open);
const toggle = () => (show.value = !show.value);
const route = useRoute();
@@ -89,7 +89,7 @@ const items = [
@click="toggle"
>
<div :class="[!show && 'abs opacity-0']" transition-opacity>
<div text-h1>{{$t('sidebar.title')}}</div>
<div text-h1>{{ $t('sidebar.title') }}</div>
</div>
<MenuUnfold
@@ -139,7 +139,7 @@ const items = [
@click="logout"
>
<Logout :size="24" />
<div text-h2>{{$t('sidebar.logout')}}</div>
<div text-h2>{{ $t('sidebar.logout') }}</div>
</div>
</div>
</div>

View File

@@ -8,6 +8,7 @@ import {
Refresh,
} from '@icon-park/vue-next';
import { useI18n } from 'vue-i18n';
const { t, locale } = useI18n({ useScope: 'global' });
const search = ref('');
const show = ref(false);
@@ -66,14 +67,14 @@ onUnmounted(() => {
offUpdate();
});
function changeLocale(){
if(localStorage.getItem('lang') === 'zh-CN'){
let newLang = 'en-US';
function changeLocale() {
if (localStorage.getItem('lang') === 'zh-CN') {
const newLang = 'en-US';
locale.value = newLang;
localStorage.setItem('lang', newLang);
location.reload();
} else {
let newLang = 'zh-CN';
const newLang = 'zh-CN';
locale.value = newLang;
localStorage.setItem('lang', newLang);
location.reload();
@@ -91,7 +92,7 @@ function changeLocale(){
<ab-search v-model:value="search" hidden />
<div ml-auto>
<ab-status-bar
<ab-status-bar
:items="items"
:running="running"
@click-add="() => (showAdd = true)"

View File

@@ -1,7 +1,7 @@
<script lang="ts" setup>
import { useI18n } from 'vue-i18n';
import type { Downloader, DownloaderType } from '#/config';
import type { SettingItem } from '#/components';
import { useI18n } from 'vue-i18n';
const { t } = useI18n({ useScope: 'global' });
const { getSettingGroup } = useConfigStore();

View File

@@ -1,7 +1,7 @@
<script lang="ts" setup>
import { useI18n } from 'vue-i18n';
import type { BangumiManage, RenameMethod } from '#/config';
import type { SettingItem } from '#/components';
import { useI18n } from 'vue-i18n';
const { t } = useI18n({ useScope: 'global' });
const { getSettingGroup } = useConfigStore();

View File

@@ -1,9 +1,9 @@
<script lang="ts" setup>
import { useI18n } from 'vue-i18n';
import type { Log, Program } from '#/config';
import type { SettingItem } from '#/components';
import { useI18n } from 'vue-i18n'
const { t } = useI18n({ useScope: 'global' })
const { t } = useI18n({ useScope: 'global' });
const { getSettingGroup } = useConfigStore();
const program = getSettingGroup('program');

View File

@@ -1,7 +1,7 @@
<script lang="ts" setup>
import { useI18n } from 'vue-i18n';
import type { Notification, NotificationType } from '#/config';
import type { SettingItem } from '#/components';
import { useI18n } from 'vue-i18n';
const { t } = useI18n({ useScope: 'global' });
const { getSettingGroup } = useConfigStore();
@@ -17,13 +17,13 @@ const notificationType: NotificationType = [
const items: SettingItem<Notification>[] = [
{
configKey: 'enable',
label: t("config.notificationset.enable"),
label: t('config.notificationset.enable'),
type: 'switch',
bottomLine: true,
},
{
configKey: 'type',
label: t("config.notificationset.type"),
label: t('config.notificationset.type'),
type: 'select',
css: 'w-140px',
prop: {
@@ -32,7 +32,7 @@ const items: SettingItem<Notification>[] = [
},
{
configKey: 'token',
label: t("config.notificationset.token"),
label: t('config.notificationset.token'),
type: 'input',
prop: {
type: 'text',
@@ -41,7 +41,7 @@ const items: SettingItem<Notification>[] = [
},
{
configKey: 'chat_id',
label: t("config.notificationset.chatid"),
label: t('config.notificationset.chatid'),
type: 'input',
prop: {
type: 'text',

View File

@@ -1,4 +1,5 @@
<script lang="ts" setup>
import { useI18n } from 'vue-i18n';
import type {
RssParser,
RssParserLang,
@@ -6,7 +7,6 @@ import type {
RssParserType,
} from '#/config';
import type { SettingItem } from '#/components';
import { useI18n } from 'vue-i18n';
const { t } = useI18n({ useScope: 'global' });
const { getSettingGroup } = useConfigStore();

View File

@@ -1,7 +1,7 @@
<script lang="ts" setup>
import { useI18n } from 'vue-i18n';
import type { Proxy, ProxyType } from '#/config';
import type { SettingItem } from '#/components';
import { useI18n } from 'vue-i18n';
const { t } = useI18n({ useScope: 'global' });
const { getSettingGroup } = useConfigStore();