Provides a quick way to set a Locale format for a request. Locale information determines date and number/currency formats.
This method sets the Locale to the browser's Locale provided via the Request.GetLocale() method.
If this method is called the wwServer::oLocaleInfo is available which provides detailed info on the locale in use. It's based on the wwLocaleInfo class.
You can call this method with an optional value of .T. to reset the Locale back to its default locale which is specifed in the wwServer::cDefaultLocale property.
The Currency Symbol can be overridden via the wwServer::cLocaleCurrencySymbol. If this value is non-blank the specified currency symbol is used regardless of the Locale in use. This is useful if your site always accepts payments in a single currency, but still wants to display numbers in the appropriate number format to the browser.
If .T. to forces the locale back to the default specified for the server in cDefaultLocale. If .F. or no parameter is passed the server switches to the locale of the user's browser.
Optional - The explicit numeric or string LocaleId to force the Locale to.
Can be implemented at many levels:
- Per Request (beginning and end of method)
- Process Class (in the Process method wrapping DoDefault())
- Server Class (in the Process method at begining and end of method)
You can only switch to locales that are installed on your server. If you plan to do this I suggest you install the various language packs for various languages which can be installed from the Locale options in Control Panel. If a Locale is not found the defaullt Locale is used instead.
Note it's your responsibility to reset the Locale. Once set the locale setting persists to the next request unless you properly unset the locale setting at the end of the page/method/request.
If you use this method make sure to add:
SET PROCEDURE TO wwLocaleInfo ADDITIVE
into your startup code
*** The following example switches locale to DEFINE CLASS wwYourServer cDefaultLocale = "de-de" ... * wwYourServer::Process FUNCTION Process *** Switch locale to browser setting this.SetLocale() *** Retrieve first parameter lcParameter=UPPER(THIS.oRequest.Querystring(1)) *** Set up project types and call external processing programs: DO CASE CASE lcParameter == "WCDEMO" DO wcDemo with THIS ... more CASE statements etc. ENDCASE *** Switch back to default Locale this.SetLocale(.T.) ENDFUNC ... ENDDEFINE
Comment or report problem with topic