diff --git a/node-polyglot/index.d.ts b/node-polyglot/index.d.ts index 9ea2c09a48..7587f77640 100644 --- a/node-polyglot/index.d.ts +++ b/node-polyglot/index.d.ts @@ -15,6 +15,8 @@ declare namespace Polyglot { interface PolyglotOptions { phrases?: any; locale?: string; + allowMissing?: boolean; + onMissingKey?: (key: string, options?: Polyglot.InterpolationOptions, locale?: string) => string; } } diff --git a/node-polyglot/node-polyglot-tests.ts b/node-polyglot/node-polyglot-tests.ts index f9d4879328..bfb18339c0 100644 --- a/node-polyglot/node-polyglot-tests.ts +++ b/node-polyglot/node-polyglot-tests.ts @@ -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 {