Web Connection
Bilingual Website
Gravatar is a globally recognized avatar based on your email address. Bilingual Website
  Kathy
  All
  Sep 26, 2019 @ 09:10am

Hello Rick,
I'm not sure under which category I should have posted this, hope this is the right one.
Would you please let me know your idea on what the best way would be to make my Webconnect website bilingual?
Thank you in advance,
Kathy

Gravatar is a globally recognized avatar based on your email address. re: Bilingual Website
  Carl Chambers
  Kathy
  Sep 26, 2019 @ 12:47pm

Hi Kathy,

I'm, not claiming this is the best way but I'll briefly describe what I did as food for thought.
My approach supports up to 6 different languages.
Also note that this app uses WebConnection 6.xx and it's layout page / template design.

The Process class has a cLanguage property for the language code.
Process.OnProcessInit() calls the SetLanguage() method.

*********************************************************************
* Function pspUserProcess :: SetLanguage
*****************************************
* Function: Sets the language to be used in creating the Response.
* Assume:	Every subclass calls this method from OnProcessInit().
*********************************************************************
FUNCTION SetLanguage()

LOCAL lcLanguage, llCookieIsOK
*
*  Get the Language to be used.
*  The language is determined in the following
*  order of priority.
*
*  1. Passed in the query string or form var
*  2. Stored in a Cookie.
*  3. In the Locale setting of the client computer.
*  4. Default to English
*
*- Try the querystring or form var
lcLanguage = LOWER(THIS.GetHttpParam("lang"))
IF EMPTY(lcLanguage) OR ;
     NOT INLIST(lcLanguage,"en","fr","es","de","it","pt")
  IF PEMSTATUS(THIS,"cLanguageCookie",5)  && This Process subclass uses cookies.
    lcLanguage = THIS.oRequest.GetCookie(THIS.cLanguageCookie)
    llCookieIsOK = INLIST(lcLanguage,"en","fr","es","de","it","pt")
  ENDIF
    
  *- Try the client locale language setting
  IF NOT llCookieIsOK
    lcLanguage = LOWER(LEFT(THIS.oRequest.GetLocale(),2))
    
    *- Finally, use the default - english
    IF NOT INLIST(m.lcLanguage,"en","fr","es","de","it","pt")
      lcLanguage = "en"
    ENDIF
    
    *
    *  If this is a regular OnLine Lookups user, set the cookie.
    *  NOTE: We're deliberately not setting the cookie
    *        if this is an API client.
    *
    IF NOT THIS.lAPI AND THIS.lConsent
      THIS.oResponse.AddCookie(THIS.cLanguageCookie, ;
                               lcLanguage, "", ;
                               "NEVER")
    ENDIF
  ENDIF  && NOT llCookieIsOK
ENDIF  && EMPTY(lcLanguage) OR...

THIS.cLanguage = lcLanguage

ENDFUNC
* EOF pspUserProcess :: SetLanguage

There is a complete set of templates for each language. There is a subfolder in the views folder for each language with the subfolder names matching the supported language codes.

Process.ExpandTemplate() locates the correct template file.

************************************************************************
* pspProcess :: ExpandTemplate
****************************************
FUNCTION ExpandTemplate(tcTemplate)
****************************************************
LOCAL lcTemplate
lcTemplate = THIS.oConfig.cHtmlPagePath + "views\" ;
           + ADDBS(THIS.cLanguage) + FORCEEXT(tcTemplate,"wc")
Response.ExpandTemplate(lcTemplate)

ENDFUNC
* EOF pspProcess::ExpandTemplate

Any text generated in procedural code that is inserted into the templates is stored in a "strings" table containing the language-specific version for each supported language.

Hope this is of some use to you.
Carl

Gravatar is a globally recognized avatar based on your email address. re: Bilingual Website
  Luca
  Kathy
  Sep 30, 2019 @ 10:47pm

Hi,
I used a simililar solution.
Set a cLanguage SessionVar from a listbox on default connection webpage.
In OnLoad of every page:

.cLanguage=Session.GetSessionVar("cLanguage")
.PageName="Page1"

IF .cLanguage<>"ita"
  SELECT Languages
  =SEEK(.cLanguage+"Page1","Languages","kiave")
  SCAN WHILE Language=.cLanguage AND ALLTRIM(PageName)==.PageName
    m.String="."+ALLTRIM(ObjName)+"='"+ALLTRIM(Text)+"'"
    &String
  ENDSCAN 
ENDIF

This is an example for a page named Page1.
You have to codify every page's object in the Languages table.
Languages table has the following fields:
Language (for example "eng")
PageName (for example "Page1")
ObjName (for example "lblName.text")
Text ( for example "Name")

Gravatar is a globally recognized avatar based on your email address. re: Bilingual Website
  Kathy
  Carl Chambers
  Oct 2, 2019 @ 10:31am

Thanks to both of you for your help and the detailed instructions.
I'll go through it more confident now 😃
Best regards,
Kathy

Gravatar is a globally recognized avatar based on your email address. re: Bilingual Website
  Kathy
  Michael Hogan (Ideate Hosting)
  Oct 15, 2019 @ 09:17am

This looks so cool.
I have not tried the trial yet but would you be able to exclude some parts, the company name for instance?
Thanks.

Gravatar is a globally recognized avatar based on your email address. re: Bilingual Website
  Michael Hogan (Ideate Hosting)
  Kathy
  Oct 15, 2019 @ 09:42am

Yes - you have very precise control regarding which parts of your pages don't get translated. You can also define your own dictionary for words or phrases if you don't quite agree with their translation (especially for industry-specific technical terms).

Gravatar is a globally recognized avatar based on your email address. re: Bilingual Website
  Kathy
  Michael Hogan (Ideate Hosting)
  Oct 15, 2019 @ 11:19am

Sounds great!
I'm going to try it ASAP.
Many thanks.

© 1996-2019