Is it possible to translate the showtext field with a dynamic variable?
xml =
onhover="showtext([h3]%$TEXT_BE_TRANSLATED%[/h3]);"
and then adding it through the initvars? Or do I need to inject it with javascript?
Has anyone done this before?
translate a showtext with a dynamic variable
-
-
Hi Tuur,
Can you be more specific?
There are different ways of doing such. Use the search of the forum and you'll find some.where is the language selection happening? In krpano world or web page..
Tuur
-
I am building an application that is available in 2 languages, the pano contains several scenes and within each scene there are a lot of hotspots...
When the visitors hovers over a hotspot I want to show a label in the current language, all the labels are defined in the database... so passing it with an invitvars seems to more logical option to me... the language selection is happening in the webpage. -
isn't it better to 'php' the xml and input directly from the database? .. like:
while ($row = mysqli_fetch_array($result, MYSQLI_ASSOC)){
$rows[] = $row;}
foreach($rows as $row){
$id2 = $row['name'];}
echo "<hotspot .. blabla.. onhover=\"".$id2."\"
.. but then with showtext syntax obviously.
or perhaps you want/need to set the language by initvar yes.. _lang and from there pickup the right var from database like above perhaps.
Not directly my expertise though.. but I had it working nicely a few years ago in a project.perhaps if(_lang == ENG, hotspot[bla].onhover = show text( \"".$id2."\" but then with right syntax obviously.
Hope it helps and makes sense..
Tuur -
I recently translated ArtPlacer.
I wanted a database free approach as the tool should be used without a database.
The way I approached the problem was to have an XML with all the translations:
Code<krpano> <translation name="Toggle Artplacer Editor" text="Abrir/Cerrar Editor de Artplacer" /> <translation name="width:" text="Ancho:" /> <translation name="height:" text="Altura:" /> ... </krpano>
And in the XML I used "get:" to fetch the translation like this:
Code<layer type="text" textalign="center" name="btnToggleArtplacerEditor" style="artplacer_editor_button_black" text="get:translation[Toggle Artplacer Editor].text" />
not sure if it helps you, but maybe you get inspiration from it :)
K.
-
I use multi languages quite often but not by database and mostly just within krpano.
it is fairly simple then and there are different ways to go.You could easily call the data container, or var, blabla_nl or blabla_eng and construct the show text.. like
showtext(calc('blabla_' + _lang), MYSTYLE);
or something like that..
many many options
The _lang could come from initvars and the text from the database like above...Tuur
-
You can have a look at my project.
There are thousands of texts in two languages. I am using a multi-XML solution as well as language variables.
-
Okay I've solved the problem with Tuur his hint :)
I am building my $initvar array in PHP dynamicallyCode$initvar = [ 'label_to_translate_1' => 'Eerste label in het Nederlands', 'label_to_translate_2' => 'Tweede label in het Nederlands', 'label_to_translate_3' => 'Derde label in het Nederlands', ];
the passing it with a json_encoded array to the pano
and in the pano
that's it, that's all! -
Looks a bit strange to me to it that way, but if that works for your setup.. i'm glad i could help.
Tuur
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!