Merge branch 'language-translation' into version-1.8.3

This commit is contained in:
Milos Holba
2021-03-02 16:38:48 +01:00
18 changed files with 1377 additions and 46 deletions
+42
View File
@@ -1,4 +1,5 @@
import i18n from '@/i18n/index'
import Axios from 'axios'
const defaultState = {
fileInfoPanelVisible: localStorage.getItem('file_info_visibility') == 'true' || true,
@@ -9,6 +10,10 @@ const defaultState = {
homeDirectory: undefined,
requestedPlan: undefined,
emojis: undefined,
languages: {
allLanguages: undefined,
strings: undefined,
},
sorting: {
sort: localStorage.getItem('sorting') ? JSON.parse(localStorage.getItem('sorting')).sort : 'DESC',
field: localStorage.getItem('sorting') ? JSON.parse(localStorage.getItem('sorting')).field : 'created_at',
@@ -983,6 +988,36 @@ const actions = {
})
},
getLanguages: ({commit, state}) => {
return new Promise((resolve, reject) => {
axios
.get('/api/language/get')
.then((response) => {
commit('LOAD_LANGUAGES', response.data)
})
.catch(() => Vue.prototype.$isSomethingWrong())
.finally(() => {
resolve(true)
})
})
},
getLanguageStrings: ({ commit }, language) => {
return new Promise((resolve, reject) => {
axios
.get(`/api/language/${language.locale}/strings`)
.then(response => {
commit('LOAD_LANGUAGE_STRINGS', response.data)
})
.catch(() => Vue.prototype.$isSomethingWrong())
.finally(() => {
resolve(true)
})
})
},
changePreviewType: ({commit, state}, preview) => {
// Get preview type
@@ -1010,6 +1045,12 @@ const mutations = {
LOAD_EMOJIS_LIST(state, data) {
state.emojis = data
},
LOAD_LANGUAGE_STRINGS (state, data) {
state.languages.strings = data
},
LOAD_LANGUAGES(state, data) {
state.languages.allLanguages = data
},
UPDATE_SORTING(state) {
state.sorting.field = JSON.parse(localStorage.getItem('sorting')).field
state.sorting.sort = JSON.parse(localStorage.getItem('sorting')).sort
@@ -1052,6 +1093,7 @@ const getters = {
currencyList: state => state.currencyList,
countries: state => state.countries,
timezones: state=> state.timezones,
languages: state => state.languages,
api: state => state.config.api,
config: state => state.config,
emojis: state => state.emojis,