https://github.com/umkus/translate.js
Painless drop-in client-side translation
https://github.com/umkus/translate.js
Last synced: 3 months ago
JSON representation
Painless drop-in client-side translation
- Host: GitHub
- URL: https://github.com/umkus/translate.js
- Owner: Umkus
- License: mit
- Created: 2016-04-06T16:57:44.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2016-04-07T08:08:15.000Z (over 10 years ago)
- Last Synced: 2025-01-28T11:48:00.243Z (over 1 year ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# translate.js
Painless client-side drop-in internationalization without dependencies.
## How it works
The script replaces marked tags' content with matching strings from the vocabulary json file.
The target translation language is determined based on the client browser settings.
See the demo [here](http://umkus.com/translate.js/demo.html).
## Usage
1. Prepare the `vocabulary.json` file like the following:
```json
{
"hello_world": {
"en": "Hello, world!",
"it": "Ciao mondo!",
"es": "¡Hola Mundo!",
"fr": "Bonjour le monde!"
}
}
```
2. Include `translate.js` in the page's ``:
```html
```
3. Make sure the contents of `data-translate-vocabulary` is a uri to the `vocabulary.json`
4. Mark the tags with translatable content with `data-translate="hello_world"`
## Examples
```html
The cake is a lie
```
```html
Mike's burgers
```
```html
```
```html
Root levelUnaffected
```
## Issues
Not possible to serve vocabulary file from a different domain out of the box. Additional webserver configuration is required.