This topic is locked

multi laguage site

8/9/2011 2:31:48 PM
PHPRunner General questions
A
arjan author

Hi,
I need some help to finish my multi language site, therefore I have some questions.
I have the possibility in my site to create records in the English language or in the Dutch language and I save the language in the record in the field "Language".

I made also multi language select list-boxes so I can use the both languages.

I made them from this example:

Add this line in "Where" Field in the properties of the list-box:
quote " language='". $_SESSION["language"] ."'" unquote
And made a table "FITUP" like this for the list-box. (I have 15 of this situations)
Fitup........... ....Language

Hechtlassen ...... Dutch(Standard)

Bullits........... Dutch(Standard)

Hechtbruggen...... Dutch(Standard)

Tackwelds......... English

Bullits........... English

Strongbacks........English
So all the labels in the site switch from language by the language selector at the top of page (Did this by label editor) that is not the problem, the problem are the stored database fields that I use in the list-boxes.
My question is:

When I select a English record to edit, it would be nice that the website language switch to English (can be done by the saved "language" Field?), and when I select a Dutch record to edit that the language switch from English to Dutch and vice versa.

But at the moment as I select a Dutch record to edit and the language of the website is English the items in the listbox have the wrong language.

How can I switch from language by using the stored "Language" field as I open a record for editing
Maybe an other "FITUP" table can give a solution to make a second language field in it as
Fitup...............Language_English

Hechtlassen........Tackwelds

Bullits............Bullits

Hechtbruggen.......Strongbacks
And then I can lookup the field "fitup" or field "Language_English" in the list-box depending on the language.
I'm looking for the code to switch the language as I select the record, or the code to select the second language in the second example.
Please advice
Arjan

C
cgphp 8/9/2011

In the "Process record values" event of the edit page enter this code:

$_SESSION['language'] = $values['name_of_the_language_field_in_the_table'];
Sergey Kornilov admin 8/10/2011

I would also recommend to check Localizing PHPRunner/ASPRunnerPro applications article for more info and code.

A
arjan author 8/11/2011



In the "Process record values" event of the edit page enter this code:

$_SESSION['language'] = $values['name_of_the_language_field_in_the_table'];



Hi Cristian, thanks for your replay,
This works almost, only when I edit the first record the labels are missing, this means no language selected so all the labels are all blank.

When I edit for the second time a record, the labels are there with the selected language by your code.

An other issue is that the main page keeps on refreshing when I have saved the record and the edit window is closed, and will not end this task unless I do it manual in the browser.
Maybe you have a solution for this issues?
Arjan

C
cgphp 8/11/2011

Enter the following code in the Javascript OnLoad event of the edit/add page:

this.on('afterSave', function(formObj, fieldControlsArr, pageObj){

location.href = "yourpagename_list.php";

});
A
arjan author 8/11/2011



Enter the following code in the Javascript onload event of the edit/add page:

this.on('afterSave', function(formObj, fieldControlsArr, pageObj){

location.href = "yourpagename_list.php";

});



Hi Cristian,
Thanks for this piece of code, this works fine the main page is refreshed after a new or edited record.

Only the blank labels of the fields remains , this is when a language is selected the first time when I edit a record.

So then first I have to close the edit window, after opening the edit window again the labels are filled with the selected language pick-up from the actual Language field form record.

But when I select a record with an another language this happens again.
Do I need the same code as below on an other location (Before the window is opened.), I tried several location but no success.

$_SESSION['language'] = $values['name_of_the_language_field_in_the_table'];
Please advice,
Thanks in advance,
Arjan

C
cgphp 8/11/2011

Please, could you post a demo link ?

A
arjan author 8/11/2011



Please, could you post a demo link ?


Cristian,
Hereby the link
http://demo.asprunner.net/test_Rozalastechniek_nl/WPSBase11/
username a

password a
Try to edit the first record, made in the language "English", the labels will be blank

The second record made in "Dutch"
If you change the language in the login screen to English then first edit second record in Dutch.
Arjan

C
cgphp 8/11/2011

When you change the language in the dropdown, you should set the language session var.
Here it is a possible solution. You could check in the "List page: before process" event if the $_GET['language'] is set:

if(isset($_GET['language']) AND ($_GET['language'] == 'English' OR $_GET['language'] == 'Dutch(Standard)'))

{

$_SESSION['language'] = $_GET['language'];

}