HTML Localizer is a small tool allowing you to easily localize HTML text inside your HTML webpage dynamically during rendering.
- Lightweight simple localization module
- Automatically loads localized texts based on the navigator's locale
- Automatically translate HTML texts within tag (tag's name can be customized)
- No extra parsing needed
Edit localizer.js dictionary to add your text for each language you want to support:
var dictionary = {
"_": { // when language is not supported
"hello_world": "Not Translated!"
},
"en": {
"hello_world": "Hello World!"
},
"ja": {
"hello_world": "こんにちは!"
}
}
Here is the list of all Language Codes
Next, load the module at the top of your HTML page by simply importing the script:
<script src="./localizer.js" type="text/javascript"></script>
You're now ready to localize any HTML text inside your page! To do that, use the tag with the key attribute.
<localized-text key="hello_world"></localized-text>
If you want to force a specific language for your text to be localized, add the lang attribute.
<localized-text key="hello_world" lang="ja"></localized-text><
See example.html for an example about the usage.