Skip to content

Commit 37dcd7c

Browse files
authored
Merge pull request #683 from terwer/dev
refactor(i18n): migrate i18n to json format and update configurations
2 parents d23e3c4 + ef9b3f9 commit 37dcd7c

File tree

12 files changed

+1988
-1323
lines changed

12 files changed

+1988
-1323
lines changed

apps/app/components/static/HomePage.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import { useStaticSettingStore } from "~/stores/useStaticSettingStore"
1515
// 由于布局是个宏,不能动态设置了,因此只能写死
1616
1717
const { t } = useI18n()
18+
1819
const { getStaticSetting } = useStaticSettingStore()
1920
2021
const setting = await getStaticSetting()

apps/app/i18n.ts

Lines changed: 0 additions & 24 deletions
This file was deleted.
Lines changed: 3 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,5 @@
1-
/*
2-
* Copyright (c) 2023, Terwer . All rights reserved.
3-
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4-
*
5-
* This code is free software; you can redistribute it and/or modify it
6-
* under the terms of the GNU General Public License version 2 only, as
7-
* published by the Free Software Foundation. Terwer designates this
8-
* particular file as subject to the "Classpath" exception as provided
9-
* by Terwer in the LICENSE file that accompanied this code.
10-
*
11-
* This code is distributed in the hope that it will be useful, but WITHOUT
12-
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13-
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14-
* version 2 for more details (a copy is included in the LICENSE file that
15-
* accompanied this code).
16-
*
17-
* You should have received a copy of the GNU General Public License version
18-
* 2 along with this work; if not, write to the Free Software Foundation,
19-
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20-
*
21-
* Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
22-
* or visit www.terwer.space if you need additional information or have any
23-
* questions.
24-
*/
25-
26-
export default {
27-
name: "Share to web",
1+
{
2+
"name": "Share to web",
283
"lang.choose": "Choose lang",
294
"lang.choose.placeholder": "Please select language",
305
"syp.about": "About me",
@@ -115,5 +90,5 @@ export default {
11590
"page.sidebar.collapse.all": "Collapse all",
11691

11792
"static.docTree": "Document menu",
118-
"static.outline": "Document outline",
93+
"static.outline": "Document outline"
11994
}
Lines changed: 6 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,9 @@
1-
/*
2-
* Copyright (c) 2023, Terwer . All rights reserved.
3-
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4-
*
5-
* This code is free software; you can redistribute it and/or modify it
6-
* under the terms of the GNU General Public License version 2 only, as
7-
* published by the Free Software Foundation. Terwer designates this
8-
* particular file as subject to the "Classpath" exception as provided
9-
* by Terwer in the LICENSE file that accompanied this code.
10-
*
11-
* This code is distributed in the hope that it will be useful, but WITHOUT
12-
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13-
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14-
* version 2 for more details (a copy is included in the LICENSE file that
15-
* accompanied this code).
16-
*
17-
* You should have received a copy of the GNU General Public License version
18-
* 2 along with this work; if not, write to the Free Software Foundation,
19-
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20-
*
21-
* Please contact Terwer, Shenzhen, Guangdong, China, youweics@163.com
22-
* or visit www.terwer.space if you need additional information or have any
23-
* questions.
24-
*/
25-
26-
export default {
27-
name: "在线分享",
1+
{
2+
"name": "在线分享",
283
"lang.choose": "语言选择",
294
"lang.choose.placeholder": "请选择语言",
305
"syp.about": "关于作者",
31-
"syp.about.desc":
32-
"你们好,我叫 terwer,已在后端行业多年,主要专注于后端技术栈的探索。希望能认识更多朋友。欢迎大家留言交流。",
6+
"syp.about.desc": "你们好,我叫 terwer,已在后端行业多年,主要专注于后端技术栈的探索。希望能认识更多朋友。欢迎大家留言交流。",
337
"theme.mode.choose": "切换模式",
348
"theme.mode.dark": "暗黑模式",
359
"theme.mode.light": "浅色模式",
@@ -64,8 +38,7 @@ export default {
6438
"blog.share.setting": "分享设置",
6539
"blog.site.url.label": "自定义域名",
6640
"blog.site.url": "自定义域名",
67-
"blog.site.url.placeholder":
68-
"请填写完整地址(如有端口,需要包括端口),需确保域名已经解析,例如:http://siyuan.terwergreen.com:6808",
41+
"blog.site.url.placeholder": "请填写完整地址(如有端口,需要包括端口),需确保域名已经解析,例如:http://siyuan.terwergreen.com:6808",
6942
"blog.site.title.label": "主页标题",
7043
"blog.site.title": "浅海拾贝",
7144
"blog.site.slogan.label": "主页副标题",
@@ -98,17 +71,14 @@ export default {
9871
"change.ip.title": "切换IP",
9972
"share.accessCodeEnabled.tip": "特别提示:为安全起见,1.9.0+ 将使用静态分享,若文档有更新,需重新分享,请知悉。",
10073
"share.public.tip": "当前处于公共分享模式",
101-
"share.static.tip":
102-
"温馨提示:如果无法访问可通过切换IP(PC)、或者在下方「偏好设置->设置自定义域名」(PC、Docker)解决,外网访问需在「设置->关于->网络伺服」打开伺服",
74+
"share.static.tip": "温馨提示:如果无法访问可通过切换IP(PC)、或者在下方「偏好设置->设置自定义域名」(PC、Docker)解决,外网访问需在「设置->关于->网络伺服」打开伺服",
10375
"share.setting": "偏好设置",
10476
"share.template.footer": "底部信息",
10577
"share.template.footer.placeholder": "留空则不显示底部,支持 HTML。更新需重新分享",
10678
"share.template.link": "分享模板",
10779
"share.template.link.placeholder": "分享出去的提示信息模板,支持占位符 [title] [url] [expired]",
108-
10980
"page.sidebar.expand.all": "展开全部",
11081
"page.sidebar.collapse.all": "折叠全部",
111-
11282
"static.docTree": "文档树",
113-
"static.outline": "文档大纲",
83+
"static.outline": "文档大纲"
11484
}

apps/app/nuxt.cloudflare.config.ts

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ export default defineNuxtConfig({
2323
modules: ["@nuxtjs/i18n", "@element-plus/nuxt", "@pinia/nuxt", "@element-plus/nuxt"],
2424

2525
i18n: {
26-
locales: ["en_US", "zh_CN"],
2726
defaultLocale: "zh_CN",
27+
locales: [
28+
{ code: "en_US", name: "English", file: "en_US.json" },
29+
{ code: "zh_CN", name: "Chinese", file: "zh_CN.json" }
30+
],
2831
strategy: "no_prefix",
2932
detectBrowserLanguage: false,
30-
vueI18n: "./i18n.ts"
3133
},
3234

3335
app: {
@@ -61,26 +63,18 @@ export default defineNuxtConfig({
6163
src: appBase + "libs/eruda/eruda.js",
6264
},
6365
{
64-
children: "eruda.init();console.log('eruda inited');",
66+
children: "eruda.init();console.log('eruda inited');" ,
6567
} as any,
6668
{
6769
defer: true,
6870
src: appBase + "libs/katex/0.16.10/katex.min.js",
6971
},
70-
{
71-
defer: true,
72-
src: appBase + "resources/stage/protyle/js/echarts/echarts.min.js",
73-
},
7472
]
7573
: [
7674
{
7775
defer: true,
7876
src: appBase + "libs/katex/0.16.10/katex.min.js",
7977
},
80-
{
81-
defer: true,
82-
src: appBase + "resources/stage/protyle/js/echarts/echarts.min.js",
83-
},
8478
],
8579
},
8680
},

apps/app/nuxt.config.ts

Lines changed: 32 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const generateDynamicV = () => {
1313
}
1414

1515
const isDev = process.env.NODE_ENV === "development"
16-
const appBase = "/plugins/siyuan-blog/app/"
16+
const appBase = "/"
1717
const staticV = generateDynamicV()
1818

1919
// https://nuxt.com/docs/api/configuration/nuxt-config
@@ -23,42 +23,13 @@ export default defineNuxtConfig({
2323
modules: ["@nuxtjs/i18n", "@element-plus/nuxt", "@pinia/nuxt", "@element-plus/nuxt"],
2424

2525
i18n: {
26-
locales: ["en_US", "zh_CN"],
2726
defaultLocale: "zh_CN",
27+
locales: [
28+
{ code: "en_US", name: "English", file: "en_US.json" },
29+
{ code: "zh_CN", name: "Chinese", file: "zh_CN.json" }
30+
],
2831
strategy: "no_prefix",
2932
detectBrowserLanguage: false,
30-
vueI18n: "./i18n.ts"
31-
},
32-
33-
// https://nuxt.com/docs/guide/going-further/custom-routing#hash-mode-spa
34-
ssr: false,
35-
router: {
36-
options: {
37-
hashMode: true,
38-
},
39-
},
40-
41-
vite: {
42-
define: {
43-
"process.env.DEV_MODE": `"${isDev}"`,
44-
"process.env.APP_BASE": `"${appBase}"`,
45-
"process.env.SSR": "\"false\"",
46-
},
47-
plugins: [
48-
AutoImport({
49-
resolvers: [ElementPlusResolver()],
50-
}),
51-
Components({
52-
resolvers: [ElementPlusResolver()],
53-
}),
54-
]
55-
},
56-
57-
css: ["~/assets/css/index.styl"],
58-
59-
elementPlus: {
60-
/** Options */
61-
themes: ["dark"],
6233
},
6334

6435
app: {
@@ -116,13 +87,36 @@ export default defineNuxtConfig({
11687
},
11788
},
11889

90+
vite: {
91+
define: {
92+
"process.env.DEV_MODE": `"${isDev}"`,
93+
"process.env.APP_BASE": `"${appBase}"`,
94+
"process.env.SSR": "\"true\"",
95+
},
96+
plugins: [
97+
AutoImport({
98+
resolvers: [ElementPlusResolver()],
99+
}),
100+
Components({
101+
resolvers: [ElementPlusResolver()],
102+
}),
103+
]
104+
},
105+
106+
css: ["~/assets/css/index.styl"],
107+
108+
elementPlus: {
109+
/** Options */
110+
themes: ["dark"],
111+
},
112+
119113
// 环境变量
120114
runtimeConfig: {
121115
public: {
122-
defaultType: "siyuan",
123-
siyuanApiUrl: "",
124-
providerMode: "false",
125-
providerUrl: "",
116+
defaultType: process.env.NUXT_PUBLIC_DEFAULT_TYPE ?? "node",
117+
siyuanApiUrl: process.env.NUXT_PUBLIC_SIYUAN_API_URL ?? "http://127.0.0.1:6806",
118+
providerMode: process.env.NUXT_PUBLIC_PROVIDER_MODE ?? "false",
119+
providerUrl: process.env.NUXT_PUBLIC_PROVIDER_URL ?? "http://127.0.0.1:8086",
126120
},
127121
},
128122

apps/app/nuxt.node.config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ export default defineNuxtConfig({
2323
modules: ["@nuxtjs/i18n", "@element-plus/nuxt", "@pinia/nuxt", "@element-plus/nuxt"],
2424

2525
i18n: {
26-
locales: ["en_US", "zh_CN"],
2726
defaultLocale: "zh_CN",
27+
locales: [
28+
{ code: "en_US", name: "English", file: "en_US.json" },
29+
{ code: "zh_CN", name: "Chinese", file: "zh_CN.json" }
30+
],
2831
strategy: "no_prefix",
2932
detectBrowserLanguage: false,
30-
vueI18n: "./i18n.ts"
3133
},
3234

3335
app: {

apps/app/nuxt.siyuan.config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ export default defineNuxtConfig({
2323
modules: ["@nuxtjs/i18n", "@element-plus/nuxt", "@pinia/nuxt", "@element-plus/nuxt"],
2424

2525
i18n: {
26-
locales: ["en_US", "zh_CN"],
2726
defaultLocale: "zh_CN",
27+
locales: [
28+
{ code: "en_US", name: "English", file: "en_US.json" },
29+
{ code: "zh_CN", name: "Chinese", file: "zh_CN.json" }
30+
],
2831
strategy: "no_prefix",
2932
detectBrowserLanguage: false,
30-
vueI18n: "./i18n.ts"
3133
},
3234

3335
// https://nuxt.com/docs/guide/going-further/custom-routing#hash-mode-spa

apps/app/nuxt.vercel.config.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ export default defineNuxtConfig({
2323
modules: ["@nuxtjs/i18n", "@element-plus/nuxt", "@pinia/nuxt", "@element-plus/nuxt"],
2424

2525
i18n: {
26-
locales: ["en_US", "zh_CN"],
2726
defaultLocale: "zh_CN",
27+
locales: [
28+
{ code: "en_US", name: "English", file: "en_US.json" },
29+
{ code: "zh_CN", name: "Chinese", file: "zh_CN.json" }
30+
],
2831
strategy: "no_prefix",
2932
detectBrowserLanguage: false,
30-
vueI18n: "./i18n.ts"
3133
},
3234

3335
app: {

apps/app/package.json

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@terwer/share-pro-app",
33
"type": "module",
4-
"version": "6.5.0",
4+
"version": "6.4.0",
55
"scripts": {
66
"dev": "bash script/dev.sh",
77
"build": "bash script/build.sh",
@@ -11,31 +11,31 @@
1111
},
1212
"dependencies": {
1313
"@element-plus/icons-vue": ">=0.2.6",
14-
"@element-plus/nuxt": "^1.1.3",
15-
"@nuxtjs/i18n": "9.5.5",
16-
"@pinia/nuxt": "^0.11.1",
14+
"@element-plus/nuxt": "1.1.4",
15+
"@nuxtjs/i18n": "^10.0.1",
16+
"@pinia/nuxt": "^0.11.2",
1717
"@popperjs/core": "npm:@sxzz/popperjs-es@^2.11.7",
18-
"@vueuse/core": "^13.3.0",
19-
"cheerio": "^1.1.0",
18+
"@vueuse/core": "^13.5.0",
19+
"cheerio": "^1.1.1",
2020
"dayjs": "^1.11.13",
2121
"element-plus": ">=2",
2222
"highlight.js": "11.7.0",
2323
"js-base64": "^3.7.7",
2424
"lodash-unified": "^1.0.3",
25-
"nuxt": "3.17.5",
25+
"nuxt": "^3.16.0",
2626
"pinia": "^3.0.3",
27-
"vue": "^3.5.16",
27+
"vue": "^3.5.17",
2828
"vue-easy-lightbox": "^1.19.0",
2929
"vue-router": "4.5.1",
3030
"zhi-common": "^1.34.1",
3131
"zhi-device": "^2.12.0",
3232
"zhi-lib-base": "^0.8.0"
3333
},
3434
"devDependencies": {
35-
"@rushstack/eslint-patch": "^1.11.0",
35+
"@rushstack/eslint-patch": "^1.12.0",
3636
"stylus": "^0.64.0",
3737
"unplugin-auto-import": "^19.3.0",
38-
"unplugin-vue-components": "^28.7.0",
39-
"vite": "^6.3.4"
38+
"unplugin-vue-components": "^28.8.0",
39+
"vite": "^5.4.19"
4040
}
4141
}

0 commit comments

Comments
 (0)