Thank you Mark, the changes look fantastic!!
easy way to add multilanguage banner
-
@crazycells seeing as the message is hard coded in the function itself, you could just have two lines - one for English, and one for Turkish.
If you can supply the language, I’ll code it for you.
If you’d like something a bit more elegant, then you’d need to leverage geo services or attempt to detect the language in use on the connecting operating system to then present the correct language.
Something like this would probably be sufficient. It’s native
js
rather thanjQuery
var userLanguage = navigator.language || navigator.userLanguage; console.log("The user's language is: " + userLanguage);
Using the result of this, which would be something like
en-US
you could then use anif
statement to select the appropriate banner language based on the response. -
Actually, for other writings/texts on the forum, we are using a plugin I created, and this plugin does not do anything else but provides translation according to the user’s language of choice.
Let’s say this plugin is
nodebb-plugin-translationplugin
So, when I install the “feed” plugin and put a “feed” icon on the navigation bar, I use this as “Text:”
[[translationplugin:feed]]So, according to the user’s language, it either puts “feed” in English or translation of it… Can we achieve similar things for HTML boxes?
this is the plugin in case you would like to check:
https://github.com/YesilkartForum/nodebb-plugin-ceviri/tree/master/languages“ceviri” means “translation” in Turkish.
-
@crazycells thanks. The principle is the same, and we will effectively be handling in the same manner, although a plugin in this instance would be overkill in the sense that we only need to detect the extending visitor language once and then use that as a token for sessions going forward.
Nice plugin though! Very clever way of using
json
strings to convert text -
@phenomlab said in easy way to add multilanguage banner:
If you can supply the language, I’ll code it for you.
Can we think about an HTML box that is added to the forum “globally”, so it can be reached from all pages…
As an example, we can do:
tr “Bu Turkce bir uyaridir.”
en-GB “This is an English announcement.”
-
@crazycells yes, are you referring to using this in a widget?
-
@phenomlab said in easy way to add multilanguage banner:
@crazycells yes, are you referring to using this in a widget?
yes, in a widget. is that harder to achieve?
Since I was planning to put several different announcements (which might change form or purpose later), and since I cannot bother you every time I want to change a detail I thought it is easier to achieve this way…
-
@crazycells said in easy way to add multilanguage banner:
yes, in a widget. is that harder to achieve?
No, not at all. In this case, you could use the plugin you already have and leverage that. No point in reinventing the wheel! Providing the plugin is global in scope (which it looks to be) then you could easily call the translation in the same way as you are doing already elsewhere in the forum.
-
@phenomlab oh ok, well, I have never used it in a HTML box, so I was not sure how to implement it… But I will try directly like that and report back Thanks.
-
@crazycells ok, let me know
-
@crazycells interested to know how you got on with this.
-
@phenomlab hi Mark, no worries. I will definitely write my experience here…
Unfortunately, I could not find time to try it yet.