From 70663e415a3e6719bd7d448d392a3e7d8a29da79 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Mon, 10 Feb 2025 14:31:23 +0100 Subject: [PATCH] Bug 39061: Export all functions from i18n.js --- .../intranet-tmpl/prog/js/vue/i18n/index.js | 28 +++++++++++++------ 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/i18n/index.js b/koha-tmpl/intranet-tmpl/prog/js/vue/i18n/index.js index 4c36558b48e..b196078d0f7 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/i18n/index.js +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/i18n/index.js @@ -1,14 +1,24 @@ -export const $__ = key => { - return window["__"](key); -}; +const methods = ["__", "__x", "__n", "__nx", "__p", "__px", "__np", "__npx"]; -export const $__p = (ctx, key) => { - return window["__p"](ctx, key); -}; +const translators = Object.fromEntries( + methods.map(method => [method, (...args) => window[method](...args)]) +); + +export const { + __: $__, + __x: $__x, + __n: $__n, + __nx: $__nx, + __p: $__p, + __px: $__px, + __np: $__np, + __npx: $__npx, +} = translators; export default { - install: (app, options) => { - app.config.globalProperties.$__ = $__; - app.config.globalProperties.$__p = $__p; + install: app => { + Object.entries(translators).forEach(([key, func]) => { + app.config.globalProperties[`$${key}`] = func; + }); }, }; -- 2.34.1