You are not logged in.

Dear visitor, welcome to krpano.com Forum. If this is your first visit here, please read the Help. It explains in detail how this page works. To use all features of this page, you should consider registering. Please use the registration form, to register here or read more information about the registration process. If you are already registered, please login here.

1

Wednesday, June 2nd 2010, 8:50am

Multi-language support in panoramas

Hi,

I'm trying to think of a way to support multiple languages in my virtual tours but other than duplicating the entire xml files I couldn't think of any.


Is there any clever way of doing this? (i find duplicating all xml files is not a very good solution, just a hack around the problem).

It would be nice if we could just put all the strings used in the panoramas in a single XML file and refer the strings by some ID (alfa-numeric).
We could then duplicate this file for each language.

2

Monday, June 7th 2010, 5:49pm

Hi

You can do this using the <data> tag. Refer to the strings using the data's name. Then have 2 files where you define the same data values using different languages.
This method still has a small annoyance. Since there is nothing like a conditional include or so, for each panorama you will need to have 3 files: one with the main code for the panorama; and the other two including the main file and with the data definitions in the corresponding language. For instance:

Beach.xml - contains all the code for the panorama EXCEPT the string
Beach-en.xml - includes Beach.xml and defines all the data values for english
Beach-de.xml - includes Beach.xml and defines all the data values for german

Loading each of the Beach-XX.xml files gives you the panorama in a different language.
Strings which are shared across the panoramas (such as hover text for controls) can be placed on some other String-xx.xml file, which will be included in each of the "language" panorama files.

Hope it helps. I think there was some other thread in the forum discussing this.
Manuel
PanoTag: Facebook tagging for krpano

KRPano development and more: http://www.digisfera.pt/en/development

autiomaa

Beginner

Posts: 36

Location: Finland

Occupation: Photographer, Retoucher, Web Developer

  • Send private message

3

Thursday, June 10th 2010, 1:26am

Interesting, would be interested of hearing more about people's experiences related to multi-language support of krpano as I will probably have need to create multi-language versions of krpano tours in the future.

4

Thursday, June 10th 2010, 9:19am

emediquei, the problem is I don't see how I could change the language from within the panorama itself.
I would have to include xmls inside an if condition or something. I don't know if it is possible. Do you have any ideas on this?


Also, let's say I have my strings as custom data tags. How do I refer a string inside a showtext() instruction. Can you give an example?


Thanks,

5

Thursday, June 10th 2010, 1:39pm

To change the language, you would have to reload the photo, by loading either Beach-en.xml or Beach-de.xml . Each of them having the same <data> in a different language.


For instance, to display a hoverText on a hotspot:

in Beach.xml:
<hotspot ...
onhover="showText(get(data[buttonHoverText].content))" />

in Beach-en.xml:
<include url="Beach.xml/>

<data name="buttonHoverText">
<p>This is such a lovely beach</p>
</data>

in Beach-de.xml:
<include url="Beach.xml/>

<data name="buttonHoverText">
<p>Es ist so eine schoene Strand</p>
</data>

In additon, for buttons which are displayed on the entire tour, there could be two other files "Global-en.xml" and "Global-de.xml" which would be included in all the "PANO-lang.xml" files, such as Beach-en.xml and Beach-de.xml

Hope this helps!
PanoTag: Facebook tagging for krpano

KRPano development and more: http://www.digisfera.pt/en/development

6

Thursday, June 10th 2010, 1:47pm

Hi,
It would be nice if we could just put all the strings used in the panoramas in a single XML file and refer the strings by some ID (alfa-numeric).
We could then duplicate this file for each language.


you could do something like that:
building string tables for each language:

Source code

1
2
3
4
5
6
7
8
9
10
11
<strings name="english"
         text1="Hello"
         text2="This text is written in English."
         ...
         />
	
<strings name="german"
         text1="Hallo"
         text2="Das ist ein deutscher Text."
         ...
         />


and using an variable for the current language - e.g:

Source code

1
set(language,english);


and then getting the wanted string by:

Source code

1
get(strings[get(lanuage)].text1)


here an usage example:

Source code

1
2
3
4
5
6
7
set(language,english);
trace('text1=', get(strings[get(language)].text1) );
trace('text2=', get(strings[get(language)].text2) );
		
set(language,german);
trace('text1=', get(strings[get(language)].text1) );
trace('text2=', get(strings[get(language)].text2) );



or if you want a numeric index for each string:

Source code

1
2
3
4
5
6
7
8
9
<strings name="english">
  <string name="0" text="Hello" />
  <string name="1" text="This text is written in English." />
</strings>
	
<strings name="german">
  <string name="0" text="Hallo" />
  <string name="1" text="Das ist ein deutscher Text." />
