Skip to content

Commit 9c0e8d8

Browse files
Merge pull request flipped-aurora#857 from MohamedHassanNasr/i18n-dev
Initial multi language (Chinese - English - Arabic). Updated Axios from 0.19.2 to 0.24.0 to fix vulnerability exist in this version.
2 parents 9fe1d7d + 3f92974 commit 9c0e8d8

File tree

13 files changed

+384
-117
lines changed

13 files changed

+384
-117
lines changed

web/limit.js

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,34 +4,34 @@ const path = require('path')
44
const wfPath = path.resolve(__dirname, './node_modules/.bin')
55

66
fs.readdir(wfPath, (err, files) => {
7-
if (err) {
8-
console.log(err)
9-
} else {
10-
if (files.length != 0) {
11-
files.forEach((item) => {
12-
if (item.split('.')[1] === 'cmd') {
13-
replaceStr(`${wfPath}/${item}`, /"%_prog%"/, '%_prog%')
14-
}
15-
})
7+
if (err) {
8+
console.log(err)
9+
} else {
10+
if (files.length != 0) {
11+
files.forEach((item) => {
12+
if (item.split('.')[1] === 'cmd') {
13+
replaceStr(`${wfPath}/${item}`, /"%_prog%"/, '%_prog%')
1614
}
15+
})
1716
}
17+
}
1818
})
1919

2020
// 参数:[文件路径、 需要修改的字符串、修改后的字符串] (替换对应文件内字符串的公共函数)
2121
function replaceStr(filePath, sourceRegx, targetSrt) {
22-
fs.readFile(filePath, (err, data) => {
22+
fs.readFile(filePath, (err, data) => {
23+
if (err) {
24+
console.log(err)
25+
} else {
26+
let str = data.toString()
27+
str = str.replace(sourceRegx, targetSrt)
28+
fs.writeFile(filePath, str, (err) => {
2329
if (err) {
24-
console.log(err)
30+
console.log(err)
2531
} else {
26-
let str = data.toString()
27-
str = str.replace(sourceRegx, targetSrt)
28-
fs.writeFile(filePath, str, (err) => {
29-
if(err){
30-
console.log(err)
31-
}else{
32-
console.log("\x1B[42m%s\x1B[0m","文件修改成功")
33-
}
34-
})
32+
console.log('\x1B[42m%s\x1B[0m', '文件修改成功')
3533
}
36-
})
37-
}
34+
})
35+
}
36+
})
37+
}

web/package.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
},
1212
"dependencies": {
1313
"@element-plus/icons": "0.0.11",
14-
"axios": "^0.19.2",
14+
"axios": "^0.24.0",
1515
"core-js": "^3.6.5",
1616
"echarts": "4.9.0",
1717
"element-plus": "1.2.0-beta.6",
@@ -25,11 +25,13 @@
2525
"script-ext-html-webpack-plugin": "^2.1.4",
2626
"spark-md5": "^3.0.1",
2727
"vue": "^3.2.25",
28+
"vue-i18n": "^9.2.0-beta.25",
2829
"vue-router": "^4.0.0-0",
2930
"vuex": "^4.0.0-0",
3031
"vuex-persist": "^2.1.0"
3132
},
3233
"devDependencies": {
34+
"@intlify/vite-plugin-vue-i18n": "^3.2.1",
3335
"@vitejs/plugin-legacy": "^1.4.4",
3436
"@vitejs/plugin-vue": "latest",
3537
"@vue/cli-plugin-babel": "~4.5.0",
@@ -50,4 +52,4 @@
5052
"vite-plugin-banner": "^0.1.3",
5153
"vite-plugin-importer": "^0.2.5"
5254
}
53-
}
55+
}

web/src/assets/flags/cn.svg

Lines changed: 1 addition & 0 deletions
Loading

web/src/assets/flags/eg.svg

Lines changed: 78 additions & 0 deletions
Loading

web/src/assets/flags/us.svg

Lines changed: 1 addition & 0 deletions
Loading

web/src/i18n.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { createI18n as _createI18n } from 'vue-i18n'
2+
import en from './locales/en.json'
3+
import cn from './locales/cn.json'
4+
import ar from './locales/ar.json'
5+
6+
// const messageImports = import.meta.glob('./locales/*.json')
7+
// console.log(messageImports)
8+
9+
export const SUPPORT_LOCALES = ['en', 'cn', 'ar']
10+
11+
export function createI18n() {
12+
return _createI18n({
13+
legacy: false,
14+
globalInjection: true,
15+
locale: 'en',
16+
fallbackLocale: 'en',
17+
messages: {
18+
en,
19+
cn,
20+
ar
21+
}
22+
})
23+
}

web/src/locales/ar.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"login": {
3+
"entUserName": "أدخل إسم المستخدم",
4+
"entPassword": "أدخل كلمة المرور",
5+
"entVerificationCode": "أدخل رمز التأكيد",
6+
"login": "الدخول للنظام",
7+
"init": "التهيئة",
8+
"errUserName": "إدخل إسم مستخدم صحيح",
9+
"errPassword": "إدخل كلمة مرور صحيحة",
10+
"errVerificationCode": "رمز تأكيد خطاء",
11+
"errLogin": "من فضلك إدخل بيانات دخول صحيحة",
12+
"errInit" : "تم تهية قاعدة البيانات مسبقا، لاداعى للتهيئة مجددا",
13+
"language": "Languages"
14+
},
15+
"init": {
16+
"note": "إشعار التهيئة",
17+
"note1": "1.يجب ان تكون على دراية بإستخدام GoLang و Vue.",
18+
"note2": "2.من فضلك تأكد من قرءاة ",
19+
"note3": "3.Please confirm that you understand the subsequent configuration process.",
20+
"note4": "Note: The development team does not provide free services for the content written in the document.",
21+
"readDocs": "قرأة الإرشادات",
22+
"confirm": "تأكيد"
23+
},
24+
"pages": {
25+
"home": {
26+
"title": "Home",
27+
"count": "count is: {value}",
28+
"virtual": "msg from virtual module: {msg}",
29+
"inter": "this will be styled with a font-face"
30+
},
31+
"about": {
32+
"title": "About"
33+
}
34+
}
35+
}

