S60 Open C
Open C Localization

Open C Localization

Table of Contents

Locale support in POSIX vs Symbian
POSIX
Categories supported in POSIX
Implementation in POSIX
Symbian OS

 


Locale support in POSIX vs Symbian

 


POSIX

Locale defines the subset of a user's environment that depends on language and cultural conventions. It is made up from one or more categories. Each category is identified by its name and controls specific aspects of the behavior of components of the system's components.

The convention followed in POSIX to identify the locale is as follows:

[email protected]

  • Language is an ISO 639 language code.
  • Territory is an ISO 3166 country code.
  • Code set is a character set or encoding identifier like ISO-8859-1, ISO-9959-2 and so on.

Example: en_US.ISO-8859-1, where en represents English language, US represents the United States of America, and ISO-8859-1 is the character set.

 


Categories supported in POSIX

  • LC_CTYPE: For regular expression matching, character classification, conversion, case-sensitive comparison, and wide character functions.
  • LC_COLLATE: For regular expression matching (it determines the meaning of range expressions and equivalence classes) and string collation.
  • LC_MONETARY: For monetary formatting
  • LC_NUMERIC:For number formatting (such as the decimal point and the thousands separator).
  • LC_TIME: For time and date formatting.
  • LC_MESSAGES : For localizable natural-language messages.

NOTE! The Symbian OS implementation supports only the LC_MONETARY, LC_NUMERIC, and LC_TIME categories.

 


Implementation in POSIX

Character set information is stored as text files in the /usr/share/i18n/charmaps/ directory.

The entry in the file looks as shown below :

<U0030> /x30 DIGIT ZERO, where U0030 is a UNICODE-16 value and x30 is an ISO-8859-1 value, which is followed by the description of the character. Locale information related to a particular country is stored in a locale definition file in the text format in the/usr/share/i18n/locales/ directory.

NOTE! The Symbian OS implementation does not use the above-mentioned mechanisms for character sets or for storing locale information.

 


Symbian OS

In Symbian OS locale-specific information is built as a DLL. The user can change the locale information related to a specific country by loading the appropriate DLL.

The convention followed in naming the DLL is as follows:

elocl.language_index - The list of languages supported by Symbian OS is enumerated in TLanguage. Each value in the TLanguage enumeration uniquely identifies a language. TLanguage enumeration can be found in the e32Const.h header file.

Examples:

  • ELangEnglish and DLL name is elocl.01.
  • ELangFrench and DLL name is elocl.02.
  • ELangGerman and DLL name is elocl.03.
  • ELangFinnish and DLL name is elocl.09.

Symbian OS provides the TLocale class to set the system-wide locale settings and to retrieve system-wide locale setting. The TLocale class provides methods for setting the following information: calendar settings, country code, currency format, date and time formatting, numeric values, time zone information, and units of distance.

In Symbian OS most applications do not need to change the locale settings; they just use the system setting instead.

The user can load the appropriate locale-specific DLL to fetch the locale data. The function given below is a way to fetch the locale-specific information.

void LoadLanguageDLL()
{
  //Finnish
  _LIT(KDllName, "elocl.09");
  RLoader loader;
  TInt r = loader.Connect();	
  if(KErrNone == r)
  {
    //Load the language variant DLL 
    TInt size = KNumLocaleExports * sizeof(TLibraryFunction);
    TPtr8 functionListBuf((TUint8*) data, size, size);
    r = loader.SendReceive(ELoadLocale, TIpcArgs(0, KDllName, &functionListBuf ) );
    if(KErrNone == r)
    {
     ((TLibFn)data[FnLocaleData])(&iLocale);
     retVal = (TText*) aLocale.Ptr();
    }
    loader.Close();
  }
}

Setting the locale by writing a program in POSIX is easier compared to the locale settings in Symbian OS. In POSIX the user does not need to be aware of the locale information, whereas in Symbian OS the user should be aware of it.

Example: The code below sets the monetary information of Finland using POSIX:

#include <stdio.h>
#include <locale.h>
int main()
{
  //before fetching the monetray information it is assumed that locale is set to finnish
  struct lconv* localeinfo = localeconv();
  return 0;
}

The lconv structure has the complete monetary information.

The code below sets the monetary information of Finland using Symbian C++:

#include <e32std.h>
void doExampleL()
{
  TLocale locale;
  locale. SetCurrencySymbolPosition(ELocaleAfter);
  locale. SetCurrencySpaceBetween(ETrue);
  locale. SetCurrencyDecimalPlaces(2);
  locale. SetCurrencyTriadsAllowed(ETrue);
  locale. SetNegativeCurrencyFormat(TLocale::ELeadingMinusSign);
  //similarly other monetary information should be set individually.
} 

Give feedback of this section


©Nokia 2007

Back to top


This material, including documentation and any related computer programs, is protected by copyright controlled by Nokia. All rights are reserved. Copying, including reproducing, storing, adapting or translating, any or all of this material requires the prior written consent of Nokia. This material also contains confidential information, which may not be disclosed to others without the prior written consent of Nokia.

Nokia is a registered trademark of Nokia Corporation. S60 and logo is a trademark of Nokia Corporation. Java and all Java-based marks are trademarks or registered trademarks of Sun Microsystems, Inc. Other company and product names mentioned herein may be trademarks or tradenames of their respective owners.