4th Street Bar Hive-Bar

Hive-Bar Powered by Hive beta-fdb5b5b

Community post

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). 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

62 upvotes $24.29

Replies (6)

Review before signing

Posting as . Signing with . Keychain permission: Posting. Hive Keychain will ask you to approve this action next.


  
Technical details

Operation fingerprint: