mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-06 13:11:46 +00:00
+ Add the allowMissing parameter in PolyglotOptions (#13757)
+ Add the onMissingKey parameter in PolyglotOptions
This commit is contained in:
committed by
Sheetal Nandi
parent
37e76515c1
commit
652c54beeb
Vendored
+2
@@ -15,6 +15,8 @@ declare namespace Polyglot {
|
||||
interface PolyglotOptions {
|
||||
phrases?: any;
|
||||
locale?: string;
|
||||
allowMissing?: boolean;
|
||||
onMissingKey?: (key: string, options?: Polyglot.InterpolationOptions, locale?: string) => string;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user