</strings>
and:

Source code

1
2
3
4
5
6
7
set(language,english);
trace('text1=', get(strings[get(language)].string[0].text) );
trace('text2=', get(strings[get(language)].string[1].text) );
		
set(language,german);
trace('text1=', get(strings[get(language)].string[0].text) );
trace('text2=', get(strings[get(language)].string[1].text) );


best regards,
Klaus

Tuur

Sage

Posts: 3,113

Location: Netherlands

Occupation: Krpano custom coding / Virtual Tours / Photography / Musician / Recording engineer

  • Send private message

7

Thursday, June 10th 2010, 2:01pm

Nice!

i had a nice way for this but the language selection is made before the tour..

This one will work on the fly, doesn't it?

Great!

Tuur *thumbsup*
http://www.virtualtuur.com
Skype:studiotuur

8

Thursday, June 10th 2010, 3:01pm

Hi,
This one will work on the fly, doesn't it?
it depends how you use it,
when using showtext() it would work intermediately,
but for static texts (e.g. in textfields) you would need to update the texts manually after the language change,

best regards,
Klaus

N'drew

Beginner

Posts: 17

Location: RUSSIA

Occupation: IT engineer

  • Send private message

9

Friday, December 17th 2010, 7:23pm

strings

Source code

1
2
3
4
<strings name="SAINT">
	<string name="12" text="var1" />
	<string name="n12" text="var2" />
</strings>


Why when i use

Source code

1
trace(get(strings[SAINT].string[12].text));


it return "var2"?

10

Monday, December 20th 2010, 11:10am

Hi,

Source code

1
<string name="12" text="var1" />


note - a number is not a valid name for an element!
when using a number it will be interpreted as index,

best regards,
Klaus

herrpedro

Trainee

Posts: 134

Location: Lisbon

Occupation: Programmer/analyst

  • Send private message

11

Saturday, September 29th 2018, 6:35pm

Hi, recovering this from a long time but i want to achieve is multilanguage
this is my structure
i'm always messing with if's and get's and nulls and can't get it straight, sorry


<itemdata name="name1" youtube="-someId">
<language name="pt" sound="pt/17.mp3" text="name 1 in pt" />
<language name="en" sound="en/17.mp3" text="name 1 in en" />
<language name="es" sound="es/17.mp3" text="name 1 in es" />
</itemdata>

<itemdata name="name2" youtube="otherId" text="testname2">
<language name="pt" sound="pt/18.mp3" text="name 2 in pt" />
<language name="en" sound="en/18.mp3" text="name 2 in en" />
<language name="es" sound="es/18.mp3" text="name 2 in es" />
</itemdata>


heres the action
%1 is the name of itemData
%2 is the attribute to get in the language
the current language is in "lang" variable


<action name="getLanguageContent">
if (lang === null ,
set(lang , 'ptPT');
);

subtxt(justLanguage , lang , 0 , 2) ;
tolower(justLanguage);

set(defaultLabelId , calc('itemdata[%1].%2' )) ;
set(labelId , calc('itemdata[%1].language[' + lang + '].%2' )) ;
set(labelIdNoCountry , calc('itemdata[%1].language[' + justLanguage + '].%2' )) ;

set (labelIdResult , get(labelId));
set (labelIdNoCountryResult , get(labelIdNoCountry));
set (defaultLabelIdResult , get(defaultLabelId));

if (get(labelIdResult) == get(labelId) ,
if( get(labelIdNoCountryResult) == get(labelIdNoCountry) ,
set ( %3 , defaultLabelIdResult );
,
set ( %3 , get(labelIdNoCountryResult) );
)
,
set ( %3 , get(labelIdResult) );
);

</action>




the supposed behaviour would be
if language is ptPT go check if there is a "language" with name = ptPT.
- if there is, check if there is the attribute %2.
- if it exists return the value of it.
- if it does not exists check for the presence in the language pt
- if it does not exist return the "root" value


getLanguageContent('name2' , 'text') would return testname2 because there is no more specific language to it (there is no language ptPT or language pt with that attribute.. so it gets the top one
getLanguageContent('name1' , 'sound') would return pt/17.mp3 because there is no more specific language to it (there is no ptPT so it ould get the pt


if tried with
=== null
!= null
this version is equal to the "get" of the parent variable because i see in the trace they are the same
i dont know what to do more

trace of the resultvariable that are set prior to the If's
INFO: 1 itemdata[name1].language[ptPT].text
INFO: 2 name 1 in pt
INFO: 3 itemdata[name1].text

trace of %3

INFO: itemdata[name1].language[ptPT].text


it is more an IF problem and variable presence problem than language but.. sorry.. i cannot find a way for this to work

hope someone helps

thank you for your time