modify Phrasen.js so that it can be used by composition api and does not use legacy categories at all

This commit is contained in:
Harald Bamberger
2023-09-28 14:27:35 +02:00
parent 4fcf4a57d1
commit 137c5f28ec
+17 -2
View File
@@ -44,6 +44,7 @@ function getValueForLoadedPhrase(category, phrase, params) {
return result;
}
const phrasen = {
t_ref(category, phrase, params) {
if (params === undefined && (
@@ -58,8 +59,9 @@ const phrasen = {
return '';
}
if (!categories[category]) {
if (window.FHC_JS_PHRASES_STORAGE_OBJECT !== undefined)
categories[category] = extractCategory(FHC_JS_PHRASES_STORAGE_OBJECT, category);
//if (window.FHC_JS_PHRASES_STORAGE_OBJECT !== undefined)
// categories[category] = extractCategory(FHC_JS_PHRASES_STORAGE_OBJECT, category);
if (!categories[category] || Object.keys(categories[category]).length === 0) {
categories[category] = undefined;
@@ -83,3 +85,16 @@ export default {
}
}
}
// Composable (wrapper for mixin)
export function usePhrasen() {
function t(category, phrase, params) {
return phrasen.t(category, phrase, params);
}
return {
t,
}
}