diff --git a/types/i18n/i18n-tests.ts b/types/i18n/i18n-tests.ts index 8f6deb423c..a24e4d4300 100644 --- a/types/i18n/i18n-tests.ts +++ b/types/i18n/i18n-tests.ts @@ -137,6 +137,16 @@ i18n.__({ phrase: 'Hello {{name}}', locale: 'fr' }, { name: 'Marcus' }); // Salu * __n() * https://github.com/mashpie/i18n-node#__n */ +// short syntax +// global (this.locale == 'de') +i18n.__n("%s cat", 1); // 1 Katze +i18n.__n("%s cat", 3); // 3 Katzen + +// scoped via req object (req.locale == 'de') +req.__n("%s cat", 1); // 1 Katze +req.__n("%s cat", 3); // 3 Katzen + +// long syntax // global (this.locale == 'de') i18n.__n("%s cat", "%s cats", 1); // 1 Katze i18n.__n("%s cat", "%s cats", 3); // 3 Katzen diff --git a/types/i18n/index.d.ts b/types/i18n/index.d.ts index ee0f3d584f..7390a44850 100644 --- a/types/i18n/index.d.ts +++ b/types/i18n/index.d.ts @@ -192,6 +192,14 @@ declare namespace i18n { //#region __n() + /** + * Translate with plural condition the given phrase and count using locale configuration + * @param phrase - Short phrase to be translated. All plural options ("one", "few", other", ...) have to be provided by your translation file + * @param count - The number which allow to select from plural to singular + * @returns The translated phrase + */ + function __n(phrase: string, count: number): string; + /** * Translate with plural condition the given phrase and count using locale configuration * @param options - Options for plural translate @@ -346,6 +354,14 @@ interface i18nAPI { //#region __n() + /** + * Translate with plural condition the given phrase and count using locale configuration + * @param phrase - Short phrase to be translated. All plural options ("one", "few", other", ...) have to be provided by your translation file + * @param count - The number which allow to select from plural to singular + * @returns The translated phrase + */ + __n(phrase: string, count: number): string; + /** * Translate with plural condition the given phrase and count using locale configuration * @param options - Options for plural translate