Translation management for SteemRandomDraw

Words
163
Reading
1 min
Listen
Play
8y

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

Translation management for SteemRandomDraw | Ecency