Difficulties in achieving the translation of different elements to layers


  • Quote from klaus.krpano


    "It works the same way as for layers or other elements.
    Basically it works for all elements/objects and is independent of layer, hotspot or something else."

    Hi Klaus
    I have been trying to get the elements other than layers to be translated, but I can't make it happen, I have also tried for the tooltips, without result, I would also like to know how to direct the translation of popup contents
    This is my code:
    some base settings to which other elements will link to
    -->
    <base color="0xFFFFFF" color.onchange="trace('the color has been changed to: ',(tohexcolor(color)));" linewidth="1" bgroundedge="0" bgalpha="0.5" bgblur="5" spacing="8"/>

    <base color2="0x000000" color.onchange="trace('the color has been changed to: ',(tohexcolor(color)));" linewidth="1" bgroundedge="0" bgalpha="0.5" bgblur="5" spacing="8"/>

    <!-- different languages texts -->
    <languages name="es" displayname="Español" title="Centro de entrenamiento" subtitle="Espacio para los procesos de selección y capacitación continua"
    latsup="Maravillosa actualización" latinf="Difícil de entender [br]para quienes no somos codificadores[br] es un poco arduo[br] pero aprenderemos"
    emulhs="Texto capa"
    text="hotspot de texto"
    content="Puesto de Habilidades transversales"
    infoder="Información Centro de entrenamiento"
    language="Idioma" />
       
    <languages name="en" displayname="English" title="Training center" subtitle="Space for selection processes and continuous training"
    latsup="Wonderful update" latinf="Difficult to understand [br]for those of us who are not coders[br] it's a little arduous[br] but we will learn"
    emulhs="Layer text"
    text="text hotspot"
    hs1w="Post of transversal skills"
    content="Post of transversal skills"
    infoder="Training center Info"
    language="Language" />
       
    <!-- some styles for the elements -->
    <style name="text" type="text" textalign="center" bgcolor="link:base.color" bgalpha="0.0" css="link:base.color:'color:'+tohexcolor(base.color,'#')+';'" txtshadow="0 0 2 0x000000"/>

    <style name="button" style="link:text" padding="4 8" bgcolor="link:base.color" bgborder="link:base.color|base.linewidth:base.linewidth+' '+tohexcolor(base.color2)+' 0.5'" bgroundedge="link:base.bgroundedge:base.bgroundedge * 0.6" bgalpha="0.1" onover="bgalpha=0.3;" onout="bgalpha=0.1;"/>

    <style name="box" bgcolor="link:base.bgcolor" bgalpha="link:base.bgalpha" bgblur="link:base.bgblur" bgborder="link:base.color|base.linewidth:base.linewidth+' '+tohexcolor(base.color)+' 0.7'" bgroundedge="link:base.bgroundedge" bgshadow="link:base.color:'4 8 16 '+tohexcolor(colormix(base.color,0x000000,0.5))+' 0.5'" bgcapture="true" cursor="move"/>

    <style name="dragable" ondown="asyncloop(pressed, x+=mouse.dx; y+=mouse.dy; );"/>
       
    <!-- the example layers -->
    <layer name="encabezado" enabled="false" type="text" bg="false" textalign="center" css="link:base.color:'font-size:24px; color:'+tohexcolor(base.color,'#')+';'" width="80%" txtshadow="0 1 5 0x000000" template="{{translate(title)}}[div style='font-size:14px;line-height:20px;']{{translate(subtitle)}}[/div]" align="top" y="40"/>

    <layer name="simularhs" enabled="false" type="text" bg="true" textalign="center" css="link:base.color2:'font-size:10px; color:'+tohexcolor(base.color2,'#')+';'" width="10%" txtshadow="0 1 5 0x000000" template="[div style='font-size:26px;font-weight: bold;font-family:julius sans one;backgroundgcolor:0x000000;background:true;backgroundgalpha:1;line-height:20px;']{{translate(emulhs)}}[/div]" align="top" y="290"/>

    <layer name="lateralder" enabled="false" type="text" bg="false" textalign="right" css="link:base.color:'font-size:24px; color:'+tohexcolor(base.color,'#')+';'" width="80%" txtshadow="0 1 5 0x000000" template="{{translate(latsup)}}[div style='font-size:14px;line-height:20px;']{{translate(latinf)}}[/div]" align="righttop" x="20"/>

    <layer name="info" devices="normal" url="%VIEWER%/add_hotspot/picture/info.png" align="bottom" edge="bottom" x="" y="90" cssclass="shake2" scale="0.8" onhover="showtext(Información[br]Centro de[br]entrenamiento, style_julius);"
    template="{{translate(infoder)}}"
    onclick="popup3('html', get(data[centrenamiento].content), 600, 900, true );"
    />

    <layer name="languages" style="link:box|dragable" align="rightbottom" x="160" y="10" scale="0.7" type="container" flowchildren="h" flowchildrenexpand="true" childflowspacing="link:base.spacing" childmargin="link:base.spacing" onloaded="forall(languages,l, addlayer(auto,item); item.parent=name; item.linkstyle(button); item.text=l.displayname; item.onclick='set(language,' + l.name + ');'; );">
    <layer style="link:text" template="{{translate('language')}}" enabled="false"/>
    </layer>
    <!-- hotspots -->
    <hotspot name="hsp_0_2" style="text_hs_sm" type="text" ondown="drag_LinkSM();" width="135" height="38" bgshadow="0 0 0 0х000000 0.5" ath="3.3734" atv="-31.3049" html="hotspot de texto" bg="true" textwidth="135" textheight="38" textalign="left" text="hotspot de texto"
    template="[div style='text_hs_sm']{{translate(text)}}[/div]"
    />
    <hotspot name="hs1w" devices="desktop" ath="21.0218776" atv="25.7220750" style="callout"
    text_bg="true" callout_bg_color="0x00688f" callout_bg_alpha="0.5" rotate="1" distancepopup="3"
    line_lenght="230" text_width="auto" shape="round" callout_bg_border="0,1" text_x="1"
    text_padding="8 18 6 18" size="6" visible="true" alpha="1"
    title=""
    content="Puesto de Habilidades transversales"
    template="[div style='callout;']{{translate(content)}}[/div]" enabled=""
    />
    krpano - cEntrenamiento

  • Where to look in your code?

    Instead of posting some big code block, please reduce it only to the relevant parts and/or add some comments - what are you doing? What where your thoughts? Where is the problem that doesn't work?

    Or describe your needs exactly, then I can try making a small and clear example.

  • Thanks. I will try
    I am trying to use the new translation possibility. I have no problem doing it with layers. But I have some hotspots, some are callouts, others are text hotspots and others are for opening popups, as well as some tooltips that I would like to be able to translate. With none of these above I have been able to get them translated.
    You can look at the example cited.


    This hotspot: callout
    <hotspot name="hs1w" devices="desktop" ath="21.0218776" atv="25.7220750" style="callout"
    text_bg="true" callout_bg_color="0x00688f" callout_bg_alpha="0.5" rotate="1" distancepopup="3"
    line_lenght="230" text_width="auto" shape="round" callout_bg_border="0,1" text_x="1"
    text_padding="8 18 6 18" size="6" visible="true" alpha="1"
    title=""
    content="Puesto de Habilidades transversales"
    template="[div style='callout;']{{translate(content)}}[/div]" enabled=""
    />
    What I want is to locate what I am doing wrong and correct it to ensure that these elements other than layers get their translation

  • I think I see the problem - either remove the content variable here:

    Code
    <hotspot ...
    content="Puesto de Habilidades transversales"
    template="...{{translate(content)}}..."
    />

    change it to:

    Code
    <hotspot ...
    template="...{{translate(content)}}..."
    />


    Or quote the text 'content' in the translate call:

    Code
    <hotspot ...
    template="...{{translate('content')}}..."
    />


    Otherwise the content of the 'content' variable (*wacko**wink*) will be used for the translate call.

  • In the other text hotspot, I quoted the text 'text' , and the translation already worked


    <hotspot name="hsp_0_2" style="text_hs_sm" type="text" ondown="drag_LinkSM();" width="135" height="38" bgshadow="0 0 0 0х000000 0.5" ath="3.3734" atv="-31.3049" html="hotspot de texto" bg="true" textwidth="135" textheight="38" textalign="left" text="hotspot de texto"
    template="[div style='text_hs_sm']{{translate('text')}}[/div]"
    />

  • What is the style="callout" doing?

    Maybe that style was using that content variable...?

    If yes, don't remove it and just quote it.


    Or directly do it different - let's assume that 'callout' style does some automatic stuff and uses the text from the content variable - here a way to pass the translated text to it:

    Code
    <hotspot ...
    content="link:translate('content')"
    template="...{{content}}..."
    />

    But then there would be still the problem, that the callout might not get updated when the language changes. So for a full working solution, the callout code would need to be adjusted to support dynamic changes as well.

  • This is the callout code:
    <hotspot name="hs1w" devices="desktop" ath="21.0218776" atv="25.7220750" style="callout"
    text_bg="true" callout_bg_color="0x00688f" callout_bg_alpha="0.5" rotate="1" distancepopup="3"
    line_lenght="230" text_width="auto" shape="round" callout_bg_border="0,1" text_x="1"
    text_padding="8 18 6 18" size="6" visible="true" alpha="1"
    title=""
    content="Puesto de Habilidades transversales"
    />
    I have used it like this:
    <hotspot name="hs1w" devices="desktop" ath="21.0218776" atv="25.7220750" style="callout"
    text_bg="true" callout_bg_color="0x00688f" callout_bg_alpha="0.5" rotate="1" distancepopup="3"
    line_lenght="230" text_width="auto" shape="round" callout_bg_border="0,1" text_x="1"
    text_padding="8 18 6 18" size="6" visible="true" alpha="1"
    title=""
    content="Puesto de Habilidades transversales"
    template="[div style='callout']{{translate(content)}}[/div]"
    />

    And also like this:
    <hotspot name="hs1w" devices="desktop" ath="21.0218776" atv="25.7220750" style="callout"
    text_bg="true" callout_bg_color="0x00688f" callout_bg_alpha="0.5" rotate="1" distancepopup="3"
    line_lenght="230" text_width="auto" shape="round" callout_bg_border="0,1" text_x="1"
    text_padding="8 18 6 18" size="6" visible="true" alpha="1"
    title=""
    content="Puesto de Habilidades transversales"
    template="[div style='callout']{{translate('content')}}[/div]"
    />


    I also tried this

    <hotspot ...
    content="link:translate('content')"
    template="...{{content}}..."
    />

  • <callout
    key="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
    size=""
    color="0xffffff"
    rotate="45"
    distancepopup="3"
    min_fov="180"
    max_fov="0"
    line_lenght="100"
    line_width="1"
    shape="round"
    circle_active_width="5"
    animation="center_screen"
    text_width="300"
    callout_bg_border="0,0,0,2"
    text_x="10"
    css_title.desktop="color:#fff;font-size:14px;font-family: julius sans one;text-shadow: 2px 2px 5px #000000;"
    css_title.mobile="color:#fff;font-size:12px;font-family: julius sans one;"
    css_text.desktop="color:#fff;font-weight:light;font-size:14px;font-family: julius sans one;text-shadow: 2px 2px 5px #000000;"
    css_text.mobile="color:#fff;font-size:14px;font-family: julius sans one;text-shadow: 2px 2px 5px #000000;"
    title_background="0x398177"
    text_background=""
    title_padding="10"
    />

  • Hi,
    I could update the plugin with the new linking system, but then it won't work with previous versions of krpano.
    You can use the translate system but you'll have to recall the onloaded event of the callout hotspots.

  • Yes it's not an ideal solution, callouts are rebuilt.
    This code will display the callouts with the updated translation.
    But for a reason I don't get yet if the first hotspot of the scene is a callout hotspot then this one will only be displayed after moving the pano ... if it's the case just add a empty hotspot : <hotspot/>

    Code
    <action name="update_callouts">
    for(set(i,0), i LT hotspot.count, inc(i),
      if(hotspot[get(i)].style == 'callout', callwith(hotspot[get(i)],oncallin);set(hotspot[get(i)].ishighlighted, false);callwith(hotspot[get(i)],onloaded);)
    );
    </action>

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!