TT#130352 missing localisations on JS CSC

Change-Id: Ie47db6b1b137edf0411fdddd125b768b70e242e2
mr10.0
Sergii Leonenko 4 years ago
parent 17f2345b30
commit b45da7aad6

@ -18,6 +18,7 @@ import {
import { import {
assignNumbers assignNumbers
} from './user' } from './user'
import { getCurrentLangAsV1Format } from 'src/i18n'
export function getPreferences (id) { export function getPreferences (id) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
@ -30,7 +31,11 @@ export function getPreferences (id) {
} }
export async function getPreferencesDefs (id) { export async function getPreferencesDefs (id) {
const result = await Vue.http.get('api/subscriberpreferencedefs/') const result = await Vue.http.get('api/subscriberpreferencedefs/', {
params: {
lang: getCurrentLangAsV1Format()
}
})
return getJsonBody(result.body) return getJsonBody(result.body)
} }

@ -1,8 +1,17 @@
export default ({ Vue, app }) => { export default ({ Vue, app }) => {
Vue.prototype.$faxQualityOptions = [ Vue.prototype.$faxQualityOptions = [
{ label: app.i18n.t('Normal'), value: 'normal' }, {
{ label: app.i18n.t('Fine'), value: 'fine' }, get label () { return app.i18n.t('Normal') },
{ label: app.i18n.t('Super'), value: 'super' } value: 'normal'
},
{
get label () { return app.i18n.t('Fine') },
value: 'fine'
},
{
get label () { return app.i18n.t('Super') },
value: 'super'
}
] ]
Vue.prototype.$faxQualityOptionsDefault = Vue.prototype.$faxQualityOptions[0] Vue.prototype.$faxQualityOptionsDefault = Vue.prototype.$faxQualityOptions[0]
} }

@ -32,4 +32,8 @@ export default ({ app, store }) => {
} }
i18n.locale = getSession('locale') + '' i18n.locale = getSession('locale') + ''
store.commit('user/changeSessionLocaleSucceeded', i18n.locale) store.commit('user/changeSessionLocaleSucceeded', i18n.locale)
store.watch(() => i18n.locale, () => {
store.dispatch('reloadLanguageRelatedData')
})
} }

