i18n-dialect
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -18,4 +18,4 @@ import { Descriptor, Scalar } from './types'; | ||
protected getUntranslatedFallback(descriptor: Descriptor): string[]; | ||
protected selectPluralForm(forms: string[], descriptor: Descriptor, forceUntranslated: boolean): string; | ||
protected substituteStrings(str: string, descriptor: Descriptor): string; | ||
protected selectPluralForm(forms: string[], descriptor: Descriptor, forceUntranslated: boolean): string | undefined; | ||
protected substituteStrings(str: string | undefined, descriptor: Descriptor): string; | ||
protected makeNewDict(items: I18NEntry[]): { | ||
@@ -22,0 +22,0 @@ [key: string]: string[]; |
@@ -101,3 +101,10 @@ "use strict"; | ||
TranslationController.prototype.substituteStrings = function (str, descriptor) { | ||
var tmpStr = str; | ||
var tmpStr = str || ''; | ||
// Fallback, than everything went wrong | ||
if (!tmpStr.length) { | ||
if (this.onFailedSubstitution) { | ||
this.onFailedSubstitution('', descriptor.substitutions); | ||
} | ||
return descriptor.msgid; | ||
} | ||
// substitute optional parameters | ||
@@ -113,3 +120,3 @@ descriptor.substitutions.forEach(function (value, index) { | ||
if (this.onFailedSubstitution && tmpStr.match(/%\d+/)) { | ||
this.onFailedSubstitution(str, descriptor.substitutions); | ||
this.onFailedSubstitution(str || '', descriptor.substitutions); | ||
} | ||
@@ -116,0 +123,0 @@ return tmpStr; |
{ | ||
"name": "i18n-dialect", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Internationalization support library", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -97,3 +97,3 @@ import { Descriptor, Scalar } from './types'; | ||
// Select proper plural form based on descriptor | ||
protected selectPluralForm(forms: string[], descriptor: Descriptor, forceUntranslated: boolean): string { | ||
protected selectPluralForm(forms: string[], descriptor: Descriptor, forceUntranslated: boolean): string | undefined { | ||
switch (descriptor.type) { | ||
@@ -116,5 +116,13 @@ case '_t': | ||
// Substitute parameters to %1, %2, etc and %% placeholders | ||
protected substituteStrings(str: string, descriptor: Descriptor): string { | ||
let tmpStr = str; | ||
protected substituteStrings(str: string | undefined, descriptor: Descriptor): string { | ||
let tmpStr = str || ''; | ||
// Fallback, than everything went wrong | ||
if (!tmpStr.length) { | ||
if (this.onFailedSubstitution) { | ||
this.onFailedSubstitution('', descriptor.substitutions); | ||
} | ||
return descriptor.msgid; | ||
} | ||
// substitute optional parameters | ||
@@ -132,3 +140,3 @@ descriptor.substitutions.forEach((value, index) => { | ||
if (this.onFailedSubstitution && tmpStr.match(/%\d+/)) { | ||
this.onFailedSubstitution(str, descriptor.substitutions); | ||
this.onFailedSubstitution(str || '', descriptor.substitutions); | ||
} | ||
@@ -135,0 +143,0 @@ |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
184603
19
864