You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using EO TranslatorJS on a DOM element is just as simple. Mark the target element or elements that you want to translate the contents of, and then leave the rest for EO TranslatorJS.
192
+
193
+
```html
194
+
<!-- The eo-translator attribute is the marker that tells EO TranslatorJS to translate the element, the value that's passed to it is the translation key -->
195
+
196
+
<!-- eo-translator-params holds the parameters. It must be valid JSON object. -->
197
+
<span
198
+
id="target"
199
+
eo-translator="greeting"
200
+
eo-translator-params='{ "name": "Luffy" }'
201
+
></span>
202
+
203
+
<script>
204
+
// Creating a dictionary object
205
+
var dict = {
206
+
en: { greeting:"Hello, {name}!" }
207
+
};
208
+
209
+
// Creating a translator object
210
+
var translator =newEOTranslator(dict);
211
+
212
+
// Getting the HTML element
213
+
var target =document.getElementById("target");
214
+
215
+
// Translating the element
216
+
translator.translateElement(target);
217
+
</script>
218
+
```
219
+
220
+
Or you can simply translate the entire document;
221
+
222
+
```js
223
+
translator.translateDOM();
224
+
```
225
+
123
226
## Credits
124
227
125
228
Icon made by [Freepik](https://www.freepik.com/) from [Flaticon](https://www.flaticon.com/) and is licensed by [Creative Commons BY 3.0](http://creativecommons.org/licenses/by/3.0/).
0 commit comments