@ -103,7 +103,7 @@ export default {
return { return {
selectedFile: false, selectedFile: false,
form: { form: {
destination: null, destination: '',
pageHeader: null, pageHeader: null,
data: null, data: null,
quality: this.$faxQualityOptionsDefault.value, quality: this.$faxQualityOptionsDefault.value,

@ -59,7 +59,7 @@ export default {
if (this.selectedFile !== null) { if (this.selectedFile !== null) {
return this.selectedFile.name + ' (' + this.selectedFile.size + ' Byte)' return this.selectedFile.name + ' (' + this.selectedFile.size + ' Byte)'
} }
return 'No file' return this.$t('No file')
} }
}, },
methods: { methods: {

@ -6,7 +6,7 @@
class="q-mr-sm" class="q-mr-sm"
dense dense
clearable clearable
label="From" :label="$t('From')"
:disable="loading" :disable="loading"
@input="inputFrom" @input="inputFrom"
/> />
@ -14,7 +14,7 @@
v-model="value.to" v-model="value.to"
dense dense
clearable clearable
label="To" :label="$t('To')"
:disable="loading" :disable="loading"
@input="inputTo" @input="inputTo"
/> />

@ -88,7 +88,7 @@
icon="person" icon="person"
:loading="loading" :loading="loading"
:disable="$v.data.$invalid || loading" :disable="$v.data.$invalid || loading"
label="Create ACL" :label="$t('Create ACL')"
@click="save()" @click="save()"
/> />
</div> </div>

@ -106,7 +106,7 @@
> >
<q-checkbox <q-checkbox
:value="soundFileLoopplay" :value="soundFileLoopplay"
label="Loop" :label="$t('Loop')"
left-label left-label
@input="toggleLoopPlay" @input="toggleLoopPlay"
/> />

@ -30,7 +30,7 @@
color="primary" color="primary"
flat flat
dense dense
label="Save" :label="$t('Save')"
:disable="pinRequesting" :disable="pinRequesting"
@click="updatePin" @click="updatePin"
/> />
@ -67,7 +67,7 @@
color="primary" color="primary"
flat flat
dense dense
label="Save" :label="$t('Save')"
:disable="emailRequesting" :disable="emailRequesting"
@click="updateEmail" @click="updateEmail"
/> />

@ -93,6 +93,7 @@
"Could not enable incoming call notifications.": "Could not enable incoming call notifications.", "Could not enable incoming call notifications.": "Could not enable incoming call notifications.",
"Could not find any device matching any of the filter criteria": "Could not find any device matching any of the filter criteria", "Could not find any device matching any of the filter criteria": "Could not find any device matching any of the filter criteria",
"Could not find any group matching any of the filter criteria": "Could not find any group matching any of the filter criteria", "Could not find any group matching any of the filter criteria": "Could not find any group matching any of the filter criteria",
"Create ACL": "Create ACL",
"Create Call Queue": "Create Call Queue", "Create Call Queue": "Create Call Queue",
"Create Config": "Create Config", "Create Config": "Create Config",
"Create List": "Create List", "Create List": "Create List",
@ -169,6 +170,7 @@
"Fr": "Fr", "Fr": "Fr",
"Free": "Free", "Free": "Free",
"Friday": "Friday", "Friday": "Friday",
"From": "From",
"From email": "From email", "From email": "From email",
"General": "General", "General": "General",
"Group": "Group", "Group": "Group",
@ -209,6 +211,7 @@
"List of registered devices for the subscriber": "List of registered devices for the subscriber", "List of registered devices for the subscriber": "List of registered devices for the subscriber",
"Login": "Login", "Login": "Login",
"Logout": "Logout", "Logout": "Logout",
"Loop": "Loop",
"MAC address": "MAC address", "MAC address": "MAC address",
"Mail To Fax feature is not active": "Mail To Fax feature is not active", "Mail To Fax feature is not active": "Mail To Fax feature is not active",
"Mail to Fax": "Mail to Fax", "Mail to Fax": "Mail to Fax",
@ -239,6 +242,7 @@
"No data to save. Please provide at least one time range.": "No data to save. Please provide at least one time range.", "No data to save. Please provide at least one time range.": "No data to save. Please provide at least one time range.",
"No destinations created yet": "No destinations created yet", "No destinations created yet": "No destinations created yet",
"No devices created yet": "No devices created yet", "No devices created yet": "No devices created yet",
"No file": "No file",
"No groups": "No groups", "No groups": "No groups",
"No groups created yet": "No groups created yet", "No groups created yet": "No groups created yet",
"No manager secretary configuration created yet": "No manager secretary configuration created yet", "No manager secretary configuration created yet": "No manager secretary configuration created yet",
@ -389,6 +393,7 @@
"Time": "Time", "Time": "Time",
"Time is invalid": "Time is invalid", "Time is invalid": "Time is invalid",
"Timerange": "Timerange", "Timerange": "Timerange",
"To": "To",
"Today": "Today", "Today": "Today",
"Tu": "Tu", "Tu": "Tu",
"Tuesday": "Tuesday", "Tuesday": "Tuesday",

@ -6,6 +6,8 @@ import localeEs from './es.json'
import localeDe from './de.json' import localeDe from './de.json'
import localeRu from './ru.json' import localeRu from './ru.json'
import { i18n } from 'src/boot/i18n' import { i18n } from 'src/boot/i18n'
import { setSession } from 'src/storage'
import Quasar from 'quasar'
export const defaultLocale = 'en-US' export const defaultLocale = 'en-US'
@ -45,6 +47,20 @@ function patchKeysForFallback (messages = {}) {
return messages return messages
} }
export function setLanguage (lang) {
setSession('locale', lang)
i18n.locale = lang
import(
/* webpackInclude: /(en-us|de|es|fr|it|ru)\.js$/ */
'quasar/lang/' + lang.toLowerCase()
).then(lang => {
Quasar.lang.set(lang.default)
})
// Note: please extend "reloadLanguageRelatedData" action in the store if you are using language related API endpoints
}
/** /**
* It converts language code from V2 (new CSC) to V1 UI (old Panel CSC) format * It converts language code from V2 (new CSC) to V1 UI (old Panel CSC) format
* @param {string} lang * @param {string} lang

@ -42,7 +42,7 @@
:readonly="dataLoading" :readonly="dataLoading"
:label="$t('Language for voicemail and app server')" :label="$t('Language for voicemail and app server')"
:title="$t('Voice prompts language for voicemail, conference and application server')" :title="$t('Voice prompts language for voicemail, conference and application server')"
:options="options" :options="languages"
@input="languageSelected()" @input="languageSelected()"
/> />
</q-item-section> </q-item-section>
@ -81,8 +81,7 @@ export default {
}, },
data () { data () {
return { return {
selectedOption: this.$defaultVoicePromptLanguage, selectedOption: this.$defaultVoicePromptLanguage
options: []
} }
}, },
computed: { computed: {
@ -107,15 +106,16 @@ export default {
}, },
async mounted () { async mounted () {
try { try {
await this.loadPreferencesDefsAction()
await this.loadSubscriberPreferencesAction() await this.loadSubscriberPreferencesAction()
this.options = await this.languages this.selectedOption = this.language || this.defaultLanguage
this.selectedOption = this.language || await this.defaultLanguage
} catch (err) { } catch (err) {
showGlobalError(err?.message || this.$t('Unknown error')) showGlobalError(err?.message || this.$t('Unknown error'))
} }
}, },
methods: { methods: {
...mapWaitingActions('callSettings', { ...mapWaitingActions('callSettings', {
loadPreferencesDefsAction: 'processing subscriberPreferences',
loadSubscriberPreferencesAction: 'processing subscriberPreferences', loadSubscriberPreferencesAction: 'processing subscriberPreferences',
setMusicOnHold: 'processing subscriberPreferences', setMusicOnHold: 'processing subscriberPreferences',
setLanguage: 'processing subscriberPreferences' setLanguage: 'processing subscriberPreferences'

@ -10,7 +10,8 @@ export default {
namespaced: true, namespaced: true,
state: { state: {
subscriberPreferencesInitialized: false, subscriberPreferencesInitialized: false,
subscriberPreferences: {} subscriberPreferences: {},
preferencesDefs: {}
}, },
getters: { getters: {
subscriberId (state, getters, rootState, rootGetters) { subscriberId (state, getters, rootState, rootGetters) {
@ -22,16 +23,15 @@ export default {
language (state) { language (state) {
return state.subscriberPreferences.language return state.subscriberPreferences.language
}, },
async defaultLanguage (state, getters) { defaultLanguage (state, getters) {
const languages = await getters.languages const languages = getters.languages
return languages.find(lang => lang.default_val).label return languages.find(lang => lang.default_val).label
}, },
async languages (state) { languages (state) {
const preferencesDefs = await getPreferencesDefs() return state.preferencesDefs
return preferencesDefs .language?.enum_values?.map((lang) => {
.language return { value: lang.value, label: lang.label, default_val: lang.default_val }
.enum_values })
.map((lang) => { return { value: lang.value, label: lang.label, default_val: lang.default_val } })
} }
}, },
mutations: { mutations: {
@ -41,6 +41,9 @@ export default {
}, },
subscriberPreferencesUpdate (state, { field, value }) { subscriberPreferencesUpdate (state, { field, value }) {
Vue.set(state.subscriberPreferences, field, value) Vue.set(state.subscriberPreferences, field, value)
},
preferencesDefsSucceeded (state, res) {
state.preferencesDefs = res
} }
}, },
actions: { actions: {
@ -55,6 +58,10 @@ export default {
value: options.value value: options.value
}) })
}, },
async loadPreferencesDefsAction (context) {
const preferencesDefs = await getPreferencesDefs()
context.commit('preferencesDefsSucceeded', preferencesDefs)
},
async setMusicOnHold (context, value) { async setMusicOnHold (context, value) {
await context.dispatch('fieldUpdateAction', { field: 'music_on_hold', value }) await context.dispatch('fieldUpdateAction', { field: 'music_on_hold', value })
}, },

@ -118,6 +118,17 @@ export default function (/* { ssrContext } */) {
state.route = route state.route = route
} }
}, },
actions: {
async reloadLanguageRelatedData (context) {
/* NOTE: this action will be called after UI language change. So you could place here actions calls for
refreshing language related data in the store */
if (Object.keys(context.state.callSettings.preferencesDefs).length > 0) {
// preferencesDefs were loaded already so we need updated them for a new language
await context.dispatch('callSettings/loadPreferencesDefsAction')
}
}
},
plugins: [ plugins: [
function rtcEngine (store) { function rtcEngine (store) {
Vue.$rtcEngine.setNgcpApiBaseUrl(Vue.$config.baseHttpUrl) Vue.$rtcEngine.setNgcpApiBaseUrl(Vue.$config.baseHttpUrl)

@ -2,9 +2,6 @@
import router from '../router' import router from '../router'
import Vue from 'vue' import Vue from 'vue'
import {
i18n
} from 'src/boot/i18n'
import _ from 'lodash' import _ from 'lodash'
import { import {
RequestState RequestState
@ -23,11 +20,11 @@ import {
getSubscriberProfile getSubscriberProfile
} from '../api/subscriber' } from '../api/subscriber'
import { deleteJwt, getJwt, getSubscriberId, setJwt, setSubscriberId } from 'src/auth' import { deleteJwt, getJwt, getSubscriberId, setJwt, setSubscriberId } from 'src/auth'
import { setSession } from 'src/storage'
import QRCode from 'qrcode' import QRCode from 'qrcode'
import { import {
qrPayload qrPayload
} from 'src/helpers/qr' } from 'src/helpers/qr'
import { setLanguage } from 'src/i18n'
export default { export default {
namespaced: true, namespaced: true,
@ -382,8 +379,8 @@ export default {
changeSessionLanguage (context, locale) { changeSessionLanguage (context, locale) {
context.commit('changeSessionLocaleRequesting') context.commit('changeSessionLocaleRequesting')
try { try {
setSession('locale', locale) setLanguage(locale)
i18n.locale = locale
context.commit('changeSessionLocaleSucceeded', locale) context.commit('changeSessionLocaleSucceeded', locale)
} catch (error) { } catch (error) {
context.commit('changeSessionLocaleFailed', error) context.commit('changeSessionLocaleFailed', error)

Loading…
Cancel
Save