Skip to content

Commit

Permalink
docs: use gen-readme
Browse files Browse the repository at this point in the history
  • Loading branch information
TiagoDanin committed Feb 10, 2019
1 parent 409184a commit da29b23
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 22 deletions.
62 changes: 41 additions & 21 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
# NodeJS i18n [![Build Status](https://travis-ci.org/TiagoDanin/NodeJS-i18n.svg?branch=master)](https://travis-ci.org/TiagoDanin/NodeJS-i18n)
# NodeJS i18n
[![Version](https://img.shields.io/npm/v/nodejs-i18n.svg?style=flat-square)](https://npmjs.org/package/nodejs-i18n)
[![Downloads](https://img.shields.io/npm/dt/nodejs-i18n.svg?style=flat-square)](https://npmjs.org/package/nodejs-i18n)
[![Travis](https://img.shields.io/travis/TiagoDanin/NodeJS-i18n.svg?branch=master&style=flat-square)](https://travis-ci.org/TiagoDanin/NodeJS-i18n)

Minimalistic internationalization using gettext style for NodeJS.
Minimalistic internationalization using gettext style for NodeJS

## Features

- Gettext style
- Easy of use
- Gettext Style
- Easy Imprementation
- Create .po via CLI
- Select lang per user
- Select Lang per User

## Installation
Module available through the
[npm registry](https://www.npmjs.com/). It can be installed using the
[`npm`](https://docs.npmjs.com/getting-started/installing-npm-packages-locally)
or
[`yarn`](https://yarnpkg.com/en/)
command line tools.

## How to Use
```sh
# NPM
npm install nodejs-i18n --global
# Or Using Yarn
yarn global add nodejs-i18n
```

## Documentation
### Example
```javascript
const { Resources, Translation } = require('nodejs-i18n')
Expand All @@ -19,6 +35,7 @@ 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
```
Expand Down Expand Up @@ -56,7 +73,7 @@ String translation.

### CLI

Create .po file with `nodejs-i18n`. Example: add in package.json
Create .po files with `nodejs-i18n`. Add in your package.json

```json
"scripts": {
Expand All @@ -66,28 +83,31 @@ Create .po file with `nodejs-i18n`. Example: add in package.json

and run `$ npm run i18n`

## Installation

This is a [Node.js](https://nodejs.org/) module available through the
[npm registry](https://www.npmjs.com/). It can be installed using the
[`npm`](https://docs.npmjs.com/getting-started/installing-npm-packages-locally)
or
[`yarn`](https://yarnpkg.com/en/)
command line tools.
## Tests
To run the test suite, first install the dependencies, then run `test`:

```sh
npm install nodejs-i18n --save
# NPM
npm test
# Or Using Yarn
yarn test
```

## Dependencies

- [argv](https://ghub.io/argv): CLI Argument Parser
- [esprima](https://ghub.io/esprima): ECMAScript parsing infrastructure for multipurpose analysis
- [gettext-parser](https://ghub.io/gettext-parser): Parse and compile gettext po and mo files to/from json, nothing more, nothing less
- [tempy](https://ghub.io/tempy): Get a random temporary file or directory path

## Dev Dependencies

- [mocha](https://ghub.io/mocha): simple, flexible, fun test framework

## License
## Related
- [gettext-parser](https://ghub.io/gettext-parser): Parse and compile gettext po and mo files to/from json, nothing more, nothing less

MIT
## Contributors
Pull requests and stars are always welcome. For bugs and feature requests, please [create an issue](https://github.com/TiagoDanin/NodeJS-i18n/issues). [List of all contributors](https://github.com/TiagoDanin/NodeJS-i18n/graphs/contributors).


## License
[MIT](LICENSE) © [TiagoDanin](https://TiagoDanin.github.io)
55 changes: 55 additions & 0 deletions docs.md
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`
13 changes: 12 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,5 +45,16 @@
},
"devDependencies": {
"mocha": "5.2.0"
}
},
"features": [
"Gettext Style",
"Easy Imprementation",
"Create .po via CLI",
"Select Lang per User"
],
"preferGlobal": true,
"related": [
"gettext-parser"
],
"documentation": "./docs.md"
}

0 comments on commit da29b23

Please sign in to comment.