Page 1 of 1
Changing language in web applications
Posted: Thu May 07, 2020 2:11 am
by Joerg Hamacher
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
Re: Changing language in web applications
Posted: Fri May 08, 2020 7:44 pm
by kno_dk
Hi.
I am having the same issue - looking forward to a solution
/klaus
Re: Changing language in web applications
Posted: Mon May 11, 2020 7:25 pm
by Joerg Hamacher
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