A drop-in translation module for real-world Express applications 🌍
- 🪄 Drop-in(no refactoring needed)
- 🪶 Lightweight(< 19 KB)
- ⚡ Fast(smart client-side caching)
$ npm install express-translify- 📝 Head into your
package.json - ➕ Add your Translify options:
{// ..."translify": {"default": "en",// default value is "en""languages": ["de",// 🇩🇪"es",// 🇪🇸"zh",// 🇨🇳// ...],"terms": ["Welcome!","Lorem ipsum...",// ...]}}✨ Or, if you prefer, you can simply provide a path to an external config file like "translify.json" to keep things neat and separate:
{
"translify": "translify.json"
}This way, you get all the flexibility without cluttering your package.json! 🎉
Use [...] to mark dynamic parts in your terms:
"terms": [
"Hello, [...]!",
"You have [...] new messages"
]
[...]means "leave this part out" - it won't be translated.
$ npx translateNeed a custom output path? Use the --out option 🛣️:
$ npx translate --out custom-pathconsttranslify=require("express-translify");app.use(translify());Using a custom locales path? Pass it in with the path option 🗂️:
app.use(translify({path: "custom-path"}));<!-- Our middleware automatically serves all necessary assets --><scriptsrc="/translify.js"></script>Note: If a term matches the page title,
document.titleis translated too.
translify("de");// 🇩🇪 Switches to GermanThat's it! Your Express app now speaks multiple languages - no refactoring, no stress. 🌍✨