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

Friday, October 8th 2010, 8:29am

changing languages layout problem

Hi Guys,



I always come here when I loose almost a day trying to make things work as I expect them to.



I have this situation:

I have a 3 languages layout.

Each language button when selected, have it's opacity at "1" and when not selected, at "0.5".

I created an action that calls the layout of each language when clicking on the desired language.

So.... this is the action:



Source code

1
2
3
4
5
6
7
<action name="change_alpha_flag"> 
set(plugin[btn_language1].alpha, 0.5); 
set(plugin[btn_language2].alpha, 0.5); 
set(plugin[btn_language3].alpha, 0.5); 
wait(blend); 
set(plugin[%1].alpha, 1); 
</action>




I than created an action to change each language layout:



Source code

1
2
3
4
5
6
7
8
<action name="change-layout-en"> 
set(plugin[menu].url, %SWFPATH%/menu-en.gif); 
set(plugin[show-map].url, %SWFPATH%/menu-map-en.png); 
set(plugin[show-images].url, %SWFPATH%/menu-images-images-en.png); 
set(plugin[menu-background].url, %SWFPATH%/menu-background-en.png); 

if(plugin[btn_english].alpha == 1, infotext-en, infotext-es); 
</action>






Here is the language button:



Source code

1
2
3
4
5
6
7
<plugin name="btn_spanish" 
style="moduly_style" 
url="%SWFPATH%/btn_spain.png" 
alpha="0.5" 
onhover="showtext(Español,STYLE1);" 
x="80" 
onclick="change_alpha_flag(btn_spanish); action(change-layout-es);" />






Here are some problems:

Some of the panos have a textbox that has 3 txt entries (1 for each language).

When I click each button, all layout structure and languages texts (textbox and other things) changes with no problems.

Considering I created for each one an action like: change-layout-en...... change-layout-es........ change-layout-pt

How can I select spanish language button (for example), then click into another panorama and keep this language selected?
It's restarting to the main language (language1).


I opted to keep="false" on most plugins cause they don't appear in all panoramas.


Considering that when clicking on the language buttons I have the layout changed perfectly with all texts and images updated, I decided to create this code:


Source code

1
2
3
4
5
6
7
8
<event onxmlcomplete="keep-layout" 

<action name="keep-layout"> 
if(plugin[btn_language1].alpha == 1, change-layout-en, ); 
if(plugin[btn_language2].alpha == 1, change-layout-pt, ); 
if(plugin[btn_language3].alpha == 1, change-layout-es, ); 

</action>




BUT... it didn't work.
What's wrong with my structure? Am I thinking it wrong?


Another question:
I had an image that's a menu.
This menu has several children.
I couldn't update the url of this menu image (to change to another language text) cause it gone on top of all children when clicking on the languages buttons to change layout.

I tryed to insert a zorder command and it made no effect.



Source code

1
2
set(plugin[menu].url, %SWFPATH%/menu-background-en.gif); 
set(plugin[menu].zorder, 0);




What happens to the plugins and children when an action changes its url?

Well... I think it got a little complicated to explain.

If you couldn't understand, please let me know.

I'm really getting crazy with it! :)

Thanks!!!!!!!!!!!!!!!!!!

Daniel

2

Friday, October 8th 2010, 2:07pm

I take another way to make that and I have no problems to keep the language

example

This post has been edited 1 times, last edit by "Job.1" (Oct 8th 2010, 2:38pm)


Tuur

Sage

Posts: 3,121

Location: Netherlands

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

  • Send private message

3

Friday, October 8th 2010, 4:05pm

He job ,

i love your navigation tooll!!

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

4

Friday, October 8th 2010, 4:23pm

Hi!!

Your navigation tool is awesome!!
Loved that ring with degrees! :)

well... i couldn't see you code, but I have no problem with the onhover (showtext). It keeps while changing languages and entering other panos with no problems.
The problem is the layout changes (image url changes).

Ex: I have a menu that is written as an image "open menu" in english and "abrir el menu" in spanish. All graphics.
When clicking on the language buttons, the images of that menu changes with no problems, but when entering another pano, the images get back to original. All showtext keep in that selected language, but the images are "reset".

Any clue? Any idea to work with?

THanks!!!!!

Daniel

5

Friday, October 8th 2010, 4:36pm

I think is the same with the help's images

Images

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<plugin name="panoaide"
	url="panoaide.png"
	autopos="center" x="0" y="0"
	visible="false" enabled="true" handcursor="true" capture="true" children="true" keep="false"
	scale="1"
 	zorder="1"
	alpha="1.00" blendmode="normal" smoothing="true"
 	onloaded=""
	onover=""
	onhover="showtext(get(txt_close));"
	onout=""
	ondown=""
	onup=""
	onclick="set(visible, false);set(plugin[aide].visible, true);set(plugin[aide1].visible, false);" />
<plugin name="panoaide_EN"
	url="panoaide_EN.png"
	autopos="center" x="0" y="0"
	visible="false" enabled="true" handcursor="true" capture="true" children="true" keep="false"
	scale="1"
 	zorder="1"
	alpha="1.00" blendmode="normal" smoothing="true"
 	onloaded=""
	onover=""
	onhover="showtext(get(txt_close));"
	onout=""
	ondown=""
	onup=""
	onclick="set(visible, false);set(plugin[aide].visible, true);set(plugin[aide1].visible, false);" />
<plugin name="panoaide_ES"
	url="panoaide_ES.png"
	autopos="center" x="0" y="0"
	visible="false" enabled="true" handcursor="true" capture="true" children="true" keep="false"
	scale="1"
 	zorder="1"
	alpha="1.00" blendmode="normal" smoothing="true"
 	onloaded=""
	onover=""
	onhover="showtext(get(txt_close));"
	onout=""
	ondown=""
	onup=""
	onclick="set(visible, false);set(plugin[aide].visible, true);set(plugin[aide1].visible, false);" />


Buttons

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<plugin name="aide"
	url="aide.png"
	parent="fond"
	autopos="leftbottom" x="60" y="58"
	visible="true" enabled="true" handcursor="true" capture="true" children="true" keep="false"
	scale="0.60"
 	zorder="6"
	alpha="1.00" 
 	onloaded=""
	onover=""
	onhover="showtext(get(txt_help));"
	onout=""
	ondown=""
	onup=""
	onclick="action(get(openaide));set(visible, false); set(plugin[aide1].visible, true);" />
<plugin name="aide1"
	url="aideb.png"
	parent="fond"
	autopos="leftbottom" x="60" y="58"
	visible="false" enabled="true" handcursor="true" capture="true" children="true" keep="false"
	scale="0.60"
 	zorder="5"
	alpha="1.00" 
 	onloaded=""
	onover=""
	onhover="showtext(get(txt_close));"
	onout=""
	ondown=""
	onup=""
	onclick="action(get(closeaide));set(visible, false); set(plugin[aide].visible, true);" />


Actions

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
<action name="openaide">
	set(plugin[panoaide].visible, true);
	</action>
	
	<action name="closeaide">
	set(plugin[panoaide].visible, false);
	</action>
	
	
	<action name="openaide_EN">
	set(plugin[panoaide_EN].visible, true);
	</action>
	
	<action name="closeaide_EN">
	set(plugin[panoaide_EN].visible, false);
	</action>
	
	
	<action name="openaide_ES">
	set(plugin[panoaide_ES].visible, true);
	</action>
	
	<action name="closeaide_ES">
	set(plugin[panoaide_ES].visible, false);
	</action>

<action name="francais">
  set(txt_help, 'Aide');
  set(openaide,'openaide');
  set(closeaide,'closeaide');
  set(plugin[french].alpha, 1);
  set(plugin[english].alpha, 0.30);
  set(plugin[espagnol].alpha, 0.30);
</action>

<action name="english">
  set(txt_help, 'Help');
  set(openaide,'openaide_EN');
  set(closeaide,'closeaide_EN');
  set(plugin[french].alpha, 0.30);
  set(plugin[english].alpha, 1);
  set(plugin[espagnol].alpha, 0.30);
</action>

<action name="espagnol">
  set(txt_help, 'Ayuda');
  set(openaide,'openaide_ES');
  set(closeaide,'closeaide_ES');
  set(plugin[french].alpha, 0.30);
  set(plugin[english].alpha, 0.30);
  set(plugin[espagnol].alpha, 1);
</action>


Language Button

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<plugin name="langue"
	url="langue.png"
	autopos="centertop,0,20"
	visible="true" enabled="true" handcursor="true" capture="true" children="true" keep="false"
	scale="0.80"
 	zorder="10"
	alpha="0.90" blendmode="normal" smoothing="true"
 	onloaded=""
	onover=""
	onhover=""
	onout=""
	ondown="" 
	onup=""
	onclick="" />
	
	<plugin name="french"
	url="francais.png"
	parent="langue"
	align="left" x="10%" y="0"
	visible="true" enabled="true" handcursor="true" capture="true" children="true" keep="false"
	scale="0.50"
 	zorder="10"
	alpha="0.30" blendmode="normal" smoothing="true"
 	onloaded=""
	onover=""
	onhover="showtext(Français);"
	onout=""
	ondown="" 
	onup=""
	onclick="francais();" />
	
	<plugin name="english"
	url="english.png"
	parent="langue"
	align="center" x="0" y="0"
	visible="true" enabled="true" handcursor="true" capture="true" children="true" keep="false"
	scale="0.50"
 	zorder="10"
	alpha="0.30" blendmode="normal" smoothing="true"
 	onloaded=""
	onover=""
	onhover="showtext(English);"
	onout=""
	ondown="" 
	onup=""
	onclick="english();" />
	
	<plugin name="espagnol"
	url="espagnol.png"
	parent="langue"
	align="right" x="10%" y="0"
	visible="true" enabled="true" handcursor="true" capture="true" children="true" keep="false"
	scale="0.50"
 	zorder="10"
	alpha="0.30" blendmode="normal" smoothing="true"
 	onloaded=""
	onover=""
	onhover="showtext(Español);"
	onout=""
	ondown="" 
	onup=""
	onclick="espagnol();" />

6

Saturday, October 9th 2010, 1:42am

Hello,



I'm getting crazy!!!!

I decided to write all language code again.




The Language Buttons:

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
<action name="english">
     set(language,english);
  change-layout(-en);
  change_alpha_flag(btn_english);
  textbox-info
  </action>  
  
  <action name="spanish">
     set(language,spanish);
  change-layout(-es);
  change_alpha_flag(btn_spanish);
  textbox-info
  </action>
  
  <action name="portugues">
     set(language,portugues);
  change-layout(-br);
  change_alpha_flag(btn_portugues);
  textbox-info
  </action>
 
 
<action name="change_alpha_flag">
    set(plugin[btn_portugues].alpha, 0.5);
    set(plugin[btn_english].alpha, 0.5);
    set(plugin[btn_spanish].alpha, 0.5);
    wait(blend);
    set(plugin[%1].alpha, 1);
  </action>
  






Some panos have a text box with info.
Here is the problem.
When clicking on the buttons, all texts are show correctly.
If I select spanish language and change pano, the textbox show portuguese text.
Portuguese and english are shown correcly, even when changing between panos.



This is the action to load textbox data:

Source code

1
2
3
4
5
<action name="textbox-info">
  if(language == english,set(plugin[text2].html,data:data-en));
  if(language == spanish,set(plugin[text2].html,data:data-es));
  if(language == portugues,set(plugin[text2].html,data:data-br));
   </action>






Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
<!-- the textfield itself -->
 <plugin name="text2" url="%SWFPATH%/plugins/textfield.swf"
         parent="textbox"
         align="lefttop" x="20" y="20"
         background="false" borderwidth="0"
         html="data:data-br"
         css="p{color:#000000; font-family:Arial; font-size:12;}"
         autosize=""
   width="220"
   Height="900"
         mask="textmask"
         />
   






I suppose the error is inside the textfield itself.. i tryed several approaches.. but I'm really about to give up this code and come back to the 2 languages layout.

Thanks for reading and your help!!

Daniel

7

Saturday, October 9th 2010, 3:18am

Here's another way to implement multiple languages:

multi-language example

