mirror of
https://github.com/mayswind/ezbookkeeping.git
synced 2026-05-22 02:34:26 +08:00
code refactor
This commit is contained in:
@@ -153,6 +153,32 @@ function getAllLanguageInfos() {
|
|||||||
return allLanguages;
|
return allLanguages;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getAllLanguageInfoArray(translateFn, includeSystemDefault) {
|
||||||
|
const ret = [];
|
||||||
|
|
||||||
|
if (includeSystemDefault) {
|
||||||
|
ret.push({
|
||||||
|
code: '',
|
||||||
|
displayName: translateFn('System Default')
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
for (const code in allLanguages) {
|
||||||
|
if (!Object.prototype.hasOwnProperty.call(allLanguages, code)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
const languageInfo = allLanguages[code];
|
||||||
|
|
||||||
|
ret.push({
|
||||||
|
code: code,
|
||||||
|
displayName: languageInfo.displayName
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
function getLanguageInfo(locale) {
|
function getLanguageInfo(locale) {
|
||||||
return allLanguages[locale];
|
return allLanguages[locale];
|
||||||
}
|
}
|
||||||
@@ -746,6 +772,7 @@ export function translateError(message, translateFn) {
|
|||||||
export function i18nFunctions(i18nGlobal) {
|
export function i18nFunctions(i18nGlobal) {
|
||||||
return {
|
return {
|
||||||
getAllLanguageInfos: getAllLanguageInfos,
|
getAllLanguageInfos: getAllLanguageInfos,
|
||||||
|
getAllLanguageInfoArray: (includeSystemDefault) => getAllLanguageInfoArray(i18nGlobal.t, includeSystemDefault),
|
||||||
getLanguageInfo: getLanguageInfo,
|
getLanguageInfo: getLanguageInfo,
|
||||||
getDefaultLanguage: getDefaultLanguage,
|
getDefaultLanguage: getDefaultLanguage,
|
||||||
getCurrentLanguageInfo: () => getCurrentLanguageInfo(i18nGlobal),
|
getCurrentLanguageInfo: () => getCurrentLanguageInfo(i18nGlobal),
|
||||||
|
|||||||
@@ -270,28 +270,7 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
...mapStores(useRootStore, useSettingsStore, useUserStore, useAccountsStore),
|
...mapStores(useRootStore, useSettingsStore, useUserStore, useAccountsStore),
|
||||||
allLanguages() {
|
allLanguages() {
|
||||||
const ret = [];
|
return this.$locale.getAllLanguageInfoArray(true);
|
||||||
const allLanguageInfo = this.$locale.getAllLanguageInfos();
|
|
||||||
|
|
||||||
ret.push({
|
|
||||||
code: '',
|
|
||||||
displayName: this.$t('System Default')
|
|
||||||
});
|
|
||||||
|
|
||||||
for (let code in allLanguageInfo) {
|
|
||||||
if (!Object.prototype.hasOwnProperty.call(allLanguageInfo, code)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const languageInfo = allLanguageInfo[code];
|
|
||||||
|
|
||||||
ret.push({
|
|
||||||
code: code,
|
|
||||||
displayName: languageInfo.displayName
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
},
|
},
|
||||||
allCurrencies() {
|
allCurrencies() {
|
||||||
return this.$locale.getAllCurrencies();
|
return this.$locale.getAllCurrencies();
|
||||||
|
|||||||
@@ -274,28 +274,7 @@ export default {
|
|||||||
computed: {
|
computed: {
|
||||||
...mapStores(useRootStore, useSettingsStore, useUserStore, useAccountsStore),
|
...mapStores(useRootStore, useSettingsStore, useUserStore, useAccountsStore),
|
||||||
allLanguages() {
|
allLanguages() {
|
||||||
const ret = [];
|
return this.$locale.getAllLanguageInfoArray(true);
|
||||||
const allLanguageInfo = this.$locale.getAllLanguageInfos();
|
|
||||||
|
|
||||||
ret.push({
|
|
||||||
code: '',
|
|
||||||
displayName: this.$t('System Default')
|
|
||||||
});
|
|
||||||
|
|
||||||
for (let code in allLanguageInfo) {
|
|
||||||
if (!Object.prototype.hasOwnProperty.call(allLanguageInfo, code)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
const languageInfo = allLanguageInfo[code];
|
|
||||||
|
|
||||||
ret.push({
|
|
||||||
code: code,
|
|
||||||
displayName: languageInfo.displayName
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
},
|
},
|
||||||
allCurrencies() {
|
allCurrencies() {
|
||||||
return this.$locale.getAllCurrencies();
|
return this.$locale.getAllCurrencies();
|
||||||
|
|||||||
Reference in New Issue
Block a user