From 137c5f28ec00543e4e4e2230f5bc8a29f408237f Mon Sep 17 00:00:00 2001 From: Harald Bamberger Date: Thu, 28 Sep 2023 14:27:35 +0200 Subject: [PATCH] modify Phrasen.js so that it can be used by composition api and does not use legacy categories at all --- public/js/mixins/Phrasen.js | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/public/js/mixins/Phrasen.js b/public/js/mixins/Phrasen.js index fd954579a..edaf4d101 100644 --- a/public/js/mixins/Phrasen.js +++ b/public/js/mixins/Phrasen.js @@ -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, + } + +}