Locale is a concept that originated in the POSIX standard to identify cultural conventions (including a language) like number, date and time formatting, currencies, sorting, and so on. Locale can also contain country-specific conventions, such as time zones. In Symbian OS there is the Locale Settings API for this purpose.
To clarify the idea of locale, consider for instance English, which is spoken in many countries all over the world. The English variant for United Kingdom requires different settings than the variant for the US market. For example, they have different date formats, different first day of the week, different currency symbol, different time zone, different international country dialing code, and so on. All these settings come from locale, which should be called by applications.
The locale system and its functions and settings are documented more
thoroughly in the S60 SDK documentation (see class TLocale
).
However, AVKON overrides the weekday and month names offered by TLocale
.
This is to allow more linguistic flexibility, since most languages inflect
the day and month names depending on the context. In addition, the date and
time Formatter in AVKON utilizes TLocale
in the date
and time formats. The AVKON formatter was created to ease application developers'
work.
Locale model and identification
Operating systems that support multilingual applications typically have
a locale model. The model defines how locales are identified and what kind
of linguistic and cultural information is associated with locales. The locale
model of Symbian OS is rather language-centric, with little flexibility to
provide for different countries that share the same language. To alleviate
this, Symbian has implemented a solution that makes full use of the 16 bits
available for locale identification. This is achieved by using dialects (TDialect
)
to extend TLanguage
. This extends the boundary of available
locales beyond the previous 99 preset country + language combinations.
Make your code locale-independent by using the functions available in the locale-related classes for formatting the locale-dependent data instead of creating your own formatting. In some cases it may be necessary to use your own format - for instance, if you need to use only day and month in Calendar. In that case it is possible to create a format, but it needs to be ensured that the format can be localized and the same format needs to be used consistently across the application.
User-modifiable locale settings
The user can modify the following locale settings in S60 General Settings. All applications should reflect these changes.
Time format and separator character
Date format and separator character
Even though there are four separators defined, only the two middle ones in the date format can be changed.
Digits (Arabic, Urdu, Farsi, and Hindi only )
In Arabic UI, the user can select whether the default digits are European or Arabic-Indic digits (numerals)
How to utilize locales?
It is essential for each developer to acquaint himself/herself with
the TLocale
class in the SDK.
In coding, it should be remembered that English is a relatively simple language, that is, it has short words and the grammar does not cause great challenges to the software. Using English as the base language in software development causes some challenges in the software design that should allow for text expansion, conjugation and inflection of words, different genders defining the adjectives and verbs, height of the text, sorting, and comparison rules. These issues do not arise when checking your implementation in English in the emulator.
Locale-related data
The locale model of Symbian OS contains the locale-related data described in the following subsections. This data is accessible through API classes and member functions.
Note: See S60 platform SDK documentation. Recommended topics are Locale settings overview in Locale Settings and TLocale in Locale Settings.
- Date and time
Note: Use the date and time formatters provided by AVKON whenever possible.
Symbian OS locale provides the following formatting functions for date and time formats:
The order of the date components: day-month-year (European), month-day-year (American), or year-month-day (Japanese)
Date separators. There are four different positions for date separators:
Beginning of the expression
Between the first and second part
Between the second and third part
At the end of the expression.
Some of the positions may contain an empty string if a separator is not used in that position in the locale in question.
Examples of short date formats, date order, and separator positions (S = separator, C= date component):
S0 |
C0 |
S1 |
C1 |
S2 |
C2 |
S3 |
|
Danish |
30 |
- |
01 |
- |
02 |
||
Hungarian |
2002 |
. |
01 |
. |
30 |
. |
|
English (US) |
1 |
/ |
30 |
/ |
02 |
||
Chinese |
2002 |
年 |
1 |
月 |
30 |
日 |
Time format
Time separator (for example, colon or full stop)
Is the 12 or 24-hour clock used?
AM/PM symbols (maximum of 5 characters allowed)
Position of the AM/PM symbol (before or after the time expression)
Is the AM/PM symbol separated by a space from the time expression?
Which days of the week are working days?
The first day of the week. The first day of the week is usually Saturday, Sunday or Monday, but in Symbian OS any weekday can be set to be the first.
- Numbers and currencies
Currency triads, that is, grouping of digits in large numbers (for example, 123 456 789). Note that Symbian OS only supports the grouping of currency amounts.
Thousands separator (for example, space, comma)
Decimal separator (for example, comma, full stop)
Currency symbol (for example, £, €, $, Ft, kn). Note that you should not make any assumptions on the number of characters in the currency symbol.
Position of the currency symbol (before or after the amount)
Is the currency symbol separated by a space from the amount?
Currency decimal places
Indication of negative currency (for example, negative currency amount is placed in parenthesis, indicated by minus)
Digit formats (European, Arabic-Indic digits)
- Measurement units
Allow you to define whether metric or imperial units are in use in the target locale.
There are separate functions for long and short distances.
- Collation
Collation is a technical term for ordering strings in a manner that is specific to a given locale. Because different languages have different alphabets, strings are also sorted differently. For example in French the letter "o with dieresis" or "ö" is a variation of "o", whereas in Swedish it is the letter "ö", which comes last in the alphabet. There are also country-specific variations within a language, for example between Iberian Spanish and Latin American Spanish.
Symbian OS provides a locale-specific scheme for collation, with the option to create multiple collation methods for a locale. These are typically used in Chinese, which does not have any alphabetical ordering but market area-dependent sorting orders (pinyin/zhuyin/stroke) that should be supported. The collation rules are automatically available to applications through the descriptor class API. Do not try to order strings by comparing individual values of characters; use the API instead. This guarantees that your code will work regardless of locale. Furthermore, collation should only be applied to complete strings and not to single characters. Remember that there are only dozens of characters in western scripts as per language to be collated, but tens of thousands of characters, for example, in Chinese.
The descriptor API also contains member functions for searching strings. They are based on the same collation data as the sorting functions.
Language- and country-dependent elements not in the locale
The following data is language- and/or country-specific, but it is not included in the Symbian OS locale-related classes. Thus, it must be designed and implemented so that the data can be localized either so that settings are included in the resource files or the user can change them. For user-changeable settings, define a localizable default.
Keyboard handling: Different languages have different keyboard layouts or key mappings. Therefore, you should not make any assumptions about key locations on the keyboard (for example QWERTY keyboard versus AZERTY [French] keyboard). Furthermore, do not assume that all characters are available in all keyboards or all key mappings.
List separator, for example comma or semicolon, has to be changeable.
Address formats: Addresses in different countries do not always contain a certain number of fields, which are in a certain order. Make sure that there are no obligatory fields (for example, state).
Telephone number formats: The grouping of numbers and the separators used in telephone numbers varies.
Paper sizes for printing, for example, DIN A, US letter and legal sizes, and Japanese sizes. The paper size needs to be localizable.
Names of measurement units, for example kB, should not be hard-coded.
Week numbers: week numbers are not used in all locales, and the first week of the year can be defined in several ways.
Symbian OS has an API function to determine the number of a given week. It uses several programmer-selectable rules for calculating the first week of the year. This is not, however, associated with the system locale in any way and applies only to the Gregorian calendar. It should also be noted that the week numbering is available only if the first day of the week is Monday.
Order of first name and last name. For instance, in Hungarian, Chinese, and Japanese, last name is displayed before the first name.