1.2.0 • Published 3 years ago

i18n-ryla v1.2.0

Weekly downloads
71
License
MIT
Repository
github
Last release
3 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

3 years ago

1.1.8

3 years ago

1.1.7

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.1.6

3 years ago

1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.0.33

3 years ago

1.0.32

3 years ago

1.0.30

3 years ago

1.0.29

3 years ago

1.0.28

3 years ago

1.0.27

3 years ago

1.0.25

3 years ago

1.0.24

3 years ago

1.0.23

3 years ago

1.0.22

3 years ago

1.0.21

3 years ago

1.0.20

3 years ago

1.0.19

3 years ago

1.0.18

3 years ago

1.0.17

3 years ago

1.0.16

3 years ago

1.0.15

3 years ago

1.0.14

3 years ago

1.0.13

3 years ago

1.0.12

3 years ago

1.0.11

3 years ago

1.0.10

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago