Skip to content

Commit bbf2e77

Browse files
committed
部署 i18n
1 parent 03c9b48 commit bbf2e77

File tree

11 files changed

+200
-85
lines changed

11 files changed

+200
-85
lines changed

src/App.vue

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,11 @@
2727
"
2828
class="add-data-opt add"
2929
>
30-
+ 添加
30+
+ {{ t("buttons.add") }}
31+
</div>
32+
<div @click="handleImport()" class="add-data-opt import">
33+
↓ {{ t("buttons.import") }}
3134
</div>
32-
<div @click="handleImport()" class="add-data-opt import">↓ 导入</div>
3335
</div>
3436
</div>
3537
<CodeDisplay :dataArr="toOriginalDatum(graphData)" />
@@ -50,6 +52,9 @@
5052
</template>
5153

5254
<script setup lang="ts">
55+
import { useI18n } from 'vue-i18n'
56+
const { t } = useI18n()
57+
5358
import Navbar from "./components/nav.vue";
5459
import Graph from "./components/graph.vue";
5560
import DataBlock from "./components/dataBlock.vue";
@@ -146,6 +151,7 @@ function handleImport() {
146151
#navbar {
147152
height: 50px;
148153
width: 100vw;
154+
box-sizing: border-box;
149155
background: var(--c-bk1);
150156
border-bottom: var(--c-border) 1px solid;
151157
position: relative;

src/components/dataBlock.vue

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<div class="selectors">
55
<select v-model="dataItem.fnType" @change="fnTypeChange(dataItem)">
66
<option v-for="type in fnTypeArr" :value="type.value">
7-
{{ type.label }}
7+
{{ t(type.label) }}
88
</option>
99
</select>
1010
<select
@@ -13,7 +13,7 @@
1313
@change="graphTypeChange(dataItem)"
1414
>
1515
<option v-for="type in allowedGraphType" :value="type.value">
16-
{{ type.label }}
16+
{{ t(type.label) }}
1717
</option>
1818
</select>
1919
<div style="flex-grow: 2"></div>
@@ -22,9 +22,11 @@
2222
:class="{ active: !blockFolded }"
2323
@click="blockFolded = !blockFolded"
2424
>
25-
{{ blockFolded ? "展开" : "收起" }}
25+
{{ t(blockFolded ? "buttons.expand" : "buttons.collapse") }}
26+
</button>
27+
<button class="delete blockBtn" @click="emit('delete')">
28+
{{ t("buttons.del") }}
2629
</button>
27-
<button class="delete blockBtn" @click="emit('delete')">删除</button>
2830
</div>
2931

3032
<div class="inputs">
@@ -61,6 +63,9 @@
6163
</div>
6264
</template>
6365
<script setup lang="ts">
66+
import { useI18n } from 'vue-i18n'
67+
const { t } = useI18n()
68+
6469
import {
6570
fnTypeArr,
6671
getAllowedGraphType,

src/components/dataBlockInner/coordArrInputs.vue

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,19 @@
1212
:key="data.id"
1313
>
1414
<span class="coordarr-drag">☰</span>
15-
<span class="coord-label">{{ fnType.coordArr.label }}</span>
15+
<span class="coord-label">{{
16+
t(fnType.coordArr.label) + fnType.coordArr.fir
17+
}}</span>
1618
<input
1719
type="number"
1820
v-model="data.payload[0]"
19-
:placeholder="fnType.coordArr.placeholder[0]"
21+
:placeholder="t(fnType.coordArr.placeholder[0])"
2022
/>
2123
<span class="coord-label">{{ fnType.coordArr.sep }}</span>
2224
<input
2325
type="number"
2426
v-model="data.payload[1]"
25-
:placeholder="fnType.coordArr.placeholder[1]"
27+
:placeholder="t(fnType.coordArr.placeholder[1])"
2628
/>
2729
<span class="coord-label">{{ fnType.coordArr.fin }}</span>
2830
<span class="coordarr-delete" @click="privateData.splice(index, 1)"
@@ -45,6 +47,9 @@
4547
</template>
4648

4749
<script setup lang="ts">
50+
import { useI18n } from "vue-i18n";
51+
const { t } = useI18n();
52+
4853
import { InputProps } from "../../consts";
4954
import { onMounted, ref, watch } from "vue";
5055
import { VueDraggable } from "vue-draggable-plus";

src/components/dataBlockInner/coordInputs.vue

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,25 +6,28 @@
66
class="input-box coord"
77
:class="{ optional: input.optional }"
88
>
9-
<span class="coord-label">{{ input.label }}</span>
9+
<span class="coord-label">{{ t(input.label) + input.fir }}</span>
1010
<input
1111
type="number"
1212
:value="dataItem[input.value]?.[0] ?? ''"
1313
@input="handleCoordInput(dataItem!, input, 0, $event)"
14-
:placeholder="input.placeholder[0]"
14+
:placeholder="t(input.placeholder[0])"
1515
/>
1616
<span class="coord-label">{{ input.sep }}</span>
1717
<input
1818
type="number"
1919
:value="dataItem[input.value]?.[1] ?? ''"
2020
@input="handleCoordInput(dataItem!, input, 1, $event)"
21-
:placeholder="input.placeholder[1]"
21+
:placeholder="t(input.placeholder[1])"
2222
/>
2323
<span class="coord-label">{{ input.fin }}</span>
2424
</div>
2525
</template>
2626

2727
<script setup lang="ts">
28+
import { useI18n } from "vue-i18n";
29+
const { t } = useI18n();
30+
2831
import { CoordType, InternalDatum, InputProps } from "../../consts";
2932
3033
const { dataItem, fnType } = defineProps<InputProps>();

src/components/dataBlockInner/optInputs.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,22 +4,29 @@
44
v-for="input in fnType.optInput ?? []"
55
class="input-box opt-input optional"
66
>
7-
<span class="coord-label optin-label">{{ input.label }}</span>
7+
<span class="coord-label optin-label">{{ t(input.label) }}</span>
88
<input
99
:type="input.type"
1010
:value="dataItem[input.value] ?? ''"
1111
@input="handleCoordInput(dataItem!, input, $event)"
12-
:placeholder="input.placeholder"
12+
:placeholder="t(input.placeholder ?? '')"
1313
/>
1414
</div>
1515
</template>
1616

1717
<script setup lang="ts">
18+
import { useI18n } from 'vue-i18n'
19+
const { t } = useI18n()
20+
1821
import { InternalDatum, InputProps, OptInput } from "../../consts";
1922
2023
const { dataItem, fnType } = defineProps<InputProps>();
2124
22-
function handleCoordInput(dataItem: InternalDatum, input: OptInput, event: Event) {
25+
function handleCoordInput(
26+
dataItem: InternalDatum,
27+
input: OptInput,
28+
event: Event
29+
) {
2330
const raw = (<HTMLInputElement>event.target).value;
2431
if (raw === "") {
2532
delete dataItem[input.value];

src/components/dataBlockInner/strInputs.vue

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,18 @@
11
<template>
22
<div v-for="input in fnType.inputs" class="input-box">
3-
<span class="input-title">{{ input.title }}</span>
3+
<span class="input-title">{{ t(input.title) }}</span>
44
<input
55
type="text"
66
v-model="dataItem[input.value]"
7-
:placeholder="input.placeholder"
7+
:placeholder="t(input.placeholder)"
88
/>
99
</div>
1010
</template>
1111

1212
<script setup lang="ts">
13+
import { useI18n } from 'vue-i18n'
14+
const { t } = useI18n()
15+
1316
import { InputProps } from "../../consts";
1417
const { dataItem, fnType } = defineProps<InputProps>();
1518
</script>

src/components/dataBlockInner/switchInputs.vue

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@
1414
class="switch"
1515
:class="dataItem[input.value] ? 'on' : 'off'"
1616
></button>
17-
{{ input.label }}
17+
{{ t(input.label) }}
1818
</div>
1919
</template>
2020

2121
<script setup lang="ts">
22+
import { useI18n } from 'vue-i18n'
23+
const { t } = useI18n()
24+
2225
import { InputProps } from "../../consts";
2326
2427
const { dataItem, fnType } = defineProps<InputProps>();

src/components/graph.vue

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
<template>
22
<div id="graphRender" ref="plotRef"></div>
3-
<button id="refresh" @click="emit('requireFullUpdate')">重置</button>
3+
<button id="refresh" @click="emit('requireFullUpdate')">
4+
{{ t("buttons.reset") }}
5+
</button>
46
</template>
57

68
<script setup lang="ts">
9+
import { useI18n } from 'vue-i18n'
10+
const { t } = useI18n()
11+
712
import { onMounted, ref, watch } from "vue";
813
import { cloneDeep, throttle } from "lodash-es";
914
import type { FunctionPlotDatum } from "function-plot";

src/components/nav.vue

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,23 +2,28 @@
22
<div id="navbar">
33
<span class="nav-title">
44
function-plot-GUI <span class="version"> v0.2 · </span>
5-
<a class="link" href="https://github.com/Linho1219/function-plot-GUI" target="_blank"
5+
<a
6+
class="link"
7+
href="https://github.com/Linho1219/function-plot-GUI"
8+
target="_blank"
69
>Github</a
710
>
811
</span>
12+
<div class="grow"></div>
13+
<select v-model="locale">
14+
<option value="zh-CN">简体中文</option>
15+
<option value="en-US">English</option>
16+
</select>
917
</div>
1018
</template>
1119

20+
<script setup lang="ts">
21+
import { useI18n } from "vue-i18n";
22+
const { locale } = useI18n();
23+
</script>
24+
1225
<style>
1326
.nav-title {
14-
display: block;
15-
position: absolute;
16-
top: 0;
17-
bottom: 0;
18-
left: 15px;
19-
height: fit-content;
20-
text-align: left;
21-
margin: auto;
2227
font-size: 20px;
2328
font-weight: bold;
2429
}
@@ -36,4 +41,11 @@
3641
opacity: 0.8;
3742
text-decoration: underline;
3843
}
44+
45+
#navbar {
46+
display: flex;
47+
justify-content: space-between;
48+
align-items: center;
49+
padding: 0 15px;
50+
}
3951
</style>

0 commit comments

Comments
 (0)