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:
parent
6945fa70b8
commit
e81ab4036e
|
|
@ -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;
|
||||
});
|
||||
},
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue