mirror of
https://github.com/FH-Complete/FHC-Core.git
synced 2026-07-25 16:44:28 +00:00
added set language feature; phrasen plugin with optional reload if non responsive phrasen are used; stundenplan header mode & buttons reworked
This commit is contained in:
@@ -2,6 +2,7 @@ import FhcApi from './FhcApi.js';
|
||||
|
||||
const categories = Vue.reactive({});
|
||||
const loadingModules = {};
|
||||
let reload = false;
|
||||
|
||||
function extractCategory(obj, category) {
|
||||
return obj.filter(e => e.category == category).reduce((res, elem) => {
|
||||
@@ -19,8 +20,19 @@ function getValueForLoadedPhrase(category, phrase, params) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
const phrasen = {
|
||||
setLanguage(language, api) {
|
||||
const catArray = Object.keys(categories)
|
||||
return api.factory.phrasen.setLanguage(catArray, language).then(res => {
|
||||
if(reload) window.location.reload()
|
||||
|
||||
res.data.forEach(row => {
|
||||
categories[row.category][row.phrase] = row.text
|
||||
})
|
||||
|
||||
return res
|
||||
})
|
||||
},
|
||||
loadCategory(category) {
|
||||
if (Array.isArray(category))
|
||||
return Promise.all(category.map(this.config.globalProperties
|
||||
@@ -63,12 +75,14 @@ const phrasen = {
|
||||
|
||||
export default {
|
||||
install(app, options) {
|
||||
reload = options?.reload ?? reload
|
||||
app.use(FhcApi, options?.fhcApi || undefined);
|
||||
app.config.globalProperties.$p = {
|
||||
t: phrasen.t,
|
||||
loadCategory: cat => phrasen.loadCategory.call(app, cat),
|
||||
setLanguage: phrasen.setLanguage,
|
||||
t_ref: phrasen.t_ref
|
||||
};
|
||||
app.provide('$p', app.config.globalProperties.$p);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user