Skip to content

easy way to add multilanguage banner

Unsolved Customisation
  • What is the easiest way to add multi-language banners? Such as the banner in chat boxes or HTML boxes in general…

    Screen Shot 2023-09-01 at 15.21.59.png

    Our users are mainly either from Turkey or from the USA, so I would like to show Turkish banners to users in Turkey, and the rest will see the banners in English. I wonder what would be the easiest way to achieve this?

  • What is the easiest way to add multi-language banners? Such as the banner in chat boxes or HTML boxes in general…

    Screen Shot 2023-09-01 at 15.21.59.png

    Our users are mainly either from Turkey or from the USA, so I would like to show Turkish banners to users in Turkey, and the rest will see the banners in English. I wonder what would be the easiest way to achieve this?

    @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 an if 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.

  • 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 👏

  • @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 an if statement to select the appropriate banner language based on the response.

    @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.”

  • @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?

  • @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…

  • @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.

  • @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.

  • @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 😃

  • @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 interested to know how you got on with this.

  • @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.


Related Topics
  • Please help me, I can't install nodebb

    Locked Solved Customisation
    7
    5 Votes
    7 Posts
    253 Views
    Installation completed, verified, and tested. Correct installation methodology is below https://docs.nodebb.org/installing/os/ubuntu/
  • Sudonix and fediverse

    Solved Customisation
    16
    4 Votes
    16 Posts
    605 Views
    @Panda said in Sudonix and fediverse: Federation will have huge advantages, especially for starting off forums that would otherwise be quiet, because it can bring in posts from similar sites to increase content. Can’t say I agree with this statement. To me, if I visit a new forum, I’d much rather be viewing original content rather than that which I can easily consume elsewhere. I understand that new forums are often empty with not much content, but the growth needs to be organic rather than ingested from elsewhere to make it look busy. Using RSS feeds to pull in content from remote sites is fine as long as you use it for reading reference and create a discussion around the topic you are referring to (as I do with Sudonix), but absolutely pointless if you include the entire article and all associated responses - you may as well just visit the origin site instead. Another issue is SEO and the impact duplicated content will have on your own forum when it comes to Google indexing your site. Duplicated content negatively impacts SEO and in addition, that same content may be proprietary meaning you need permission to include it on your site. Potentially, it’s a legal minefield which should be treated with trepidation to ensure no copyright infringement takes place.
  • NodeBB recent cards customisation

    Solved Customisation
    3
    1
    2 Votes
    3 Posts
    216 Views
    @phenomlab thank you very much for the assistance Mark, massively appreciated as always. The great thing about this is it’s all documented for other NodeBB users that come looking for solutions . Looks far better .
  • 3 Votes
    6 Posts
    942 Views
    @kadir-ay-0 marking as resolved based on https://community.nodebb.org/topic/17109/manual-build-a-night-mode-for-harmony/5 Please do not raise requests in two places - here and the NodeBB forums. All this does is create unnecessary load for both parties.
  • 1 Votes
    1 Posts
    410 Views
    No one has replied
  • [NODEBB] Help for my custom CSS

    Solved Customisation
    218
    44 Votes
    218 Posts
    37k Views
    Ohh super ^^ Thank you Mark
  • [NODEBB] Scroll Button

    Solved Customisation
    7
    1
    0 Votes
    7 Posts
    980 Views
    @downpw ooops. Forgot that. Thanks for adding.
  • [NODEBB] Welcome Message

    Solved Customisation
    20
    2
    13 Votes
    20 Posts
    3k Views
    @DownPW the ‘js’ code for the banner takes the time from the client, so what it displays really depends on the regional settings for the operating system. I’ve not seen this issue myself but would like to see some examples of screenshots if possible.