Sie sind nicht angemeldet.

1

Mittwoch, 2. Juni 2010, 08:50

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

Montag, 7. Juni 2010, 17:49

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

Anfänger

Beiträge: 36

Wohnort: Finland

Beruf: Photographer, Retoucher, Web Developer

  • Nachricht senden

3

Donnerstag, 10. Juni 2010, 01:26

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

Donnerstag, 10. Juni 2010, 09:19

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

Donnerstag, 10. Juni 2010, 13:39

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

Donnerstag, 10. Juni 2010, 13:47

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:

Quellcode

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:

Quellcode

1
set(language,english);


and then getting the wanted string by:

Quellcode

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


here an usage example:

Quellcode

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:

Quellcode

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:

Quellcode

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

Erleuchteter

Beiträge: 3 021

Wohnort: Netherlands

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

  • Nachricht senden

7

Donnerstag, 10. Juni 2010, 14:01

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

Donnerstag, 10. Juni 2010, 15:01

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

Anfänger

Beiträge: 17

Wohnort: RUSSIA

Beruf: IT engineer

  • Nachricht senden

9

Freitag, 17. Dezember 2010, 19:23

strings

Quellcode

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


Why when i use

Quellcode

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


it return "var2"?

10

Montag, 20. Dezember 2010, 11:10

Hi,

Quellcode

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

Schüler

Beiträge: 131

Wohnort: Lisbon

Beruf: Programmer/analyst

  • Nachricht senden

11

Samstag, 29. September 2018, 18:35

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