https://github.com/dinoscapeprogramming/express-translify
A drop-in translation module for real-world Express applications
https://github.com/dinoscapeprogramming/express-translify
Last synced: 10 months ago
JSON representation
A drop-in translation module for real-world Express applications
- Host: GitHub
- URL: https://github.com/dinoscapeprogramming/express-translify
- Owner: DinoscapeProgramming
- License: mit
- Created: 2025-07-17T17:54:25.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2025-08-12T08:24:26.000Z (11 months ago)
- Last Synced: 2025-08-12T10:15:34.694Z (11 months ago)
- Language: JavaScript
- Size: 33.2 KB
- Stars: 1
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# ð 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
```sh
$ npm install express-translify
```
## 2. ð Specify Your Languages & Terms to Translate
* ð Head into your `package.json`
* â Add your Translify options:
```js
{
// ...
"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:
```json
{
"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:
```json
"terms": [
"Hello, [...]!",
"You have [...] new messages"
]
```
> `[...]` means "leave this part out" - it won't be translated.
## 3. ð ïļ Generate Your Locales
```sh
$ npx translate
```
Need a custom output path? Use the `--out` option ðĢïļ:
```sh
$ npx translate --out custom-path
```
## 4. ð§Đ Use Our Express Middleware
```js
const translify = require("express-translify");
app.use(translify());
```
Using a custom locales path? Pass it in with the `path` option ðïļ:
```js
app.use(translify({ path: "custom-path" }));
```
## 5. ðĨ Import Translify Into Your Website
```html
```
> **Note:** If a term matches the page title, `document.title` is translated too.
## 6. ð§ Switching Languages at Runtime
```js
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. ðâĻ