diff --git a/jest.config.js b/jest.config.js index dd4fd658..4e1019cf 100755 --- a/jest.config.js +++ b/jest.config.js @@ -1,3 +1,5 @@ +const esModules = ['quasar/lang', 'lodash-es', 'quasar'].join('|') + module.exports = { globals: { __DEV__: true @@ -52,9 +54,7 @@ module.exports = { // '.*\\.vue$': '/node_modules/@quasar/quasar-app-extension-testing-unit-jest/node_modules/vue-jest', // '.*\\.js$': '/node_modules/@quasar/quasar-app-extension-testing-unit-jest/node_modules/babel-jest' }, - transformIgnorePatterns: [ - '/node_modules/(?!quasar/lang)' - ], + transformIgnorePatterns: [`/node_modules/(?!(${esModules}))`], snapshotSerializers: [ '/node_modules/jest-serializer-vue' ], diff --git a/src/boot/i18n.js b/src/boot/i18n.js index 5a085bf7..d44e9c8e 100644 --- a/src/boot/i18n.js +++ b/src/boot/i18n.js @@ -4,12 +4,10 @@ import VueI18n from 'vue-i18n' import { messages, getLangFromBrowserDefaults, - normalizeLocaleCode + setLanguage } from 'src/i18n' import { - hasSession, - getSession, - setSession + getSession } from 'src/storage' Vue.use(VueI18n) @@ -24,13 +22,10 @@ export const i18n = new VueI18n({ }) export default ({ app, store }) => { + const currentLocale = getSession('locale') || getLangFromBrowserDefaults() || defaultLocale app.i18n = i18n store.$i18n = i18n - if (!hasSession('locale')) { - setSession('locale', getLangFromBrowserDefaults()) - } - i18n.locale = normalizeLocaleCode(getSession('locale')) - + setLanguage(currentLocale) store.watch(() => i18n.locale, () => { store.dispatch('reloadLanguageRelatedData') }) diff --git a/src/components/call-forwarding/CscCfGroupItem.vue b/src/components/call-forwarding/CscCfGroupItem.vue index aa433467..8ac917a6 100644 --- a/src/components/call-forwarding/CscCfGroupItem.vue +++ b/src/components/call-forwarding/CscCfGroupItem.vue @@ -251,7 +251,7 @@ export default { async removeDestinationEvent (payload) { this.$q.dialog({ title: this.$t('Delete destination'), - message: 'You are about to delete this destination', + message: this.$t('You are about to delete this destination'), color: 'negative', cancel: true, persistent: true diff --git a/src/components/call-forwarding/CscCfGroupTitle.vue b/src/components/call-forwarding/CscCfGroupTitle.vue index d10a9207..a71f0677 100644 --- a/src/components/call-forwarding/CscCfGroupTitle.vue +++ b/src/components/call-forwarding/CscCfGroupTitle.vue @@ -423,7 +423,7 @@ export default { async deleteMappingEvent (mapping) { this.$q.dialog({ title: this.$t('Delete forwarding'), - message: 'You are about to delete this forwarding', + message: this.$t('You are about to delete this forwarding'), color: 'negative', cancel: true, persistent: true diff --git a/src/i18n/en.json b/src/i18n/en.json index 7d174840..bf86d6be 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -479,6 +479,8 @@ "You are about to change your login password. After the password was changed successfully, you get automatically logged out to authenticate with the new password. ": "You are about to change your login password. After the password was changed successfully, you get automatically logged out to authenticate with the new password. ", "You are about to delete recording #{id}": "You are about to delete recording #{id}", "You are about to delete slot {slot}": "You are about to delete slot {slot}", + "You are about to delete this destination": "You are about to delete this destination", + "You are about to delete this forwarding": "You are about to delete this forwarding", "You are about to delete time range \"{from} - {to}\"": "You are about to delete time range \"{from} - {to}\"", "You are about to remove ACL: From email <{from_email}>": "You are about to remove ACL: From email <{from_email}>", "You are about to remove call queue for {subscriber}": "You are about to remove call queue for {subscriber}", @@ -543,4 +545,4 @@ "{field} must be maximum of {maxValue} seconds": "{field} must be maximum of {maxValue} seconds", "{field} must consist of numeric characters only": "{field} must consist of numeric characters only", "{field} must have at most {maxLength} letters": "{field} must have at most {maxLength} letters" -} +} \ No newline at end of file diff --git a/src/i18n/index.js b/src/i18n/index.js index cb99444b..5a740aa5 100644 --- a/src/i18n/index.js +++ b/src/i18n/index.js @@ -53,7 +53,8 @@ function patchKeysForFallback (messages = {}) { return messages } -export function setLanguage (lang) { +export function setLanguage (locale) { + const lang = normalizeLocaleCode(locale) setSession('locale', lang) i18n.locale = lang @@ -61,8 +62,8 @@ export function setLanguage (lang) { import( /* webpackInclude: /(en-us|de|es|fr|it)\.js$/ */ 'quasar/lang/' + quasarLangCode - ).then(lang => { - Quasar.lang.set(lang.default) + ).then(qLang => { + Quasar.lang.set(qLang.default) }) // Note: please extend "reloadLanguageRelatedData" action in the store if you are using language related API endpoints