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 4c36558b48..b196078d0f 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; + }); }, };