Add short syntax to i18n.__n

This commit is contained in:
Lukas Kullmann
2019-02-05 09:24:07 +01:00
parent c807902931
commit 3a06372dc1
2 changed files with 26 additions and 0 deletions
+10
View File
@@ -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
+16
View File
@@ -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