Skip to content

Commit 6eab494

Browse files
committed
重构 i18n 结构
1 parent 1bbfe5f commit 6eab494

30 files changed

+352
-493
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "function-plot-gui",
33
"private": true,
4-
"version": "0.4.0",
4+
"version": "0.5",
55
"type": "module",
66
"scripts": {
77
"dev": "vite",

src/editor/annotation.vue

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
>
2020
<SIconDelete />
2121
</s-icon-button>
22-
{{ t("buttons.del") }}
22+
{{ t("annotation.topButton.delete") }}
2323
</s-tooltip>
2424
<s-tooltip>
2525
<s-icon-button
@@ -29,7 +29,7 @@
2929
>
3030
<SIconTextfield />
3131
</s-icon-button>
32-
{{ t("annotation.text") }}
32+
{{ t(`annotation.topButton.${showText ? "remove" : "add"}Text`) }}
3333
</s-tooltip>
3434
<span class="annotation-drag drag-icon">
3535
<SIconDrag />
@@ -62,7 +62,8 @@
6262

6363
<script setup lang="ts">
6464
import { useI18n } from "vue-i18n";
65-
const { t } = useI18n();
65+
import { I18nSchema } from "@/i18n";
66+
const { t } = useI18n<{ message: I18nSchema }>();
6667
6768
import SIconDelete from "@/ui/icons/delete.vue";
6869
import SIconDrag from "@/ui/icons/drag.vue";

src/editor/annotationList.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@
1717
</VueDraggable>
1818
<div class="plot-data add-data" @click="profile.addAnnotation">
1919
<s-icon name="add" />
20-
{{ t("buttons.add") }}
20+
{{ t("editor.add") }}
2121
<s-ripple attached></s-ripple>
2222
</div>
2323
</s-scroll-view>
2424
</template>
2525

2626
<script setup lang="ts">
2727
import { useI18n } from "vue-i18n";
28-
const { t } = useI18n();
28+
import { I18nSchema } from "@/i18n";
29+
const { t } = useI18n<{ message: I18nSchema }>();
2930
3031
import AnimatedList from "@/ui/animated/animatedList.vue";
3132
import AnimatedListItem from "@/ui/animated/animatedListItem.vue";

src/editor/data.vue

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,24 @@
33
<div class="selectors">
44
<!-- fnType Picker -->
55
<s-picker
6-
:label="t('inputs.fnType')"
6+
:label="t('data.main.fnType')"
77
v-model.lazy="fnType"
88
:key="selectKey"
99
>
1010
<s-picker-item v-for="type in fnTypeArr" :value="type.value">
11-
{{ t(type.label) }}
11+
{{ t("data.fnType." + type.value) }}
1212
</s-picker-item>
1313
</s-picker>
1414

1515
<!-- graphType Picker -->
1616
<s-picker
17-
:label="t('inputs.graphType')"
17+
:label="t('data.main.graphType')"
1818
v-model.lazy="props.self.graphType"
1919
v-show="props.self.graphType !== 'text'"
2020
:key="selectKey"
2121
>
2222
<s-picker-item v-for="type in allowedGraphType" :value="type.value">
23-
{{ t(type.label) }}
23+
{{ t("data.graphType." + type.value) }}
2424
</s-picker-item>
2525
</s-picker>
2626

@@ -37,7 +37,7 @@
3737
>
3838
<SIconDelete />
3939
</s-icon-button>
40-
{{ t("buttons.del") }}
40+
{{ t("data.topButton.delete") }}
4141
</s-tooltip>
4242
<!-- Hide -->
4343
<s-tooltip>
@@ -48,14 +48,14 @@
4848
>
4949
<SIconHide />
5050
</s-icon-button>
51-
{{ t("buttons.hide") }}
51+
{{ t("data.topButton.hide") }}
5252
</s-tooltip>
5353
<!-- Fold -->
5454
<s-tooltip>
5555
<s-icon-button slot="trigger" @click="folded = !folded">
5656
<s-icon :name="folded ? 'chevron_down' : 'chevron_up'"> </s-icon>
5757
</s-icon-button>
58-
{{ t(folded ? "buttons.expand" : "buttons.collapse") }}
58+
{{ t(`data.topButton.${folded ? "more" : "less"}`) }}
5959
</s-tooltip>
6060
<!-- Drag -->
6161
<span class="datablock-drag drag-icon">
@@ -76,7 +76,8 @@
7676
</template>
7777
<script setup lang="ts">
7878
import { useI18n } from "vue-i18n";
79-
const { t, locale } = useI18n();
79+
import { I18nSchema } from "@/i18n";
80+
const { locale, t } = useI18n<{ message: I18nSchema }>();
8081
8182
import { fnTypeArr, getAllowedGraphType } from "../consts";
8283
import { ref, computed, toRef } from "vue";
@@ -114,9 +115,9 @@ function deleteDatum() {
114115
const backup = props.self;
115116
profile.datum.splice(props.index, 1);
116117
Snackbar.builder({
117-
text: t("title.deleteSuccess"),
118+
text: t("editor.delete.success"),
118119
action: {
119-
text: t("buttons.undo"),
120+
text: t("editor.delete.undo"),
120121
click: () => {
121122
profile.datum.splice(props.index, 0, backup);
122123
},

src/editor/dataList.vue

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,16 @@
1717
</VueDraggable>
1818
<div class="plot-data add-data" @click="profile.addData">
1919
<s-icon name="add" />
20-
{{ t("buttons.add") }}
20+
{{ t('editor.add') }}
2121
<s-ripple attached></s-ripple>
2222
</div>
2323
</s-scroll-view>
2424
</template>
2525

2626
<script setup lang="ts">
2727
import { useI18n } from "vue-i18n";
28-
const { t } = useI18n();
28+
import { I18nSchema } from "@/i18n";
29+
const { t } = useI18n<{ message: I18nSchema }>();
2930
3031
import { VueDraggable } from "vue-draggable-plus";
3132

src/editor/import.vue

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,28 +4,31 @@
44
<s-fab slot="trigger">
55
<SIconImport />
66
</s-fab>
7-
{{ t("buttons.import") }}
7+
{{ t("editor.import") }}
88
</s-tooltip>
9-
<div slot="headline" class="dialog-title">{{ t("title.source") }}</div>
9+
<div slot="headline" class="dialog-title">
10+
{{ t("editor.importRelated.title") }}
11+
</div>
1012
<s-text-field
1113
slot="text"
12-
label="JSON5 / JSON"
14+
:label="t('editor.importRelated.placeholder')"
1315
multiLine
1416
v-model.lazy="importStr"
1517
class="monospace"
1618
></s-text-field>
1719
<s-button slot="action" type="text">
18-
{{ t("buttons.cancel") }}
20+
{{ t("editor.importRelated.cancel") }}
1921
</s-button>
2022
<s-button slot="action" type="text" @click="handleImport">
21-
{{ t("buttons.confirm") }}
23+
{{ t("editor.importRelated.confirm") }}
2224
</s-button>
2325
</s-dialog>
2426
</template>
2527

2628
<script setup lang="ts">
2729
import { useI18n } from "vue-i18n";
28-
const { t } = useI18n();
30+
import { I18nSchema } from "@/i18n";
31+
const { t } = useI18n<{ message: I18nSchema }>();
2932
3033
import SIconImport from "@/ui/icons/import.vue";
3134
@@ -59,12 +62,12 @@ function handleImport() {
5962
profile.options = newOptions;
6063
emitter.emit("require-full-update", "Data import");
6164
Snackbar.builder({
62-
text: t("title.importSuccess"),
65+
text: t("editor.importRelated.success"),
6366
type: "success",
6467
});
6568
} catch (e) {
6669
Snackbar.builder({
67-
text: t("title.importFail"),
70+
text: t("editor.importRelated.fail"),
6871
type: "error",
6972
});
7073
}

src/editor/index.vue

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717

1818
<script setup lang="ts">
1919
import { useI18n } from "vue-i18n";
20-
const { t } = useI18n();
20+
import { I18nSchema } from "@/i18n";
21+
const { t } = useI18n<{ message: I18nSchema }>();
2122
2223
import ImportBtn from "./import.vue";
2324
import DataList from "./dataList.vue";
@@ -31,9 +32,9 @@ const currentTab = ref("0");
3132
const currentTabIndex = computed(() => Number(currentTab.value));
3233
const transitionName = ref("");
3334
const tabs = [
34-
{ caption: "title.functions", component: DataList },
35-
{ caption: "title.annotations", component: AnnotaionList },
36-
{ caption: "title.graphOptions", component: GraphOptions },
35+
{ caption: "editor.functions", component: DataList },
36+
{ caption: "editor.annotations", component: AnnotaionList },
37+
{ caption: "editor.graphOptions", component: GraphOptions },
3738
];
3839
watch(currentTabIndex, (newVal, oldVal) => {
3940
if (newVal > oldVal) transitionName.value = "slide-left";

src/editor/inputs/implicit.vue

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323
import { PrivateDataTypes } from "@/types/data";
2424
import { toRef } from "vue";
2525
import { useI18n } from "vue-i18n";
26-
const { t } = useI18n();
26+
import { I18nSchema } from "@/i18n";
27+
const { t } = useI18n<{ message: I18nSchema }>();
2728
2829
import FilledTextfield from "@/editor/inputs/subblocks/function.vue";
2930

src/editor/inputs/linear.vue

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,34 +5,33 @@
55
<filledTextfield class="styled fn" label="f(x)" v-model="self.fn" />
66
</div>
77
<s-fold :folded="props.folded">
8-
<s-divider>{{ t("title.moreOptions") }}</s-divider>
8+
<s-divider>{{ t("data.more.dividerTitle") }}</s-divider>
99
<div class="input-inner-optional">
1010
<div class="fields">
11-
<span class="label">定义域</span>
11+
<span class="label"> {{ t("data.more.range") }} </span>
1212
<Domain :self="self" />
1313
<span class="label">
14-
颜色 <HelpIcon> 支持颜色名称 / RGB(A) / HEX,留空将自动着色 </HelpIcon>
14+
{{ t("data.more.color") }}
15+
<HelpIcon> {{ t("data.more.colorHelp") }} </HelpIcon>
1516
</span>
1617
<ColorPicker v-model="self.color" />
17-
<span class="label"
18-
>采样数 <HelpIcon> 留空则根据图像宽度动态调整 </HelpIcon>
19-
</span>
18+
<span class="label"> {{ t("data.more.nSamples") }} </span>
2019
<s-text-field
21-
class="input monospace"
20+
class="input monospace-inner"
2221
type="number"
23-
label="采样数"
22+
:label="t('data.more.nSamples')"
2423
v-model="self.nSamples"
2524
:min="1"
2625
@blur="if (!self.nSamples) self.nSamples = undefined;"
2726
></s-text-field>
2827
</div>
2928
<div class="switches">
3029
<s-checkbox type="checkbox" v-model.lazy="self.closed">
31-
闭合并填充
30+
{{ t("data.more.closed") }}
3231
</s-checkbox>
3332
<s-checkbox type="checkbox" v-model.lazy="self.skipTip">
34-
隐藏悬浮指示条
35-
<HelpIcon> 隐藏鼠标经过时标出的点与坐标信息 </HelpIcon>
33+
{{ t("data.more.skipTip") }}
34+
<HelpIcon> {{ t("data.more.skipTipHelp") }} </HelpIcon>
3635
</s-checkbox>
3736
</div>
3837
</div>
@@ -44,7 +43,8 @@
4443
import { PrivateDataTypes } from "@/types/data";
4544
import { toRef } from "vue";
4645
import { useI18n } from "vue-i18n";
47-
const { t } = useI18n();
46+
import { I18nSchema } from "@/i18n";
47+
const { t } = useI18n<{ message: I18nSchema }>();
4848
4949
const props = defineProps<{
5050
folded: boolean;

0 commit comments

Comments
 (0)