+ Add the allowMissing parameter in PolyglotOptions (#13757)

+ Add the onMissingKey parameter in PolyglotOptions
This commit is contained in:
Jean-Philippe Lachance
2017-01-12 09:42:44 -08:00
committed by Sheetal Nandi
parent 37e76515c1
commit 652c54beeb
2 changed files with 18 additions and 0 deletions
+2
View File
@@ -15,6 +15,8 @@ declare namespace Polyglot {
interface PolyglotOptions {
phrases?: any;
locale?: string;
allowMissing?: boolean;
onMissingKey?: (key: string, options?: Polyglot.InterpolationOptions, locale?: string) => string;
}
}
+16
View File
@@ -5,6 +5,22 @@ function instantiatePolyglot(): void {
var polyglot = new Polyglot();
var phrasedPolyglot = new Polyglot({phrases: {"hello": "Hello"}});
var localePolyglot = new Polyglot({locale: "fr"});
var allowMissingPolyglot = new Polyglot({
phrases: {"hello": "Hello"},
allowMissing: true
});
var onMissingKeySimplePolyglot = new Polyglot({
phrases: {"hello": "Hello"},
onMissingKey: (key: string): string => {
return 'ouups!';
}
});
var onMissingKeyComplexPolyglot = new Polyglot({
phrases: {"hello": "Hello"},
onMissingKey: (key: string, options: Polyglot.InterpolationOptions, locale: string): string => {
return 'ouups!';
}
});
}
function translate(): void {