clevershovel avatar

Translation management for SteemRandomDraw

clevershovel

Published: 08 Apr 2018 › Updated: 08 Apr 2018Translation management for SteemRandomDraw

Translation management for SteemRandomDraw

SteemRandomDraw is application that automate the draw.

i18next

I have added support of i18next plugin for jquery. i18next loads is needed translation so we just need to choose language. The translations stores in json files in language directory. This makes it easier to translate into other languages.
Also I have added russian language so if someone want to use this language you are welcome.
image.png

Code

It is the main code for translation management (later it was modified by deadzy@deadzy). i18next load json files from subdirectories of directory /languages. All elements in index.html with attribute 'data-i18n' have the pair key-value in translation files with the the same key as the value of attribute. The elements with class 'lang-select' call a function that changes the language to the text of element.

+       i18next
+           .use(window.i18nextXHRBackend)
+           .init({
+               lng: 'en',
+               backend: {
+                   loadPath: './locales/{{lng}}/{{ns}}.json'
+               }
+               }, function(err, t) {
+               jqueryI18next.init(i18next, $);
+               $(document).localize();
+           
+               $('.lang-select').click(function() {
+                   i18next.changeLanguage(this.innerHTML, function() {
+                   $(document).localize();
+                   });
+               });
+           });

Contact

if you have some suggestions about russian translation write it here or contact me on discord CleverShovel#7855




Posted on Utopian.io - Rewarding Open Source Contributors

Leave Translation management for SteemRandomDraw to:

Written by

Making some technical stuff also puzzles

Read more #utopian-io posts


Best Posts From clevershovel

We have not curated any of clevershovel's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From clevershovel