It uses a single variable to change the language for all onhover/showtext events. This variable will be retained as you move from pano to pano.

steve

8

Saturday, October 9th 2010, 7:05pm

Thank you Steve!!

Several days ago I saw that code, but understood absolutely nothing! :)

Today I think it'll be easier to understand it!!
I already read it, but need to take a deep look to adapt it to my needs.


Just a point:



How should I insert this code?



Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function kr_eval_get_in_string(varname) {
 var krpano=document.getElementById("krpanoSWFObject");
 var content= krpano.get(varname);
 var subs = content.match(/get\((?:[^()]+|\(([^()]+|\(([^()]+|(\([^()]+\)))*\))*\))+\)/g); /* deals with up to 4 sets of nested parenthesis */
 var name;
 var val;
 var i;
 for (i=0;i < subs.length;i++)
 {
  name=subs[i].replace(/^get\(/,"");
  name=name.replace(/\)$/,"");
  val=kr_resolve(name);
  content=content.replace(subs[i],val);
 }
 krpano.set(varname,content);
}
function kr_resolve(argument) {
 var krpano=document.getElementById("krpanoSWFObject");
 var subs = argument.match(/get\((?:[^()]+|\(([^()]+|\(([^()]+|(\([^()]+\)))*\))*\))+\)/g); /* deals with up to 4 sets of nested parenthesis */
 var name;
 var val;
 var i;
 if (subs != null) {
  for (i=0;i < subs.length;i++)
  {
   name=subs[i].replace(/^get\(/,"");
   name=name.replace(/\)$/,"");
   val=kr_resolve(name);
   argument=argument.replace(subs[i],val);
  }
  return(krpano.get(argument));
 } else {
  return(krpano.get(argument));
 }
}




I tried inside xml.It returns XML Parser Error: Element is malformed (#1090).

I put it inside the index html and nothing happened... it looks like it weren't there.

I know this looks stupid by my side... but could you please give me this first guideline?

Thank you!

Daniel

9

Sunday, October 10th 2010, 12:29am

Thank you Steve!!
How should I insert this code?

Source code

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
function kr_eval_get_in_string(varname) {
 var krpano=document.getElementById("krpanoSWFObject");
 var content= krpano.get(varname);
 var subs = content.match(/get\((?:[^()]+|\(([^()]+|\(([^()]+|(\([^()]+\)))*\))*\))+\)/g); /* deals with up to 4 sets of nested parenthesis */
 var name;
 var val;
 var i;
 for (i=0;i < subs.length;i++)
 {
  name=subs[i].replace(/^get\(/,"");
  name=name.replace(/\)$/,"");
  val=kr_resolve(name);
  content=content.replace(subs[i],val);
 }
 krpano.set(varname,content);
}
function kr_resolve(argument) {
 var krpano=document.getElementById("krpanoSWFObject");
 var subs = argument.match(/get\((?:[^()]+|\(([^()]+|\(([^()]+|(\([^()]+\)))*\))*\))+\)/g); /* deals with up to 4 sets of nested parenthesis */
 var name;
 var val;
 var i;
 if (subs != null) {
  for (i=0;i < subs.length;i++)
  {
   name=subs[i].replace(/^get\(/,"");
   name=name.replace(/\)$/,"");
   val=kr_resolve(name);
   argument=argument.replace(subs[i],val);
  }
  return(krpano.get(argument));
 } else {
  return(krpano.get(argument));
 }
}

Daniel


That's javascript, not xml. You can put it in a file called kr_languages.js and then load it by putting the following line in the body of your html:

Source code

1
<script type="text/javascript" src="kr_languages.js"></script>


steve

10

Wednesday, October 13th 2010, 7:43pm

Thank you Steve!!!
This works fine!!!!

I´ll update my layout structure with these codes!

THANK YOU!!!!!!!!!!!!!!

Can I use this code to have a button onclick get the xml of my tour?
Supose user wants to send an e-mail of that xml or even send it to any social network..
how could be the code for something similar to "get(xml url)" and send an e-mail? :)

Sorry if it looks stupid question, but these steps are now beyond my poor knowledge. I swear I will learn it in a near future! :)

Thanks again!!

Daniel