Skip to content

Latest commit

History

55 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

🚀 Express Translify 🚀

A drop-in translation module for real-world Express applications 🌍

  • 🪄 Drop-in(no refactoring needed)
  • 🪶 Lightweight(< 19 KB)
  • Fast(smart client-side caching)

1. 📦 Installation

$ npm install express-translify

2. 🌐 Specify Your Languages & Terms to Translate

  • 📝 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! 🎉

✍️ Placeholders in Terms

Use [...] to mark dynamic parts in your terms:

"terms": [
"Hello, [...]!",
"You have [...] new messages"
]

[...] means "leave this part out" - it won't be translated.

3. 🛠️ Generate Your Locales

$ npx translate

Need a custom output path? Use the --out option 🛣️:

$ npx translate --out custom-path

4. 🧩 Use Our Express Middleware

consttranslify=require("express-translify");app.use(translify());

Using a custom locales path? Pass it in with the path option 🗂️:

app.use(translify({path: "custom-path"}));

5. 📥 Import Translify Into Your Website

<!-- Our middleware automatically serves all necessary assets --><scriptsrc="/translify.js"></script>

Note: If a term matches the page title, document.title is translated too.

6. 🧭 Switching Languages at Runtime

translify("de");// 🇩🇪 Switches to German

7. 🎉 Enjoy Translations in Your App

That's it! Your Express app now speaks multiple languages - no refactoring, no stress. 🌍✨

About

A drop-in translation module for real-world Express applications

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages