An open API service indexing awesome lists of open source software.

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

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
Beautiful downtown apartment
```

```html

Root level
Unaffected


```

## Issues
Not possible to serve vocabulary file from a different domain out of the box. Additional webserver configuration is required.