HTML-link to various language versions

Q&A about the latest versions
Post Reply
Lalalala
Posts: 9
Joined: Mon Sep 28, 2020 2:20 pm

Hello,
I've created a p2vr project including different language versions. I am using "variables" and "actions" for polygon mode changes for switching the language. Now my costumer ask me, if it's possible to have different html-links to the site with different default language, e.g. one link for the german version, one for the english version etc. The only way to achieve this I could imagine is to have for each language a complete copy of the whole site into one folder for every single language version. This will end up in a huge amount of data as the project is quite big (~1,5 GB) and there are already 4 language versions. Is there any way to achieve this in a more elegant manner?

Thanks in advance.
Regards
User avatar
CStüben
Posts: 146
Joined: Mon Apr 24, 2017 6:00 pm
Location: Wuppertal, Germany
Contact:

hmmm, i think you store the current language in a skin variable.

skin variables can be set by the javascript api:
https://ggnome.com/doc/javascript-api/

So with some additional html and javascript that reads out the html parameter (mytour.html?language=de) you can easily set the start language.

greetings from germany
Chris
---
Die Welt ist eine runde Scheibe.
Lalalala
Posts: 9
Joined: Mon Sep 28, 2020 2:20 pm

Hello CStüben,
thanks for your reply. I've tried your advice and created a link to my site according to your example. (in my case: index.html?sprache=en) But it doesn't work. I suspect that the 'additional html and javascript' you've mentioned seems to be essential to do the trick. Unfortunately I've no clue what to do. Maybe you or somebody else may give me a hint.

Thanks and greetings from germany too
Matthias
User avatar
CStüben
Posts: 146
Joined: Mon Apr 24, 2017 6:00 pm
Location: Wuppertal, Germany
Contact:

Hello lalala,
you need this function:

Code: Select all

<!-- ---------------------------------------------------------------------------------------- -->

function hole_parameter_wert (schluessel, standardwert)
{
  var lauf;
  var ergebnis = standardwert;
  var pos;

  var paare = window.location.search.substring(1).split ('&');
  for (lauf = 0; lauf < paare.length; lauf++)
  {
    if (paare.length > 0)
    { 
      pos = paare[lauf].indexOf('=');
      if (paare[lauf].substring (0, pos) == schluessel)
      {
        ergebnis = paare[lauf]. substring (pos + 1);
      }
    }
  }
  return ergebnis;
}

<!-- ---------------------------------------------------------------------------------------- -->


and then later between

Code: Select all

			skin=new pano2vrSkin(pano);
			// load the configuration
and

Code: Select all

			window.addEventListener("load", function() {
				pano.readConfigUrlAsync("pano.xml");
you need a

Code: Select all

var sprache = hole_parameter_wert ('sprache', 'de');
pano.setVariableValue('sprache', sprache);
so that it look like

Code: Select all

			skin=new pano2vrSkin(pano);
			// load the configuration

var sprache = hole_parameter_wert ('sprache', 'de');
pano.setVariableValue('sprache', sprache);

			window.addEventListener("load", function() {
				pano.readConfigUrlAsync("pano.xml");

and in your url you can say

..../mypanotour/index.html?sprache=en

and of course you have to declare a skin variable "sprache" type text, make a hook at the "exposed" field

greetings from germany
Chris
---
Die Welt ist eine runde Scheibe.
User avatar
k.ary.n
Gnome
Posts: 615
Joined: Wed Aug 15, 2007 1:02 pm

You're almost there. You can use Direct Node Access for this. And since you're already using variables to change the languages, you can set the variable value from the URL rather than once the tour opens.

You can use the instructions and templates here: viewtopic.php?f=13&t=15454.
Lalalala
Posts: 9
Joined: Mon Sep 28, 2020 2:20 pm

Thanks Chris, thanks k.ary.n,

I will try this out. Very friendly people here:)

Best regards
User avatar
CStüben
Posts: 146
Joined: Mon Apr 24, 2017 6:00 pm
Location: Wuppertal, Germany
Contact:

Hi Lalalala,
the working bi-lingual you can find here:
http://360.haifischbar.de/panoramen/bei ... sprachig=1

Simply have a look at the html source to see how the html-part is done. Only a few lines of code is needed.

With an additional parameter &sprache=en or &sprache=de you can start the virtual tour in a language you want:

http://360.haifischbar.de/panoramen/bei ... sprache=en


Unfortunately the customer didnt load the multilingual version yet. Deep sigh.
https://www.wuppertal.de/rathaus-buerge ... eb-C3A4ude


greetings from germany
Chris
---
Die Welt ist eine runde Scheibe.
Lalalala
Posts: 9
Joined: Mon Sep 28, 2020 2:20 pm

Thanks to everyone. So here is how I succeeded without touching too much of my project:
  • In the skin editor I created a new variable: Name= ExtValue , Type= Text , Init Value= (Your starting language. In my case 'de')
  • I erased the Init Value of my language Variable, leaving it blank.
  • I created for every language an action with: Source= Config Loaded , Action= Set Variable Value , Variable Name= (Your language variable. In my case 'sprache') , Operation= Set(=) , Value= (The language value you want to switch to.) , Action Filter= *ExtValue = (The language value)
That's it. (Be sure to use 'Config Loaded' as Source, as 'Start' didn't work in my case.)
Now you can select the language by using 'url#(Your Language Value)' (e.g. index.html#en ).

Regards
Post Reply