i18n4e is a package that offers a modern, quick and easy way to add internationalization support to your Express Js application.
npm install i18n4e
or
yarn add i18n4e
<script src="https://cdn.jsdelivr.net/npm/i18n4e/client-dist/i18n4e.min.js"></script>
or
<script src="/node_modules/i18n4e/client-dist/i18n4e.min.js"></script>
To see the full documentation, please visit the official documentation.
-
Install the package
npm install i18n4e
-
Import the package
const {i18n4e} = require('i18n4e');
-
Create a _locales folder in the root of your project and add the locales files
project βββ node_modules βββ package.json βββ index.js βββ _locales βββ en β βββ translation.json βββ pt_br β βββ translation.json βββ es βββ translation.json
-
Add variables in the translation.json files for each language
βββ en/translation.json
{
"hello-world": "Hello World!"
}
βββ pt_br/translation.json
{
"hello-world": "OlΓ‘ Mundo!"
}
βββ es/translation.json
{
"hello-world": "Hola Mundo!"
}
-
In your view files (example: index.ejs or index.html) add i18nID attributes to the elements you want to translate
<h1 i18nID="hello-world">Hello World!</h1>
-
Start i18n4e on your file by passing your app express
i18n4e.init(app,{ defaultLang:'en', // define the main language })
use this example. Its done! Now your application is ready to be translated into multiple languages.
For more examples and configurations, please visit the Examples.
i18n4e, created with β€οΈ by Luiisp, is a package with the philosophy of demystifying the difficulty of implementing i18n in web applications. At a high level, you can make various complex configurations using only boolean options.
- Modern syntax written with typescript
- Fast and Scalable Execution
- ES6/ESM and Common Js support
- Easy to use
- Change language by session support
- HTML/EJS support
We have several ready-made project examples using i18n4e that you can view and use as you wish.
We welcome contributions to the i18n4e project! If you would like to contribute, please follow these steps:
- Fork the repository on GitHub.
- Clone your forked repository to your local machine.
- Create a new branch for your changes.
- Make your desired changes to the codebase.
- Test your changes to ensure they work as expected.
- Commit your changes and push them to your forked repository.
- Submit a pull request to the main i18n4e repository.
Please make sure to follow our contribution guidelines and adhere to our code of conduct when contributing.
We appreciate your contributions and look forward to working with you!
Thanks goes to all these wonderful people:
This project is licensed under the MIT License - see the LICENSE file for details
inspired by chrome.i18n
Created with β€οΈ by luiisp