@fkui/i18next-translate 6.38.0 → 6.40.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/index.js +33 -13
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +33 -13
- package/dist/esm/index.js.map +1 -1
- package/dist/types/tsdoc-metadata.json +1 -1
- package/package.json +5 -5
package/dist/cjs/index.js
CHANGED
|
@@ -2039,7 +2039,7 @@ function createScreenReaderWrapper(options) {
|
|
|
2039
2039
|
wrapper.id = "fkui-alert-screen-reader";
|
|
2040
2040
|
wrapper.className = "sr-only";
|
|
2041
2041
|
updateProperties();
|
|
2042
|
-
document.body.
|
|
2042
|
+
document.body.append(wrapper);
|
|
2043
2043
|
}
|
|
2044
2044
|
}
|
|
2045
2045
|
/**
|
|
@@ -2256,7 +2256,7 @@ const deepFind = (obj, path, keySeparator = '.') => {
|
|
|
2256
2256
|
}
|
|
2257
2257
|
return current;
|
|
2258
2258
|
};
|
|
2259
|
-
const getCleanedCode = code => code?.replace(
|
|
2259
|
+
const getCleanedCode = code => code?.replace(/_/g, '-');
|
|
2260
2260
|
|
|
2261
2261
|
const consoleLogger = {
|
|
2262
2262
|
type: 'logger',
|
|
@@ -2517,7 +2517,16 @@ function keysFromSelector(selector, opts) {
|
|
|
2517
2517
|
const {
|
|
2518
2518
|
[PATH_KEY]: path
|
|
2519
2519
|
} = selector(createProxy());
|
|
2520
|
-
|
|
2520
|
+
const keySeparator = opts?.keySeparator ?? '.';
|
|
2521
|
+
const nsSeparator = opts?.nsSeparator ?? ':';
|
|
2522
|
+
if (path.length > 1 && nsSeparator) {
|
|
2523
|
+
const ns = opts?.ns;
|
|
2524
|
+
const nsArray = Array.isArray(ns) ? ns : null;
|
|
2525
|
+
if (nsArray && nsArray.length > 1 && nsArray.slice(1).includes(path[0])) {
|
|
2526
|
+
return `${path[0]}${nsSeparator}${path.slice(1).join(keySeparator)}`;
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
return path.join(keySeparator);
|
|
2521
2530
|
}
|
|
2522
2531
|
|
|
2523
2532
|
const checkedLoadedFor = {};
|
|
@@ -2591,6 +2600,10 @@ class Translator extends EventEmitter {
|
|
|
2591
2600
|
...opt
|
|
2592
2601
|
});
|
|
2593
2602
|
if (!Array.isArray(keys)) keys = [String(keys)];
|
|
2603
|
+
keys = keys.map(k => typeof k === 'function' ? keysFromSelector(k, {
|
|
2604
|
+
...this.options,
|
|
2605
|
+
...opt
|
|
2606
|
+
}) : String(k));
|
|
2594
2607
|
const returnDetails = opt.returnDetails !== undefined ? opt.returnDetails : this.options.returnDetails;
|
|
2595
2608
|
const keySeparator = opt.keySeparator !== undefined ? opt.keySeparator : this.options.keySeparator;
|
|
2596
2609
|
const {
|
|
@@ -2837,6 +2850,10 @@ class Translator extends EventEmitter {
|
|
|
2837
2850
|
let usedLng;
|
|
2838
2851
|
let usedNS;
|
|
2839
2852
|
if (isString(keys)) keys = [keys];
|
|
2853
|
+
if (Array.isArray(keys)) keys = keys.map(k => typeof k === 'function' ? keysFromSelector(k, {
|
|
2854
|
+
...this.options,
|
|
2855
|
+
...opt
|
|
2856
|
+
}) : k);
|
|
2840
2857
|
keys.forEach(k => {
|
|
2841
2858
|
if (this.isValidLookup(found)) return;
|
|
2842
2859
|
const extracted = this.extractFromKey(k, opt);
|
|
@@ -3766,7 +3783,11 @@ const bindMemberFunctions = inst => {
|
|
|
3766
3783
|
});
|
|
3767
3784
|
};
|
|
3768
3785
|
const SUPPORT_NOTICE_KEY = '__i18next_supportNoticeShown';
|
|
3769
|
-
const getSupportNoticeShown = () =>
|
|
3786
|
+
const getSupportNoticeShown = () => {
|
|
3787
|
+
if (typeof globalThis !== 'undefined' && !!globalThis[SUPPORT_NOTICE_KEY]) return true;
|
|
3788
|
+
if (typeof process !== 'undefined' && process.env && process.env.I18NEXT_NO_SUPPORT_NOTICE) return true;
|
|
3789
|
+
return false;
|
|
3790
|
+
};
|
|
3770
3791
|
const setSupportNoticeShown = () => {
|
|
3771
3792
|
if (typeof globalThis !== 'undefined') globalThis[SUPPORT_NOTICE_KEY] = true;
|
|
3772
3793
|
};
|
|
@@ -3835,7 +3856,7 @@ class I18n extends EventEmitter {
|
|
|
3835
3856
|
this.options.overloadTranslationOptionHandler = defOpts.overloadTranslationOptionHandler;
|
|
3836
3857
|
}
|
|
3837
3858
|
if (this.options.showSupportNotice !== false && !usesLocize(this) && !getSupportNoticeShown()) {
|
|
3838
|
-
if (typeof console !== 'undefined' && typeof console.info !== 'undefined') console.info('🌐 i18next is
|
|
3859
|
+
if (typeof console !== 'undefined' && typeof console.info !== 'undefined') console.info('🌐 i18next is made possible by our own product, Locize — consider powering your project with managed localization (AI, CDN, integrations): https://locize.com 💙');
|
|
3839
3860
|
setSupportNoticeShown();
|
|
3840
3861
|
}
|
|
3841
3862
|
const createClassOnDemand = ClassOrObject => {
|
|
@@ -4098,21 +4119,20 @@ class I18n extends EventEmitter {
|
|
|
4098
4119
|
o.lngs = o.lngs || fixedT.lngs;
|
|
4099
4120
|
o.ns = o.ns || fixedT.ns;
|
|
4100
4121
|
if (o.keyPrefix !== '') o.keyPrefix = o.keyPrefix || keyPrefix || fixedT.keyPrefix;
|
|
4122
|
+
const selectorOpts = {
|
|
4123
|
+
...this.options,
|
|
4124
|
+
...o
|
|
4125
|
+
};
|
|
4126
|
+
if (typeof o.keyPrefix === 'function') o.keyPrefix = keysFromSelector(o.keyPrefix, selectorOpts);
|
|
4101
4127
|
const keySeparator = this.options.keySeparator || '.';
|
|
4102
4128
|
let resultKey;
|
|
4103
4129
|
if (o.keyPrefix && Array.isArray(key)) {
|
|
4104
4130
|
resultKey = key.map(k => {
|
|
4105
|
-
if (typeof k === 'function') k = keysFromSelector(k,
|
|
4106
|
-
...this.options,
|
|
4107
|
-
...opts
|
|
4108
|
-
});
|
|
4131
|
+
if (typeof k === 'function') k = keysFromSelector(k, selectorOpts);
|
|
4109
4132
|
return `${o.keyPrefix}${keySeparator}${k}`;
|
|
4110
4133
|
});
|
|
4111
4134
|
} else {
|
|
4112
|
-
if (typeof key === 'function') key = keysFromSelector(key,
|
|
4113
|
-
...this.options,
|
|
4114
|
-
...opts
|
|
4115
|
-
});
|
|
4135
|
+
if (typeof key === 'function') key = keysFromSelector(key, selectorOpts);
|
|
4116
4136
|
resultKey = o.keyPrefix ? `${o.keyPrefix}${keySeparator}${key}` : key;
|
|
4117
4137
|
}
|
|
4118
4138
|
return this.t(resultKey, o);
|