web/src/locales/cn.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"login": {
3+
"entUserName": "请输入用户名",
4+
"entPassword": "请输入密码",
5+
"entVerificationCode": "请输入验证码",
6+
"login": "登 录",
7+
"init": "前往初始化",
8+
"errUserName": "请输入正确的用户名",
9+
"errPassword": "请输入正确的密码",
10+
"errVerificationCode": "验证码格式不正确",
11+
"errLoging": "请正确填写登录信息",
12+
"errInit" : "已配置数据库信息,无法初始化",
13+
"language": "Languages"
14+
},
15+
"init": {
16+
"note": "初始化须知",
17+
"note1": "1.您需有用一定的VUE和GOLANG基础",
18+
"note2": "2.请您确认是否已经阅读过官方文档",
19+
"note3": "3.请您确认是否了解后续的配置流程",
20+
"note4": "注:开发组不为文档中书写过的内容提供无偿服务",
21+
"readDocs": "阅读文档",
22+
"confirm": "我已确认"
23+
},
24+
"pages": {
25+
"home": {
26+
"title": "Home",
27+
"count": "count is: {value}",
28+
"virtual": "msg from virtual module: {msg}",
29+
"inter": "this will be styled with a font-face"
30+
},
31+
"about": {
32+
"title": "About"
33+
}
34+
}
35+
}

web/src/locales/en.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"login": {
3+
"entUserName": "Please enter username",
4+
"entPassword": "Please enter the password",
5+
"entVerificationCode": "Please enter verification code",
6+
"login": "Login",
7+
"init": "Go to initialization",
8+
"errUserName": "Please enter the correct username",
9+
"errPassword": "Please enter the correct password",
10+
"errVerificationCode": "Incorrect verification code",
11+
"errLogin": "Please fill in the login information correctly",
12+
"errInit" : "Database information has been configured and cannot be initialized",
13+
"language": "Languages"
14+
},
15+
"init": {
16+
"note": "Initialization notice",
17+
"note1": "1.You should be familiar with Vue AND GoLang.",
18+
"note2": "2.Please confirm that you have read the official documents.",
19+
"note3": "3.Please confirm that you understand the subsequent configuration process.",
20+
"note4": "Note: The development team does not provide free services for the content written in the document.",
21+
"readDocs": "Read the documentation",
22+
"confirm": "I confirm"
23+
},
24+
"pages": {
25+
"home": {
26+
"title": "Home",
27+
"count": "count is: {value}",
28+
"virtual": "msg from virtual module: {msg}",
29+
"inter": "this will be styled with a font-face"
30+
},
31+
"about": {
32+
"title": "About"
33+
}
34+
}
35+
}

web/src/main.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import './core/gin-vue-admin'
99
import router from '@/router/index'
1010
import run from '@/core/gin-vue-admin.js'
1111
import auth from '@/directive/auth'
12+
import { createI18n } from './i18n' // added by mohamed hassan to multilangauge
1213

1314
import '@/permission'
1415
import { store } from '@/store/index'
@@ -17,6 +18,10 @@ import App from './App.vue'
1718
const app = createApp(App)
1819
app.config.productionTip = false
1920

21+
const i18n = createI18n() // added by mohamed hassan to multilangauge
22+
23+
app.use(i18n)
24+
2025
app.use(run)
2126
.use(auth)
2227
.use(store)

web/src/view/init/index.vue

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,18 @@
33
<div class="init_page_panle">
44
<div v-if="hello < 2" id="hello" :class="[hello < 1 ? 'slide-in-fwd-top' : 'slide-out-right']" class="hello ">
55
<div>
6-
<div class="hello_title">GIN-VUE-ADMIN</div>
7-
<p class="in-two a-fadeinT">初始化须知</p>
8-
<p class="init_p">1.您需有用一定的VUE和GOLANG基础</p>
9-
<p class="init_p">2.请您确认是否已经阅读过官方文档</p>
10-
<p class="init_p">3.请您确认是否了解后续的配置流程</p>
11-
<p class="init_p">注:开发组不为文档中书写过的内容提供无偿服务</p>
6+
<div class="hello_title">{{ $GIN_VUE_ADMIN.appName }}</div>
7+
<p class="in-two a-fadeinT">{{ $t('init.note') }}</p>
8+
<p class="init_p">{{ $t('init.note1') }}</p>
9+
<p class="init_p">{{ $t('init.note2') }}</p>
10+
<p class="init_p">{{ $t('init.note3') }}</p>
11+
<p class="init_p">{{ $t('init.note4') }}</p>
1212
<p class="init_btn">
1313
<el-button type="primary" @click="goDoc">
14-
阅读文档
14+
{{ $t('init.readDocs') }}
1515
</el-button>
1616
<el-button type="primary" @click="showNext">
17-
我已确认
17+
{{ $t('init.confirm') }}
1818
</el-button>
1919
</p>
2020
</div>

0 commit comments

Comments
 (0)