Skip to content

easy way to add multilanguage banner

Unsolved Customisation
12 2 2.4k 1
  • 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
  • External Links - New Window

    Solved Customisation nodebb links settings
    8
    2 Votes
    8 Posts
    595 Views
    @Sampo2910 search the forum here for ogproxy which is the client side version of that plugin I wrote. It’s in use here on this forum.
  • Please help me, I can't install nodebb

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

    Unsolved Customisation fancybox zoom image
    2
    1
    0 Votes
    2 Posts
    635 Views
    @DownPW Technically, it should be possible with the addition of the below Toolbar: { display: { left: ["infobar"], middle: [ "zoomIn", "zoomOut", "toggle1to1", "rotateCCW", "rotateCW", "flipX", "flipY", ], right: ["slideshow", "thumbs", "close"], }, }, Meaning your code block becomes function fancybox() { if (top.location.pathname !== '/login') { $(document).ready(function() { $('a').not('.forum-logo').not(".avatar").not(".emoji").not(".bmac-noanimate").each(function() { $('a[href*=".jpg"], a[href*=".jpeg"], a[href*=".png"], a[href*=".gif"], a[href*=".webp"], a[href*=".svg"]').addClass("noanimate"); }); }); Fancybox.bind( 'a[href*=".jpg"], a[href*=".jpeg"], a[href*=".png"], a[href*=".gif"], a[href*=".webp"], a[href*=".svg"]', { Toolbar: { display: { left: ["infobar"], middle: [ "zoomIn", "zoomOut", "toggle1to1", "rotateCCW", "rotateCW", "flipX", "flipY", ], right: ["slideshow", "thumbs", "close"], }, }, } ); } } Note, that you just need to add/remove the elements in the toolbar you do not need. Obviously, zoomIn and zoomOut are the ones you are specifically interested in. However, if Fancybox detects that the image has already been zoomed as far as possible, then this will not work. You’d need an external library such as zoom.js to add this functionality, or perhaps simpler https://www.jacklmoore.com/zoom/ A good example of how you’d make these two independent libraries work together is below https://codepen.io/ezra_siton/pen/VgrjKw It’s worth nothing that this specific code is based on Fancybox 3, so may need to be refactored to work with the latest version 5.
  • 3 Votes
    6 Posts
    2k 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
    832 Views
    No one has replied
  • [NODEBB] Help for my custom CSS

    Solved Customisation nodebb css bugfix
    237
    49 Votes
    237 Posts
    93k Views
    @baris said: You should change your selectors so it doesn’t look at the entire document. You probably only want to apply fancybox to stuff inside the #content element which is what changes when the user navigates around the page. So use $('#content a').... for your selectors then the forum logo in the header won’t be selected. I modified the JS Fancybox code now and this code and it seem better // --------------------------------------------- // Fancybox Media Reader (Without Website Logo) // --------------------------------------------- if (top.location.pathname !== '/login') { $(window).on('action:posts.loaded', function(data) { console.log("Polling DOM for lazyLoaded images to apply Fancybox"); $(document).ready(function() { $('#content a').not('.forum-logo').not(".avatar").not(".emoji").not(".bmac-noanimate").each(function() { $('#content a[href*=".jpg"], #content a[href*=".jpeg"], #content a[href*=".png"], #content a[href*=".gif"], #content a[href*=".webp"]').addClass("noanimate"); }); }); }); } if (top.location.pathname !== '/login') { $(document).ready(function() { $(window).on('action:ajaxify.end', function(data) { $('#content a').not('.logo').not(".avatar").not(".emoji").not(".bmac-noanimate").each(function() { $('#content a[href*=".jpg"], #content a[href*=".jpeg"], #content a[href*=".png"], #content a[href*=".gif"], #content a[href*=".webp"]').addClass("noanimate"); data.preventDefault() // Strip out the images contained inside blockquotes as this looks nasty :) $('#content blockquote img').remove(); }); Fancybox.bind( '#content a[href*=".jpg"], #content a[href*=".jpeg"], #content a[href*=".png"], #content a[href*=".gif"], #content a[href*=".webp"]', { groupAll: true, } ); }); }); } // Chat fancybox - fires when chat module loaded and AJAX calls new chat $(document).ready(function() { $(window).on('action:chat.loaded', function(data) { // >>> Se limiter au contenu principal uniquement <<< $('#content img').not('.forum-logo').not(".avatar").not(".emoji").not(".bmac-noanimate").each(function() { var newHref = $(this).attr("src"); $(this).wrap("<a class='fancybox' href='" + newHref + "'/>"); $('#content a[href*=".jpg"], #content a[href*=".jpeg"], #content a[href*=".png"], #content a[href*=".gif"], #content a[href*=".webp"]').addClass("noanimate"); data.preventDefault(); // Strip out the images contained inside blockquotes as this looks nasty :) $('#content blockquote img').remove(); }); Fancybox.bind( '#content a[href*=".jpg"], #content a[href*=".jpeg"], #content a[href*=".png"], #content a[href*=".gif"], #content a[href*=".webp"]', { groupAll: true, } ); }); }); For the logo, I must use overflow: visible !important; on [component="brand/logo"] /* --- Logo --- */ [component="brand/logo"] { max-height: 50px; width: auto; height: auto; max-width: 100%; display: block; object-fit: contain; object-position: left center; overflow: visible !important; } Better result !!
  • [NODEBB] Scroll Button

    Solved Customisation css javascript html scroll button
    7
    1
    0 Votes
    7 Posts
    2k Views
    @downpw ooops. Forgot that. Thanks for adding.
  • [NODEBB] Welcome Message

    Solved Customisation css html nodebb
    20
    2
    13 Votes
    20 Posts
    6k 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.