Skip to content

Commit

Permalink
feat(setting): display localized lang title
Browse files Browse the repository at this point in the history
  • Loading branch information
ci010 committed Sep 4, 2019
1 parent 84c35a4 commit d690580
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/renderer/windows/main/SettingPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,8 @@
</template>

<script>
import langIndex from 'static/locales/index.json';
export default {
data() {
return {
Expand All @@ -188,7 +190,7 @@ export default {
computed: {
selectedLang: {
get() {
return this.langs.find(l => l === this.$repo.state.setting.locale) || 'en';
return this.langs.find(l => l.value === this.$repo.state.setting.locale) || 'en';
},
set(v) { this.$repo.commit('locale', v); },
},
Expand All @@ -212,7 +214,12 @@ export default {
downloadingUpdate() { return this.$repo.state.setting.downloadingUpdate; },
checkingUpdate() { return this.$repo.state.setting.checkingUpdate; },
updateInfo() { return this.$repo.state.setting.updateInfo || {}; },
langs() { return this.$repo.state.setting.locales; },
langs() {
return this.$repo.state.setting.locales.map(l => ({
value: l,
text: langIndex[l],
}));
},
},
methods: {
checkUpdate() {
Expand Down
1 change: 1 addition & 0 deletions static/locales/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ const files = require.context('.', false, /\.json$/);
const locales = {};

files.keys().forEach((key) => {
if (key.endsWith('index.json')) return;
locales[key.replace(/(\.\/|\.json)/g, '')] = files(key);
});

Expand Down
4 changes: 4 additions & 0 deletions static/locales/index.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"en": "English",
"zh-CN": "中文(简体)"
}

0 comments on commit d690580

Please sign in to comment.