Changing language in web applications

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
Joerg Hamacher
Posts: 53
Joined: Thu Feb 11, 2016 12:01 am

Changing language in web applications

Post by Joerg Hamacher » Thu May 07, 2020 2:11 am

Hi,

I want to change the language in a web session (web pages) dynamically.

I want to realize a dropdown where a language can be selected - and if a
new language is selected I want to change the web session language
automatically to display all texts in the new language. I only know of USE
SET_SESSION_VALUE but this is not allowed in Web programming.


Many thanks in advance,
Joerg

kno_dk
Posts: 127
Joined: Tue Feb 23, 2016 12:00 am

Re: Changing language in web applications

Post by kno_dk » Fri May 08, 2020 7:44 pm

Hi.

I am having the same issue - looking forward to a solution ;-)

/klaus

Joerg Hamacher
Posts: 53
Joined: Thu Feb 11, 2016 12:01 am

Re: Changing language in web applications

Post by Joerg Hamacher » Mon May 11, 2020 7:25 pm

Hi Klaus,
I also contacted support and got this solution:

Here is an example of how you can achieve this:
------------------------------------------------------------------
Begin_Com Role(*EXTENDS #PRIM_WEB) Theme(#SYS_THEME<MaterialDesignBlue>) Height(464)
Define_Com Class(#lngSwitchFld.DropdownField) Name(#lngSwitchFld) DisplayPosition(1) Left(88) Parent(#COM_OWNER) TabPosition(1) Top(85)

Evtroutine Handling(#lngSwitchFld.Changed)

If_Ref Com(#sys_web.URLParameters<"lang">) Is_Not(*NULL)
#std_codel := #sys_web.URLParameters<"lang">.Value
#sys_web.Navigate( ((#SYS_WEB.URL).Replace( ("lang=" + #std_codel.Trim) ("lang=" + #lngSwitchFld.Trim) )) Current )
Endif

Endroutine
End_Com


It's done by changing the URL parameter "lang" and re-opening the web page.
But this also closes the current web session and starts a complete new one so everything that has been done before or be held for the complete web application with Scope(*APPLICATION) seems to be gone.
I will separate the logon webpage from the application web page and create an own Welcome page which calls the application page with the language that the user selected. Changing the language from within the application is apparently not possible.

Best regards,
Joerg

Post Reply