Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
Merge pull request #114 from R2kip/master
Browse files Browse the repository at this point in the history
Russian lang support
  • Loading branch information
YuMao233 authored Oct 4, 2023
2 parents 9328908 + 7382891 commit 1172cbb
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 3 deletions.
8 changes: 8 additions & 0 deletions src/app/directive/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,12 @@ export default function (app) {
if (language != "en_us") el.style.display = "none";
}
});

app.directive("isru", {
// eslint-disable-next-line no-unused-vars
mounted(el, binding, vnode) {
const language = i18n.global.locale;
if (language != "ru_ru") el.style.display = "none";
}
});
}
6 changes: 4 additions & 2 deletions src/app/i18n.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import { createI18n } from 'vue-i18n'
import zh_cn from "../language/zh_cn.json"
import en_us from "../language/en_us.json"
import ru_ru from "../language/ru_ru.json"

const i18n = createI18n({
locale: 'en_us',
fallbackLocale: 'en_us',
messages: {
zh_cn,
en_us
en_us,
ru_ru
},
})

window.$t = i18n.global.t

export default i18n
export default i18n
5 changes: 4 additions & 1 deletion src/app/utils/lang.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ export function isEN() {
}

export function isCN() {
console.log("L:", i18n);
return i18n.global.locale === "zh_cn";
}

export function isRU() {
return i18n.global.locale === "ru_ru";
}
6 changes: 6 additions & 0 deletions src/app/views/Install/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,10 @@ export default {
{
label: "简体中文",
value: "zh_cn"
},
{
label: "Русский",
value: "ru_ru"
}
],
rules: {
Expand All @@ -136,6 +140,8 @@ export default {
const language = window.navigator.language;
if (language.includes("zh")) {
this.selectLanguage("zh_cn");
} else if (language.includes("ru")) {
this.selectLanguage("ru_ru");
} else {
this.selectLanguage("en_us");
}
Expand Down
3 changes: 3 additions & 0 deletions src/app/views/NewImage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,9 @@ export default {
},
isCN() {
return this.$i18n.locale === "zh_cn";
},
isRU() {
return this.$i18n.locale === "ru_ru";
}
},
methods: {
Expand Down
1 change: 1 addition & 0 deletions src/app/views/Settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
<el-select v-model="settings.language" :placeholder="$t('general.pleaseSelect')">
<el-option label="English" value="en_us"></el-option>
<el-option value="zh_cn" :label="$t('CommonText.011')"></el-option>
<el-option label="Russian" value="ru_ru"></el-option>
<!-- <el-option label="Japanese" value="jp" disabled></el-option> -->
</el-select>
</div>
Expand Down

0 comments on commit 1172cbb

Please sign in to comment.