-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
409184a
commit da29b23
Showing
3 changed files
with
108 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
### Example | ||
```javascript | ||
const { Resources, Translation } = require('nodejs-i18n') | ||
|
||
const r = new Resources() | ||
r.load('pt', 'pt.po') | ||
|
||
var user = new Translation('pt') | ||
//i18n: My Hello World with NodeJs i18n | ||
var world = user._`world` // Mundo | ||
user._`Hello ${world}` // Olá mundo | ||
``` | ||
|
||
#### Options :: Resources({}) | ||
- **lang** - String | ||
> Lang id.</br> | ||
> Default value: `en` | ||
#### Options :: Resources({}).load(lang, file) | ||
Load translation | ||
|
||
- **lang** - String | ||
> Lang id.</br> | ||
- **file** - String | ||
> File path | ||
#### Options :: Resources({}).remove() | ||
Remove translation. | ||
|
||
- **lang** - String | ||
> Lang id.</br> | ||
#### Options :: Translation(lang) | ||
Select translation. | ||
|
||
- **lang** - String | ||
> Lang id.</br> | ||
#### Options :: Translation(lang).\_(string) | ||
String translation. | ||
|
||
- **String** - String | ||
|
||
### CLI | ||
|
||
Create .po files with `nodejs-i18n`. Add in your package.json | ||
|
||
```json | ||
"scripts": { | ||
"i18n": "find . | grep .js | sort | nodejs-i18n > en.po" | ||
} | ||
``` | ||
|
||
and run `$ npm run i18n` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters