code refactor
This commit is contained in:
+12
-1
@@ -259,6 +259,10 @@ function getLocaleFromLanguageAlias(alias) {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getCurrentLanguageCode(i18nGlobal) {
|
||||||
|
return i18nGlobal.locale;
|
||||||
|
}
|
||||||
|
|
||||||
function getCurrentLanguageInfo(i18nGlobal) {
|
function getCurrentLanguageInfo(i18nGlobal) {
|
||||||
const locale = getLanguageInfo(i18nGlobal.locale);
|
const locale = getLanguageInfo(i18nGlobal.locale);
|
||||||
|
|
||||||
@@ -266,7 +270,12 @@ function getCurrentLanguageInfo(i18nGlobal) {
|
|||||||
return locale;
|
return locale;
|
||||||
}
|
}
|
||||||
|
|
||||||
return getDefaultLanguage();
|
return getLanguageInfo(getDefaultLanguage());
|
||||||
|
}
|
||||||
|
|
||||||
|
function getCurrentLanguageDisplayName(i18nGlobal) {
|
||||||
|
const currentLanguageInfo = getCurrentLanguageInfo(i18nGlobal);
|
||||||
|
return currentLanguageInfo.displayName;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getDefaultCurrency(translateFn) {
|
function getDefaultCurrency(translateFn) {
|
||||||
@@ -917,7 +926,9 @@ export function i18nFunctions(i18nGlobal) {
|
|||||||
getAllLanguageInfoArray: (includeSystemDefault) => getAllLanguageInfoArray(i18nGlobal.t, includeSystemDefault),
|
getAllLanguageInfoArray: (includeSystemDefault) => getAllLanguageInfoArray(i18nGlobal.t, includeSystemDefault),
|
||||||
getLanguageInfo: getLanguageInfo,
|
getLanguageInfo: getLanguageInfo,
|
||||||
getDefaultLanguage: getDefaultLanguage,
|
getDefaultLanguage: getDefaultLanguage,
|
||||||
|
getCurrentLanguageCode: () => getCurrentLanguageCode(i18nGlobal),
|
||||||
getCurrentLanguageInfo: () => getCurrentLanguageInfo(i18nGlobal),
|
getCurrentLanguageInfo: () => getCurrentLanguageInfo(i18nGlobal),
|
||||||
|
getCurrentLanguageDisplayName: () => getCurrentLanguageDisplayName(i18nGlobal),
|
||||||
getDefaultCurrency: () => getDefaultCurrency(i18nGlobal.t),
|
getDefaultCurrency: () => getDefaultCurrency(i18nGlobal.t),
|
||||||
getDefaultFirstDayOfWeek: () => getDefaultFirstDayOfWeek(i18nGlobal.t),
|
getDefaultFirstDayOfWeek: () => getDefaultFirstDayOfWeek(i18nGlobal.t),
|
||||||
getCurrencyName: (currencyCode) => getCurrencyName(currencyCode, i18nGlobal.t),
|
getCurrencyName: (currencyCode) => getCurrencyName(currencyCode, i18nGlobal.t),
|
||||||
|
|||||||
@@ -8,10 +8,10 @@
|
|||||||
</router-link>
|
</router-link>
|
||||||
<v-row no-gutters class="auth-wrapper">
|
<v-row no-gutters class="auth-wrapper">
|
||||||
<v-col cols="12" md="8" class="d-none d-md-flex align-center justify-center position-relative">
|
<v-col cols="12" md="8" class="d-none d-md-flex align-center justify-center position-relative">
|
||||||
<div class="d-flex auth-img-footer" v-if="currentTheme !== 'dark'">
|
<div class="d-flex auth-img-footer" v-if="!isDarkMode">
|
||||||
<v-img src="img/desktop/background.svg"/>
|
<v-img src="img/desktop/background.svg"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex auth-img-footer" v-if="currentTheme === 'dark'">
|
<div class="d-flex auth-img-footer" v-if="isDarkMode">
|
||||||
<v-img src="img/desktop/background-dark.svg"/>
|
<v-img src="img/desktop/background-dark.svg"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex align-center justify-center w-100 pt-10">
|
<div class="d-flex align-center justify-center w-100 pt-10">
|
||||||
@@ -221,20 +221,11 @@ export default {
|
|||||||
return !this.passcode;
|
return !this.passcode;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
currentTheme: {
|
isDarkMode() {
|
||||||
get: function () {
|
return this.globalTheme.global.name.value === 'dark';
|
||||||
return this.globalTheme.global.name.value;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
currentLanguageName() {
|
currentLanguageName() {
|
||||||
const currentLocale = this.$i18n.locale;
|
return this.$locale.getCurrentLanguageDisplayName();
|
||||||
let lang = this.$locale.getLanguageInfo(currentLocale);
|
|
||||||
|
|
||||||
if (!lang) {
|
|
||||||
lang = this.$locale.getLanguageInfo(this.$locale.getDefaultLanguage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return lang.displayName;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
|
|||||||
@@ -8,10 +8,10 @@
|
|||||||
</router-link>
|
</router-link>
|
||||||
<v-row no-gutters class="auth-wrapper">
|
<v-row no-gutters class="auth-wrapper">
|
||||||
<v-col cols="12" md="4" class="d-none d-md-flex align-center justify-center position-relative">
|
<v-col cols="12" md="4" class="d-none d-md-flex align-center justify-center position-relative">
|
||||||
<div class="d-flex auth-img-footer" v-if="currentTheme !== 'dark'">
|
<div class="d-flex auth-img-footer" v-if="!isDarkMode">
|
||||||
<v-img src="img/desktop/background.svg"/>
|
<v-img src="img/desktop/background.svg"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex auth-img-footer" v-if="currentTheme === 'dark'">
|
<div class="d-flex auth-img-footer" v-if="isDarkMode">
|
||||||
<v-img src="img/desktop/background-dark.svg"/>
|
<v-img src="img/desktop/background-dark.svg"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex align-center justify-center w-100 pt-10">
|
<div class="d-flex align-center justify-center w-100 pt-10">
|
||||||
@@ -272,7 +272,7 @@ export default {
|
|||||||
confirmPassword: '',
|
confirmPassword: '',
|
||||||
email: '',
|
email: '',
|
||||||
nickname: '',
|
nickname: '',
|
||||||
language: self.$i18n.locale,
|
language: self.$locale.getCurrentLanguageCode(),
|
||||||
defaultCurrency: settingsStore.localeDefaultSettings.currency,
|
defaultCurrency: settingsStore.localeDefaultSettings.currency,
|
||||||
firstDayOfWeek: settingsStore.localeDefaultSettings.firstDayOfWeek,
|
firstDayOfWeek: settingsStore.localeDefaultSettings.firstDayOfWeek,
|
||||||
},
|
},
|
||||||
@@ -311,7 +311,7 @@ export default {
|
|||||||
},
|
},
|
||||||
currentLocale: {
|
currentLocale: {
|
||||||
get: function () {
|
get: function () {
|
||||||
return this.$i18n.locale;
|
return this.$locale.getCurrentLanguageCode();
|
||||||
},
|
},
|
||||||
set: function (value) {
|
set: function (value) {
|
||||||
const isCurrencyDefault = this.user.defaultCurrency === this.settingsStore.localeDefaultSettings.currency;
|
const isCurrencyDefault = this.user.defaultCurrency === this.settingsStore.localeDefaultSettings.currency;
|
||||||
@@ -331,10 +331,8 @@ export default {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
currentTheme: {
|
isDarkMode() {
|
||||||
get: function () {
|
return this.globalTheme.global.name.value === 'dark';
|
||||||
return this.globalTheme.global.name.value;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
currentLanguageName() {
|
currentLanguageName() {
|
||||||
const languageInfo = this.$locale.getLanguageInfo(this.currentLocale);
|
const languageInfo = this.$locale.getLanguageInfo(this.currentLocale);
|
||||||
@@ -345,9 +343,6 @@ export default {
|
|||||||
|
|
||||||
return languageInfo.displayName;
|
return languageInfo.displayName;
|
||||||
},
|
},
|
||||||
currentDayOfWeekName() {
|
|
||||||
return getNameByKeyValue(this.allWeekDays, this.user.firstDayOfWeek, 'type', 'displayName');
|
|
||||||
},
|
|
||||||
inputIsEmpty() {
|
inputIsEmpty() {
|
||||||
return !!this.inputEmptyProblemMessage;
|
return !!this.inputEmptyProblemMessage;
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -8,10 +8,10 @@
|
|||||||
</router-link>
|
</router-link>
|
||||||
<v-row no-gutters class="auth-wrapper">
|
<v-row no-gutters class="auth-wrapper">
|
||||||
<v-col cols="12" md="8" class="d-none d-md-flex align-center justify-center position-relative">
|
<v-col cols="12" md="8" class="d-none d-md-flex align-center justify-center position-relative">
|
||||||
<div class="d-flex auth-img-footer" v-if="currentTheme !== 'dark'">
|
<div class="d-flex auth-img-footer" v-if="!isDarkMode">
|
||||||
<v-img src="img/desktop/background.svg"/>
|
<v-img src="img/desktop/background.svg"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex auth-img-footer" v-if="currentTheme === 'dark'">
|
<div class="d-flex auth-img-footer" v-if="isDarkMode">
|
||||||
<v-img src="img/desktop/background-dark.svg"/>
|
<v-img src="img/desktop/background-dark.svg"/>
|
||||||
</div>
|
</div>
|
||||||
<div class="d-flex align-center justify-center w-100 pt-10">
|
<div class="d-flex align-center justify-center w-100 pt-10">
|
||||||
@@ -133,20 +133,11 @@ export default {
|
|||||||
&& this.$user.getWebAuthnCredentialId()
|
&& this.$user.getWebAuthnCredentialId()
|
||||||
&& webauthn.isSupported();
|
&& webauthn.isSupported();
|
||||||
},
|
},
|
||||||
currentTheme: {
|
isDarkMode() {
|
||||||
get: function () {
|
return this.globalTheme.global.name.value === 'dark';
|
||||||
return this.globalTheme.global.name.value;
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
currentLanguageName() {
|
currentLanguageName() {
|
||||||
const currentLocale = this.$i18n.locale;
|
return this.$locale.getCurrentLanguageDisplayName();
|
||||||
let lang = this.$locale.getLanguageInfo(currentLocale);
|
|
||||||
|
|
||||||
if (!lang) {
|
|
||||||
lang = this.$locale.getLanguageInfo(this.$locale.getDefaultLanguage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return lang.displayName;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
setup() {
|
setup() {
|
||||||
|
|||||||
@@ -70,7 +70,7 @@
|
|||||||
@click="changeLanguage(locale)"
|
@click="changeLanguage(locale)"
|
||||||
>
|
>
|
||||||
<template #after>
|
<template #after>
|
||||||
<f7-icon class="list-item-checked-icon" f7="checkmark_alt" v-if="$i18n.locale === locale"></f7-icon>
|
<f7-icon class="list-item-checked-icon" f7="checkmark_alt" v-if="currentLanguageCode === locale"></f7-icon>
|
||||||
</template>
|
</template>
|
||||||
</f7-list-item>
|
</f7-list-item>
|
||||||
</f7-list>
|
</f7-list>
|
||||||
@@ -183,15 +183,11 @@ export default {
|
|||||||
return 'Use a backup code';
|
return 'Use a backup code';
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
currentLanguageCode() {
|
||||||
|
return this.$locale.getCurrentLanguageCode();
|
||||||
|
},
|
||||||
currentLanguageName() {
|
currentLanguageName() {
|
||||||
const currentLocale = this.$i18n.locale;
|
return this.$locale.getCurrentLanguageDisplayName();
|
||||||
let lang = this.$locale.getLanguageInfo(currentLocale);
|
|
||||||
|
|
||||||
if (!lang) {
|
|
||||||
lang = this.$locale.getLanguageInfo(this.$locale.getDefaultLanguage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return lang.displayName;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ export default {
|
|||||||
const self = this;
|
const self = this;
|
||||||
|
|
||||||
return {
|
return {
|
||||||
currentLocale: self.$i18n.locale,
|
currentLocale: self.$locale.getCurrentLanguageCode(),
|
||||||
logouting: false
|
logouting: false
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
@@ -196,7 +196,7 @@ export default {
|
|||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onPageAfterIn() {
|
onPageAfterIn() {
|
||||||
this.currentLocale = this.$i18n.locale;
|
this.currentLocale = this.$locale.getCurrentLanguageCode();
|
||||||
},
|
},
|
||||||
logout() {
|
logout() {
|
||||||
const self = this;
|
const self = this;
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ export default {
|
|||||||
confirmPassword: '',
|
confirmPassword: '',
|
||||||
email: '',
|
email: '',
|
||||||
nickname: '',
|
nickname: '',
|
||||||
language: self.$i18n.locale,
|
language: self.$locale.getCurrentLanguageCode(),
|
||||||
defaultCurrency: settingsStore.localeDefaultSettings.currency,
|
defaultCurrency: settingsStore.localeDefaultSettings.currency,
|
||||||
firstDayOfWeek: settingsStore.localeDefaultSettings.firstDayOfWeek,
|
firstDayOfWeek: settingsStore.localeDefaultSettings.firstDayOfWeek,
|
||||||
},
|
},
|
||||||
@@ -227,7 +227,7 @@ export default {
|
|||||||
},
|
},
|
||||||
currentLocale: {
|
currentLocale: {
|
||||||
get: function () {
|
get: function () {
|
||||||
return this.$i18n.locale;
|
return this.$locale.getCurrentLanguageCode();
|
||||||
},
|
},
|
||||||
set: function (value) {
|
set: function (value) {
|
||||||
const isCurrencyDefault = this.user.defaultCurrency === this.settingsStore.localeDefaultSettings.currency;
|
const isCurrencyDefault = this.user.defaultCurrency === this.settingsStore.localeDefaultSettings.currency;
|
||||||
|
|||||||
@@ -48,7 +48,7 @@
|
|||||||
@click="changeLanguage(locale)"
|
@click="changeLanguage(locale)"
|
||||||
>
|
>
|
||||||
<template #after>
|
<template #after>
|
||||||
<f7-icon class="list-item-checked-icon" f7="checkmark_alt" v-if="$i18n.locale === locale"></f7-icon>
|
<f7-icon class="list-item-checked-icon" f7="checkmark_alt" v-if="currentLanguageCode === locale"></f7-icon>
|
||||||
</template>
|
</template>
|
||||||
</f7-list-item>
|
</f7-list-item>
|
||||||
</f7-list>
|
</f7-list>
|
||||||
@@ -94,15 +94,11 @@ export default {
|
|||||||
&& this.$user.getWebAuthnCredentialId()
|
&& this.$user.getWebAuthnCredentialId()
|
||||||
&& webauthn.isSupported();
|
&& webauthn.isSupported();
|
||||||
},
|
},
|
||||||
|
currentLanguageCode() {
|
||||||
|
return this.$locale.getCurrentLanguageCode();
|
||||||
|
},
|
||||||
currentLanguageName() {
|
currentLanguageName() {
|
||||||
const currentLocale = this.$i18n.locale;
|
return this.$locale.getCurrentLanguageDisplayName();
|
||||||
let lang = this.$locale.getLanguageInfo(currentLocale);
|
|
||||||
|
|
||||||
if (!lang) {
|
|
||||||
lang = this.$locale.getLanguageInfo(this.$locale.getDefaultLanguage());
|
|
||||||
}
|
|
||||||
|
|
||||||
return lang.displayName;
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
|
|||||||
@@ -71,7 +71,7 @@ export default {
|
|||||||
|
|
||||||
return {
|
return {
|
||||||
loadingError: null,
|
loadingError: null,
|
||||||
currentLocale: self.$i18n.locale,
|
currentLocale: self.$locale.getCurrentLanguageCode(),
|
||||||
categoryType: 0,
|
categoryType: 0,
|
||||||
allCategories: [],
|
allCategories: [],
|
||||||
submitting: false,
|
submitting: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user