We build. You grow.

Get best community software here

Start a social network, a fan-site, an education project with oxwall - free opensource community software

How to make custom HTML blocks translatable? | Forum

Ilja
Ilja Jul 18 '15
When I put a custom HTML block in User Dashboard it displays in one language only. While site is multilingual everyone sees the same text, not adopted to their language.


How do you guys solve that?

tammy harris
tammy harris Jul 18 '15
i have not tryed this but you should be able to search the text in admin languages n translate it there 


ross Team
ross Jul 19 '15
You need to do that manually

You need to use javascript in order to show a certain block of the text. For example


You have 3 languages on your website


You type some text in the default English in the custom hmlt widget

Now you need to do the translation to other 2 languages and do the mark up


like this: 


<div #English>

some text

</div>

<div # German>

some text

</div>

<div #French>

some text

</div>


Then apply the js code which tracks which item is chosen in the lang drop down menu and show the corresponding block of your html


Hope I made it clear for you

The Forum post is edited by ross Jul 19 '15
IntrigU
IntrigU Feb 27 '16
Ross,


Can you share the Javascript code?

ross Team
ross Mar 1 '16
Topic was moved from General Questions.
tammy harris
tammy harris Mar 1 '16
have you try make a new language key and add that to html block and translate it 
Ilja
Ilja Mar 1 '16
Tammy, how can you add language key to HTML block? That could be a good solution if possible
IntrigU
IntrigU Mar 1 '16

This is the only way to get this working as of version 1.8.1. Lang tags won't work in the widget.


1. Add hidden style to your theme custom css: 


.hidden { display: none; }


2. Copy and paste this into the HTML block. Replace the content within divs and titles in JS with your own. 


<div id="en_text" class="hidden">

<p align="center"><a href="https://www.intrigu.com/join" class="btn btn-danger btn-lg" role="button">Join for FREE now</a>

</div>


<div id="es_text" class="hidden">

Spanish Content

</div>


<div id="pt_text" class="hidden">

Portuguese content

</div>


<div id="fr_text" class="hidden">

French Content

</div>


<div id="ru_text" class="hidden">

Russian content

</div>



<script>var lang=document.documentElement.lang;

if (lang.indexOf("ru-RU")>=0){

$("#ru_text").removeClass('hidden');

document.getElementsByClassName('ow_ic_warning')[0].innerHTML="Russian Title";

else

if (lang.indexOf("en")>=0){

$("#en_text").removeClass('hidden');

document.getElementsByClassName('ow_ic_warning')[0].innerHTML="English Title";

}

else

if (lang.indexOf("es-ES")>=0){

$("#es_text").removeClass('hidden');

document.getElementsByClassName('ow_ic_warning')[0].innerHTML="Spanish Title";

}

else

if (lang.indexOf("fr-FR")>=0){

$("#fr_text").removeClass('hidden');

document.getElementsByClassName('ow_ic_warning')[0].innerHTML="French Title";

}

else

if (lang.indexOf("pt-pt")>=0){

$("#pt_text").removeClass('hidden');

document.getElementsByClassName('ow_ic_warning')[0].innerHTML="Portuguese Title";

}

</script>

The Forum post is edited by IntrigU Mar 1 '16
tammy harris
tammy harris Mar 1 '16
Lang tags won't work in the widget.

well thats pretty stupid 

This is the only way to get this working as of version 1.8.1.

so langs in html use to work ?? 
IntrigU
IntrigU Mar 1 '16
Not that I am aware of
Ilja
Ilja Mar 3 '16
Terry, thanks, that's actually pretty the same as ross proposed. It's probably a workaround, but sad Oxwall doesn't have it done normally.
IntrigU
IntrigU Mar 6 '16
Agree!
OW-Ghost
OW-Ghost Mar 19 '16
it did work in desktop version but when i try in mobile version it not works and i guess mobiles not supports java scripts as standard?


so please help how to implement code like this for the text/html boxes for mobile version?

IntrigU
IntrigU Mar 20 '16
Marcus, this should also work in mobile version. Can you list out your steps - I'll see if I can troubleshoot.
OW-Ghost
OW-Ghost Mar 20 '16
i did send you a PM but no reply back??
IntrigU
IntrigU Mar 20 '16
You will need to add .hidden { display: none; } to your mobile theme css. Don't think there is a way to do this from the Admin Panel, so I suggest you locate and edit the css file using an FTP client or CPanel.
OW-Ghost
OW-Ghost Mar 21 '16
ahaa okey i understand. so this code will bee overwrite all the time a updates comes. that really sucks. what about add a option to add css code to mobile theme to? i think we need wait long time for that happen


anyways thank you Terry for the help so far. i hope they implememnt this in the core in future for all html/text widgets for mobile version and desktop version

The Forum post is edited by OW-Ghost Mar 21 '16
IntrigU
IntrigU Sep 8 '16
Hi guys,


New plugin that gives you multilingual HTML widget. Support for mobile version coming soon.


https://developers.oxwall.com/store/item/1325

The Forum post is edited by IntrigU Oct 13 '16
OW-Ghost
OW-Ghost Sep 9 '16
I will wait for the mobile support then i will buy it 100% because the design looks good.
IntrigU
IntrigU Sep 9 '16
Mobile is supported now. Enjoy!


https://developers.oxwall.com/store/item/1325

Pages: 1 2 »