mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-11 20:40:20 +00:00
Updated 18next exists method and added ability to use string interpolation arguments (#16124)
* Updated i18next extists function definition and allow for additional interpolation options to be passed as TranslationOptions * Updated 18next test * i18next fixed typing of exists key parameter * i18next Fixed test typo
This commit is contained in:
committed by
Sheetal Nandi
parent
c4077c19e4
commit
8e24694620
@@ -10,12 +10,14 @@ i18n.init({
|
||||
resources: {
|
||||
en: {
|
||||
translation: {
|
||||
helloWorld: 'Hello, world!'
|
||||
helloWorld: 'Hello, world!',
|
||||
helloWorldInterpolated: 'Hello, {{name}}!'
|
||||
}
|
||||
},
|
||||
ru: {
|
||||
translation: {
|
||||
helloWorld: 'Привет, мир!'
|
||||
helloWorld: 'Привет, мир!',
|
||||
helloWorldInterpolated: 'Привет, {{name}}!'
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -61,6 +63,14 @@ i18n.t('helloWorld', <i18n.TranslationOptions> {
|
||||
count: 10
|
||||
});
|
||||
|
||||
i18n.t('helloWorldInterpolated', <i18n.TranslationOptions> {
|
||||
defaultValue: 'default',
|
||||
count: 10,
|
||||
name: "world"
|
||||
});
|
||||
|
||||
i18n.exists("helloWorld");
|
||||
|
||||
const options:i18n.Options = i18n.options;
|
||||
const currentLanguage:string = i18n.language;
|
||||
const userLanguageCodes:string[] = i18n.languages;
|
||||
|
||||
Vendored
+3
-1
@@ -49,6 +49,8 @@ declare namespace i18n {
|
||||
joinArrays?: string;
|
||||
postProcess?: string | any[];
|
||||
interpolation?: InterpolationOptions;
|
||||
//add an indexer to assure that interpolation arguments can be passed
|
||||
[x: string]: any;
|
||||
}
|
||||
|
||||
interface Options {
|
||||
@@ -106,7 +108,7 @@ declare namespace i18n {
|
||||
|
||||
t(key: string, options?: TranslationOptions): string | any | Array<any>;
|
||||
|
||||
exists(): boolean;
|
||||
exists(key: string, options?: TranslationOptions): boolean;
|
||||
|
||||
setDefaultNamespace(ns: string): void;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user