1.2.0 • Published 4 years ago

i18n-ryla v1.2.0

Weekly downloads
71
License
MIT
Repository
github
Last release
4 years ago

i18n-ryla

Used for internationalization of ExpressJS api's based on the Accept-Language of the headers.

How to install

npm install i18n-ryla

Create a languages folder with localization json files and config.json

-node-modules
-server.js
-languages
    |
    ---> config.json
    |
    ---> en-us.json
    |
    ---> pt-br.json

An example of a json localization file would be:

// en-us.json
{
    "hello_world": "Hello World!"
}
// pt-br.json
{
    "hello_world": "Olá Mundo!"
}

config.json is required to have at least the default language

// config.json
{
    "default": "en-us" // or pt-pt, pt-br... just make sure you have the corresponding json file
}

In config.json we can also choose if we want to return a similar language if no language on the system is the same as that of the user. Put resemblance = true in config.json

Example: user has only the pt-pt language and the system only pt-br and the default is en-us. In this case with the true resemblance the system returns pt-br instead of en-us.

// config.json
{
    "default": "en-us", // or pt-pt, pt-br... just make sure you have the corresponding json file
    "resemblance": true // optional
}

When you need a multilingual message, import i18n:

const i18n = require('i18n-ryla')

app.use(i18n.message)

app.get('/', (req, res)=>{
    res.send(req.message.hello_world)
})
1.2.0

4 years ago

1.1.8

4 years ago

1.1.7

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.1.6

4 years ago

1.1.5

4 years ago

1.1.4

4 years ago

1.1.3

4 years ago

1.1.2

4 years ago

1.0.33

4 years ago

1.0.32

4 years ago

1.0.30

4 years ago

1.0.29

4 years ago

1.0.28

4 years ago

1.0.27

4 years ago

1.0.25

4 years ago

1.0.24

4 years ago

1.0.23

4 years ago

1.0.22

4 years ago

1.0.21

4 years ago

1.0.20

4 years ago

1.0.19

4 years ago

1.0.18

4 years ago

1.0.17

4 years ago

1.0.16

4 years ago

1.0.15

4 years ago

1.0.14

4 years ago

1.0.13

4 years ago

1.0.12

4 years ago

1.0.11

4 years ago

1.0.10

4 years ago

1.0.9

4 years ago

1.0.8

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago