@zeesoft/i18n-verify 3.3.9 → 3.4.1
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/executor.mjs +16 -1
- package/package.json +1 -1
package/dist/executor.mjs
CHANGED
|
@@ -3455,6 +3455,7 @@ const insight = () => `// insights content
|
|
|
3455
3455
|
data.untranslatedStrings +
|
|
3456
3456
|
data.partialStrings,
|
|
3457
3457
|
'Not Internationlized Strings': data.notLocalizedStrings,
|
|
3458
|
+
'Partially Localized Strings': data.partialStrings,
|
|
3458
3459
|
'Internationlized Numbers': data.localizedNumber,
|
|
3459
3460
|
'Not Internationlized Numbers': data.notLocalizedNumber,
|
|
3460
3461
|
'Internationlized Currency': data.localizedCurrency,
|
|
@@ -6472,7 +6473,17 @@ class StringValidator extends BaseValidator {
|
|
|
6472
6473
|
* @returns {Promise<Boolean>}
|
|
6473
6474
|
*/
|
|
6474
6475
|
isPartiallyLocalizedText(string) {
|
|
6475
|
-
|
|
6476
|
+
const detectionResult = detectTextLangEx(string);
|
|
6477
|
+
const scores = detectionResult?.scores || {};
|
|
6478
|
+
const currLang = this.currentLanguage();
|
|
6479
|
+
const sortedMatches = Object.entries(scores).filter(([lang]) => lang).sort((a, b) => b[1] - a[1]);
|
|
6480
|
+
if (sortedMatches.length === 0) {
|
|
6481
|
+
return false;
|
|
6482
|
+
}
|
|
6483
|
+
const topDetectedLang = sortedMatches[0]?.[0];
|
|
6484
|
+
const topScore = sortedMatches[0]?.[1];
|
|
6485
|
+
const threshold = Config.getPartiallyLocalizedScoreThreshold();
|
|
6486
|
+
return topDetectedLang === currLang && topScore > threshold;
|
|
6476
6487
|
}
|
|
6477
6488
|
/**
|
|
6478
6489
|
* detects given string language code
|
|
@@ -6873,11 +6884,15 @@ class Config {
|
|
|
6873
6884
|
}
|
|
6874
6885
|
static build() {
|
|
6875
6886
|
Config.#driver = build$1(Config.#type, Config.#driver);
|
|
6887
|
+
Config.#executor = null;
|
|
6876
6888
|
Config.resetCounter();
|
|
6877
6889
|
}
|
|
6878
6890
|
static getGarbledChars() {
|
|
6879
6891
|
return [...Config.#options.garbledChars || [], ...GARBLED_CHARACTERS];
|
|
6880
6892
|
}
|
|
6893
|
+
static getPartiallyLocalizedScoreThreshold() {
|
|
6894
|
+
return Config.#options.partiallyLocalizedScoreThreshold ?? 0.3;
|
|
6895
|
+
}
|
|
6881
6896
|
static getL10nReportsPath() {
|
|
6882
6897
|
return Config.#options.l10nReportsPath;
|
|
6883
6898
|
}
|
package/package.json
CHANGED