Skip to content

Commit

Permalink
Merge pull request #7 from zakkudo/cleanupPluralForms
Browse files Browse the repository at this point in the history
Cleanup plural forms
  • Loading branch information
zakkudo committed Sep 24, 2018
2 parents b40f930 + da8d347 commit ae88d3a
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 19 deletions.
4 changes: 2 additions & 2 deletions README.md
Expand Up @@ -99,7 +99,7 @@ Where `locales/fr.json` will look like this for use by your translators:
},
"There is one user": {
// src/pages/AboutPage/index.js:40
"default": {"one":"French translation", "other":"French translation"},
"default": {"1":"French translation", "2":"French translation"},
},
"Welcome to the about page!": {
// src/pages/AboutPage/index.js:38
Expand All @@ -115,7 +115,7 @@ And the optimized `src/.locales/fr.json` will look like this for use by your dev
"default": "French translation",
"menuitem": "French translation"
},
"There is one user": {"one":"French translation", "other":"French translation"},
"There is one user": {"1":"French translation", "2":"French translation"},
"Welcome to the about page!": "French translation"
}
```
Expand Down
4 changes: 2 additions & 2 deletions src/README.md
Expand Up @@ -99,7 +99,7 @@ Where `locales/fr.json` will look like this for use by your translators:
},
"There is one user": {
// src/pages/AboutPage/index.js:40
"default": {"one":"French translation", "other":"French translation"},
"default": {"1":"French translation", "2":"French translation"},
},
"Welcome to the about page!": {
// src/pages/AboutPage/index.js:38
Expand All @@ -115,7 +115,7 @@ And the optimized `src/.locales/fr.json` will look like this for use by your dev
"default": "French translation",
"menuitem": "French translation"
},
"There is one user": {"one":"French translation", "other":"French translation"},
"There is one user": {"1":"French translation", "2":"French translation"},
"Welcome to the about page!": "French translation"
}
```
Expand Down
14 changes: 12 additions & 2 deletions src/index.js
Expand Up @@ -54,14 +54,24 @@ function __p(context, key) {
* @private
*/
function __n(singular) {
return [toKeyWithContext(singular), {one: "", other: ""}];
return [toKeyWithContext(singular), {
// Singular form placeholder
"1": "",
// Plural form placeholder
"2": ""
}];
}

/**
* @private
*/
function __np(context, singular) {
return [toKeyWithContext(singular, context), {one: "", other: ""}];
return [toKeyWithContext(singular, context), {
// Singular form placeholder
"1": "",
// Plural form placeholder
"2": ""
}];
}

/**
Expand Down

0 comments on commit ae88d3a

Please sign in to comment.