Is there a way to have different RAW HTML Snippets for different languages?  I would like to have different languages for the HTML, or different HTML altogether.  An example would be creating "Share" buttons.  I would like to show Facebook and Twitter for English users but since those are not available in China, I would like to show Weibo and QQ for Chinese users. Thank you.

I checked the "Watch our Video" snippet and figured out that I can have HTML text translation using [[ text ]] and translate that from the backend.  Is it possible then to wrap an entire block of HTML (and Javascript) text in [[ ]] and "translate" that?

Problem solved.  I have the text of an HTML element enclosed by [[ ]] and then a js program to take a different path depends on its value.  Then all I have to do is translate that one string. Is there a better way to do that?

Hi kcpau, there are probably lots of different ways you could do this. You could use a different layout for each language. Or, you can make a Flexible Nest plugin that shows different things depending on a condition (though this is a bit advanced). Or, you could use some logic in JavaScript, e.g.:if (zenario.langId == 'zh-hans' || zenario.langId == 'zh-hant') {    // Add Weibo and QQ} else {    // Add Facebook and Twitter} Or, you could do it the way you've done it.

I like the idea of using zenario.langId (I did not know that there is such a property available).  Thanks.

Hello Chris, I tried to use zenario.langId but I got the message that it is undefined.  Can you tell me where that is defined?  Thanks.

You'll need to make sure that your JavaScript is running after the page has been loaded. If you try and run JavaScript while the page is still being generated you'll run into two problems:

  • Non of the variables will be defined yet.
  • Your page will load more slowly, and you'll get bad SEO.
The easiest way to do this is to edit the HTML at the foot of the page and place your JavaScript code there.

I was finally able to use zenario.langId by using the window.onload method.  If would have been easier if $(document).ready is available but it looks like jQuery is not loaded until the Footer portion.  Is there any reason why jQuery was not loaded earlier, just curious.

It's for speed and SEO reasons. If you try to load a JavaScript library (such as jQuery) at the top or in the middle of the page then the browser will stop rendering the page until the script has finished downloading and running. This results in a slower page load. Search engines such as Google actively look out for this and demote pages that are slow to load in their rankings. Both of these are bad so we keep the JavaScript until the end.

That is a good explanation.  Thank you.

You must confirm your screen name on your profile in order to comment.

Please Login if you wish to add a comment.