Bug 39061: Export all functions from i18n.js

Signed-off-by: Martin Renvoize <martin.renvoize@openfifth.co.uk>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Jonathan Druart 2025-02-10 14:31:23 +01:00 committed by Katrin Fischer
parent 6945fa70b8
commit e81ab4036e
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 19 additions and 9 deletions

View File

@ -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;
});
},
};