@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/esm/index.js
CHANGED
|
@@ -2037,7 +2037,7 @@ function createScreenReaderWrapper(options) {
|
|
|
2037
2037
|
wrapper.id = "fkui-alert-screen-reader";
|
|
2038
2038
|
wrapper.className = "sr-only";
|
|
2039
2039
|
updateProperties();
|
|
2040
|
-
document.body.
|
|
2040
|
+
document.body.append(wrapper);
|
|
2041
2041
|
}
|
|
2042
2042
|
}
|
|
2043
2043
|
/**
|
|
@@ -2254,7 +2254,7 @@ const deepFind = (obj, path, keySeparator = '.') => {
|
|
|
2254
2254
|
}
|
|
2255
2255
|
return current;
|
|
2256
2256
|
};
|
|
2257
|
-
const getCleanedCode = code => code?.replace(
|
|
2257
|
+
const getCleanedCode = code => code?.replace(/_/g, '-');
|
|
2258
2258
|
|
|
2259
2259
|
const consoleLogger = {
|
|
2260
2260
|
type: 'logger',
|
|
@@ -2515,7 +2515,16 @@ function keysFromSelector(selector, opts) {
|
|
|
2515
2515
|
const {
|
|
2516
2516
|
[PATH_KEY]: path
|
|
2517
2517
|
} = selector(createProxy());
|
|
2518
|
-
|
|
2518
|
+
const keySeparator = opts?.keySeparator ?? '.';
|
|
2519
|
+
const nsSeparator = opts?.nsSeparator ?? ':';
|
|
2520
|
+
if (path.length > 1 && nsSeparator) {
|
|
2521
|
+
const ns = opts?.ns;
|
|
2522
|
+
const nsArray = Array.isArray(ns) ? ns : null;
|
|
2523
|
+
if (nsArray && nsArray.length > 1 && nsArray.slice(1).includes(path[0])) {
|
|
2524
|
+
return `${path[0]}${nsSeparator}${path.slice(1).join(keySeparator)}`;
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
return path.join(keySeparator);
|
|
2519
2528
|
}
|
|
2520
2529
|
|
|
2521
2530
|
const checkedLoadedFor = {};
|
|
@@ -2589,6 +2598,10 @@ class Translator extends EventEmitter {
|
|
|
2589
2598
|
...opt
|
|
2590
2599
|
});
|
|
2591
2600
|
if (!Array.isArray(keys)) keys = [String(keys)];
|
|
2601
|
+
keys = keys.map(k => typeof k === 'function' ? keysFromSelector(k, {
|
|
2602
|
+
...this.options,
|
|
2603
|
+
...opt
|
|
2604
|
+
}) : String(k));
|
|
2592
2605
|
const returnDetails = opt.returnDetails !== undefined ? opt.returnDetails : this.options.returnDetails;
|
|
2593
2606
|
const keySeparator = opt.keySeparator !== undefined ? opt.keySeparator : this.options.keySeparator;
|
|
2594
2607
|
const {
|
|
@@ -2835,6 +2848,10 @@ class Translator extends EventEmitter {
|
|
|
2835
2848
|
let usedLng;
|
|
2836
2849
|
let usedNS;
|
|
2837
2850
|
if (isString(keys)) keys = [keys];
|
|
2851
|
+
if (Array.isArray(keys)) keys = keys.map(k => typeof k === 'function' ? keysFromSelector(k, {
|
|
2852
|
+
...this.options,
|
|
2853
|
+
...opt
|
|
2854
|
+
}) : k);
|
|
2838
2855
|
keys.forEach(k => {
|
|
2839
2856
|
if (this.isValidLookup(found)) return;
|
|
2840
2857
|
const extracted = this.extractFromKey(k, opt);
|
|
@@ -3764,7 +3781,11 @@ const bindMemberFunctions = inst => {
|
|
|
3764
3781
|
});
|
|
3765
3782
|
};
|
|
3766
3783
|
const SUPPORT_NOTICE_KEY = '__i18next_supportNoticeShown';
|
|
3767
|
-
const getSupportNoticeShown = () =>
|
|
3784
|
+
const getSupportNoticeShown = () => {
|
|
3785
|
+
if (typeof globalThis !== 'undefined' && !!globalThis[SUPPORT_NOTICE_KEY]) return true;
|
|
3786
|
+
if (typeof process !== 'undefined' && process.env && process.env.I18NEXT_NO_SUPPORT_NOTICE) return true;
|
|
3787
|
+
return false;
|
|
3788
|
+
};
|
|
3768
3789
|
const setSupportNoticeShown = () => {
|
|
3769
3790
|
if (typeof globalThis !== 'undefined') globalThis[SUPPORT_NOTICE_KEY] = true;
|
|
3770
3791
|
};
|
|
@@ -3833,7 +3854,7 @@ class I18n extends EventEmitter {
|
|
|
3833
3854
|
this.options.overloadTranslationOptionHandler = defOpts.overloadTranslationOptionHandler;
|
|
3834
3855
|
}
|
|
3835
3856
|
if (this.options.showSupportNotice !== false && !usesLocize(this) && !getSupportNoticeShown()) {
|
|
3836
|
-
if (typeof console !== 'undefined' && typeof console.info !== 'undefined') console.info('🌐 i18next is
|
|
3857
|
+
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 💙');
|
|
3837
3858
|
setSupportNoticeShown();
|
|
3838
3859
|
}
|
|
3839
3860
|
const createClassOnDemand = ClassOrObject => {
|
|
@@ -4096,21 +4117,20 @@ class I18n extends EventEmitter {
|
|
|
4096
4117
|
o.lngs = o.lngs || fixedT.lngs;
|
|
4097
4118
|
o.ns = o.ns || fixedT.ns;
|
|
4098
4119
|
if (o.keyPrefix !== '') o.keyPrefix = o.keyPrefix || keyPrefix || fixedT.keyPrefix;
|
|
4120
|
+
const selectorOpts = {
|
|
4121
|
+
...this.options,
|
|
4122
|
+
...o
|
|
4123
|
+
};
|
|
4124
|
+
if (typeof o.keyPrefix === 'function') o.keyPrefix = keysFromSelector(o.keyPrefix, selectorOpts);
|
|
4099
4125
|
const keySeparator = this.options.keySeparator || '.';
|
|
4100
4126
|
let resultKey;
|
|
4101
4127
|
if (o.keyPrefix && Array.isArray(key)) {
|
|
4102
4128
|
resultKey = key.map(k => {
|
|
4103
|
-
if (typeof k === 'function') k = keysFromSelector(k,
|
|
4104
|
-
...this.options,
|
|
4105
|
-
...opts
|
|
4106
|
-
});
|
|
4129
|
+
if (typeof k === 'function') k = keysFromSelector(k, selectorOpts);
|
|
4107
4130
|
return `${o.keyPrefix}${keySeparator}${k}`;
|
|
4108
4131
|
});
|
|
4109
4132
|
} else {
|
|
4110
|
-
if (typeof key === 'function') key = keysFromSelector(key,
|
|
4111
|
-
...this.options,
|
|
4112
|
-
...opts
|
|
4113
|
-
});
|
|
4133
|
+
if (typeof key === 'function') key = keysFromSelector(key, selectorOpts);
|
|
4114
4134
|
resultKey = o.keyPrefix ? `${o.keyPrefix}${keySeparator}${key}` : key;
|
|
4115
4135
|
}
|
|
4116
4136
|
return this.t(resultKey, o);
|