Skip to content

Commit

Permalink
Merge pull request #1 from akinjide/master
Browse files Browse the repository at this point in the history
fix(i18n): minor fix to grammar
  • Loading branch information
eslam-mahmoud authored Jun 17, 2017
2 parents 6df7f66 + be03947 commit f5ede17
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# i18n-nodejs

I18n module for node, out of frustration with over complicated modules for translation & localization I created this module with simplicity in mind.
i18n module for node, out of frustration with over complicated modules for translation & localization, I created this module with simplicity in mind.

## Install

Expand Down Expand Up @@ -46,7 +46,7 @@ console.log(i18n.__('Welcome')); // output => 'اهلا'

The module will try to find the translation using the language abbreviation if could not find it will return the original text.

### variables
### Variables
If the text has `variable` that need to be translated you should add the the text like `{{name}}` and you need to pass the translated value of that `variable` as second arg into the `__()` function.
```js
//Language file
Expand All @@ -71,7 +71,7 @@ console.log(i18n.__("Welcome {{name}}", {name: "اسلام"}));
// output => 'مرحبا اسلام'
```

If you do not want to write the tranlation directly in your code (wich you should not do) you should add the value and its translation the langauage file and use it like that
If you do not want to write the translation directly in your code (which you should not do) you should add the value and its translation the language file and use it like that
```js
console.log(i18n.__("Welcome {{name}}", {name: i18n.__("eslam")}));
// output => 'مرحبا اسلام'
Expand All @@ -80,9 +80,9 @@ console.log(i18n.__("Welcome {{name}}", {name: i18n.__("eslam")}));
## Pluralization
Starting form version `2.0.0` we now support pluralization, First let us describe the problem let say we want to display "Hi Eslam, you have 555 points", but if you want to display that text in arabic the word "points" will have 5 different possibilities to be rendered in as it is the rule in Arabic language in case of plural each of them depend on the number before the word.

So instesd of writing it as
So instead of writing it as
```js
//this is worng
//this is wrong
"Hi {{name}}, you have {{points_count}} points"
```
You should pass the count to the variable as `{{var||var_count}}`
Expand All @@ -93,7 +93,7 @@ i18n.__(
points_count: 555
}
```
As you see we passed the variable `name` aslo we passed the `points_count` in two places
As you see we passed the variable `name` also we passed the `points_count` in two places
- where we want it to be displayed
- where we need to handle the pluralization after `||`
Expand Down Expand Up @@ -123,7 +123,7 @@ You can find all the rules in [this localization guide](http://localization-guid
There is a note also as you can see we did not submit the `points` variable in the values object as second param for `__(string, values object)` because now the module is smarter and will look first for the translation in the values param then if it is not there will look for it in the file set in the constructor
## Summary of updates
-Version 2.0.0 support pluralization, remove the dependency to other packages to make it even simpler and light for your app and if you passed any values for any variable in the second param it will overwrite the original value in the translation file.
- Version 2.0.0 support pluralization, remove the dependency to other packages to make it even simpler and light for your app and if you passed any values for any variable in the second param it will overwrite the original value in the translation file.
## Links
- [pluralization rules guide](http://localization-guide.readthedocs.org/en/latest/l10n/pluralforms.html)
Expand Down

0 comments on commit f5ede17

Please sign in to comment.