How to run my application from web using some parameters?

Get help using Construct 2

Post » Tue Mar 03, 2015 11:39 am

Hi for all!

The question is about:
I have a personal wiki-site. I have an application stored on that site. This app supplies 2 different languages (also like a site).
How can I run my application with parameter (or any another way) that will have an information about page language? If I will run app from english page, it must be in english, if I'll run it from russian page, it must be in russian.

For now I can make it just with WebStorage. But it saves data user must to input by himself when he will start this app for the first time (if an english-speaking user will run it first time he'll see default-russian text first, then he have to switch into english mode, just after that language option will be saved for the next time).
I want user to avoid switching. If he will start app from english page - he must take an english version of program.

How to make this? How to run application with some language parameter?
Last edited by NickRimer on Tue Mar 03, 2015 1:15 pm, edited 1 time in total.
B
8
S
1
Posts: 72
Reputation: 606

Post » Tue Mar 03, 2015 12:21 pm

Maybe you could use the browser plugin and check the url. Then set the application to run based on that information.
B
47
S
16
G
9
Posts: 1,097
Reputation: 11,180

Post » Tue Mar 03, 2015 1:12 pm

I think it will not work because in this way I should know url of previous page, because current page will be application url.. It will be no so good to make 2 identical folders (for example "ru" and "en") to read this information and switch according to it..
B
8
S
1
Posts: 72
Reputation: 606

Post » Tue Mar 03, 2015 2:34 pm

Well you could use Browser.Referrer then which will tell you the url of the refering page.
B
47
S
16
G
9
Posts: 1,097
Reputation: 11,180

Post » Tue Mar 03, 2015 2:39 pm

NickRimer wrote:Hi for all!

The question is about:
I have a personal wiki-site. I have an application stored on that site. This app supplies 2 different languages (also like a site).
How can I run my application with parameter (or any another way) that will have an information about page language? If I will run app from english page, it must be in english, if I'll run it from russian page, it must be in russian.

For now I can make it just with WebStorage. But it saves data user must to input by himself when he will start this app for the first time (if an english-speaking user will run it first time he'll see default-russian text first, then he have to switch into english mode, just after that language option will be saved for the next time).
I want user to avoid switching. If he will start app from english page - he must take an english version of program.

How to make this? How to run application with some language parameter?


You can do it with php... how the language is detected? just add one variable $language=

I suggest you to use php, when you have your variable in php, just set:

$_SESSION['language'] = $languageinwebsite;

after this, just make a new page php who call the echo of the "echo $_SESSION['language'];"

in construct2, make a call AJAX of the page where you put the echo SESSION ;)
B
21
S
9
Posts: 298
Reputation: 2,967

Post » Wed Mar 04, 2015 8:44 am

Thanks for all your answers! This is my solution:

1. It seems, there is no problem to execute game URL like this: .../index.html?lang=en
2.
Code: Select all
System -> On start of layout
   Set value (VAR) to Browser.QueryParam("lang");

3. Result is VAR = "en"
4. Now I can make all I want with VAR in my program!
B
8
S
1
Posts: 72
Reputation: 606


Return to How do I....?

Who is online

Users browsing this forum: ivanski1983 and 14 guests