mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2025-09-06 19:51:15 +00:00
Finished Chinese Simplified and Traditional translation
This commit is contained in:
@@ -0,0 +1,86 @@
|
||||
<script>
|
||||
import LocaleText from "@/components/text/localeText.vue";
|
||||
import {fetchGet, fetchPost} from "@/utilities/fetch.js";
|
||||
import {DashboardConfigurationStore} from "@/stores/DashboardConfigurationStore.js";
|
||||
|
||||
export default {
|
||||
name: "dashboardLanguage",
|
||||
components: {LocaleText},
|
||||
setup(){
|
||||
const store = DashboardConfigurationStore()
|
||||
return {store}
|
||||
},
|
||||
data(){
|
||||
return {
|
||||
languages: undefined
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
fetchGet("/api/locale/available", {}, (res) => {
|
||||
this.languages = res.data;
|
||||
})
|
||||
},
|
||||
methods: {
|
||||
changeLanguage(lang_id){
|
||||
fetchPost("/api/locale/update", {
|
||||
lang_id: lang_id
|
||||
}, (res) => {
|
||||
if (res.status){
|
||||
this.store.Configuration.Server.dashboard_language = lang_id;
|
||||
this.store.Locale = res.data
|
||||
}else{
|
||||
this.store.newMessage("Server", "Dashboard language update failed", "danger")
|
||||
}
|
||||
})
|
||||
}
|
||||
},
|
||||
computed:{
|
||||
currentLanguage(){
|
||||
let lang = this.store.Configuration.Server.dashboard_language;
|
||||
return this.languages.find(x => x.lang_id === lang)
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<div class="card mb-4 shadow rounded-3">
|
||||
<p class="card-header">
|
||||
<LocaleText t="Dashboard Language"></LocaleText>
|
||||
</p>
|
||||
<div class="card-body d-flex gap-2">
|
||||
<div class="dropdown w-100">
|
||||
<button class="btn bg-primary-subtle text-primary-emphasis dropdown-toggle w-100 rounded-3"
|
||||
:disabled="!this.languages"
|
||||
type="button" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<LocaleText t="Loading..." v-if="!this.languages"></LocaleText>
|
||||
<span v-else>
|
||||
{{ currentLanguage?.lang_name_localized }}
|
||||
</span>
|
||||
|
||||
</button>
|
||||
<ul class="dropdown-menu rounded-3 shadow" style="width: 500px">
|
||||
<li v-for="x in this.languages">
|
||||
<a class="dropdown-item d-flex align-items-center" role="button"
|
||||
@click="this.changeLanguage(x.lang_id)"
|
||||
>
|
||||
<p class="me-auto mb-0">
|
||||
{{ x.lang_name_localized }}
|
||||
<small class="d-block" style="font-size: 0.8rem">
|
||||
{{ x.lang_name }}
|
||||
</small>
|
||||
</p>
|
||||
<i class="bi bi-check text-primary fs-5"
|
||||
|
||||
v-if="currentLanguage?.lang_id === x.lang_id"></i>
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
|
||||
</style>
|
@@ -14,7 +14,7 @@ import {DashboardConfigurationStore} from "@/stores/DashboardConfigurationStore.
|
||||
import {fetchGet} from "@/utilities/fetch.js";
|
||||
|
||||
let Locale;
|
||||
await fetch("/api/locale").then(res => res.json()).then(res => Locale = JSON.parse(res.data))
|
||||
await fetch("/api/locale").then(res => res.json()).then(res => Locale = res.data)
|
||||
|
||||
|
||||
const app = createApp(App)
|
||||
@@ -29,5 +29,7 @@ pinia.use(({ store }) => {
|
||||
app.use(pinia)
|
||||
|
||||
const store = DashboardConfigurationStore()
|
||||
window.Locale = Locale;
|
||||
// window.Locale = Locale;
|
||||
|
||||
store.Locale = Locale;
|
||||
app.mount('#app')
|
@@ -1,12 +1,16 @@
|
||||
import {DashboardConfigurationStore} from "@/stores/DashboardConfigurationStore.js";
|
||||
|
||||
export const GetLocale = (key) => {
|
||||
if (window.Locale === null)
|
||||
const store = DashboardConfigurationStore()
|
||||
|
||||
if (store.Locale === null)
|
||||
return key
|
||||
const reg = Object.keys(window.Locale)
|
||||
const reg = Object.keys(store.Locale)
|
||||
const match = reg.filter(x => {
|
||||
return key.match(new RegExp('^' + x + '$', 'gi')) !== null
|
||||
})
|
||||
if (match.length === 0 || match.length > 1){
|
||||
return key
|
||||
}
|
||||
return key.replace(new RegExp(match[0], 'gi'), window.Locale[match[0]])
|
||||
return key.replace(new RegExp(match[0], 'gi'), store.Locale[match[0]])
|
||||
}
|
@@ -1,5 +1,4 @@
|
||||
<script>
|
||||
import {wgdashboardStore} from "@/stores/wgdashboardStore.js";
|
||||
import {DashboardConfigurationStore} from "@/stores/DashboardConfigurationStore.js";
|
||||
import PeersDefaultSettingsInput from "@/components/settingsComponent/peersDefaultSettingsInput.vue";
|
||||
import {ipV46RegexCheck} from "@/utilities/ipCheck.js";
|
||||
@@ -13,11 +12,13 @@ import DashboardSettingsInputIPAddressAndPort
|
||||
import DashboardAPIKeys from "@/components/settingsComponent/dashboardAPIKeys.vue";
|
||||
import AccountSettingsMFA from "@/components/settingsComponent/accountSettingsMFA.vue";
|
||||
import LocaleText from "@/components/text/localeText.vue";
|
||||
import DashboardLanguage from "@/components/settingsComponent/dashboardLanguage.vue";
|
||||
|
||||
export default {
|
||||
name: "settings",
|
||||
methods: {ipV46RegexCheck},
|
||||
components: {
|
||||
DashboardLanguage,
|
||||
LocaleText,
|
||||
AccountSettingsMFA,
|
||||
DashboardAPIKeys,
|
||||
@@ -39,14 +40,15 @@ export default {
|
||||
<LocaleText t="Settings"></LocaleText>
|
||||
</h3>
|
||||
<DashboardTheme></DashboardTheme>
|
||||
<DashboardLanguage></DashboardLanguage>
|
||||
<div class="card mb-4 shadow rounded-3">
|
||||
<p class="card-header">
|
||||
<LocaleText t="Peers Default Settings"></LocaleText>
|
||||
</p>
|
||||
<div class="card-body">
|
||||
<PeersDefaultSettingsInput targetData="peer_global_dns" title="DNS"></PeersDefaultSettingsInput>
|
||||
<PeersDefaultSettingsInput targetData="peer_endpoint_allowed_ip" title="Peer Endpoint Allowed IPs"></PeersDefaultSettingsInput>
|
||||
<PeersDefaultSettingsInput targetData="peer_mtu" title="MTU (Max Transmission Unit)"></PeersDefaultSettingsInput>
|
||||
<PeersDefaultSettingsInput targetData="peer_endpoint_allowed_ip" title="Endpoint Allowed IPs"></PeersDefaultSettingsInput>
|
||||
<PeersDefaultSettingsInput targetData="peer_mtu" title="MTU"></PeersDefaultSettingsInput>
|
||||
<PeersDefaultSettingsInput targetData="peer_keep_alive" title="Persistent Keepalive"></PeersDefaultSettingsInput>
|
||||
<PeersDefaultSettingsInput targetData="remote_endpoint" title="Peer Remote Endpoint"
|
||||
:warning="true" warningText="This will be changed globally, and will be apply to all peer's QR code and configuration file."
|
||||
|
Reference in New Issue
Block a user