Home · All Classes · Main Classes · Deprecated
Public Types | Signals | Public Member Functions | Static Public Member Functions | Static Protected Member Functions

ML10N::MLocale Class Reference

MLocale is a class that implements locale dependent data formatting as well as translation, collation and calendar systems. More...

Inherits QObject.

List of all members.

Public Types

enum  DateType {
  DateNone, DateShort, DateMedium, DateLong,
  DateFull, DateYearAndMonth, DateWeekdayAbbreviatedAndDayOfMonth, DateWeekdayWideAndDayOfMonth
}
enum  TimeType {
  TimeNone, TimeShort, TimeMedium, TimeLong,
  TimeFull
}
enum  Category {
  MLcMessages, MLcTime, MLcCollate, MLcNumeric,
  MLcMonetary, MLcName, MLcTelephone
}
enum  Collation {
  DefaultCollation, PhonebookCollation, PinyinCollation, TraditionalCollation,
  StrokeCollation, DirectCollation, PosixCollation, Big5hanCollation,
  Gb2312hanCollation
}
enum  CalendarType {
  DefaultCalendar, GregorianCalendar, IslamicCalendar, ChineseCalendar,
  IslamicCivilCalendar, HebrewCalendar, JapaneseCalendar, BuddhistCalendar,
  PersianCalendar, CopticCalendar, EthiopicCalendar
}
enum  TimeFormat24h { LocaleDefaultTimeFormat24h, TwelveHourTimeFormat24h, TwentyFourHourTimeFormat24h }
enum  Weekday {
  Monday = 1, Tuesday, Wednesday, Thursday,
  Friday, Saturday, Sunday
}
enum  WeekdayType { WeekdayTypeWeekday, WeekdayTypeWeekend, WeekdayTypeWeekendOnset, WeekdayTypeWeekendCease }
enum  Comparison { LessThan = -1, Equal = 0, GreaterThan = 1 }
enum  CollatorStrength {
  CollatorStrengthPrimary = 0, CollatorStrengthSecondary = 1, CollatorStrengthTertiary = 2, CollatorStrengthQuaternary = 3,
  CollatorStrengthIdentical = 15
}
enum  DateSymbolContext { DateSymbolFormat, DateSymbolStandalone }
enum  DateSymbolLength { DateSymbolAbbreviated, DateSymbolWide, DateSymbolNarrow }
enum  PhoneNumberGrouping { DefaultPhoneNumberGrouping, NoPhoneNumberGrouping, NorthAmericanPhoneNumberGrouping }

Signals

void settingsChanged ()
void localeSettingsChanged ()

Public Member Functions

 MLocale (QObject *parent=0)
 MLocale (const QString &localeName, QObject *parent=0)
 MLocale (const MLocale &other, QObject *parent=0)
virtual ~MLocale ()
MLocaleoperator= (const MLocale &other)
bool isValid () const
void setCategoryLocale (Category category, const QString &localeName)
void setCollation (Collation collation)
Collation collation () const
void setCalendarType (CalendarType calendar)
CalendarType calendarType () const
void setTimeFormat24h (TimeFormat24h timeFormat24h)
TimeFormat24h timeFormat24h () const
TimeFormat24h defaultTimeFormat24h () const
MCollator collator () const
QString toLower (const QString &string) const
QString toUpper (const QString &string) const
QString languageEndonym () const
QString countryEndonym () const
QString decimalPoint () const
QString joinStringList (const QStringList &texts) const
QStringList localeScripts () const
QStringList exemplarCharactersIndex () const
QString indexBucket (const QString &str) const
QString indexBucket (const QString &str, const QStringList &buckets, const MCollator &collator) const
QString language () const
QString country () const
QString script () const
QString variant () const
QString name () const
Qt::LayoutDirection textDirection () const
QString categoryLanguage (Category category) const
QString categoryCountry (Category category) const
QString categoryScript (Category category) const
QString categoryVariant (Category category) const
QString categoryName (Category category) const
QString formatNumber (qlonglong i) const
qlonglong toLongLong (const QString &s, bool *ok=0) const
QString formatNumber (short i) const
short toShort (const QString &s, bool *ok=0) const
QString formatNumber (int i) const
int toInt (const QString &s, bool *ok=0) const
QString formatNumber (double i, int maxPrecision=-1) const
QString formatNumber (double i, int maxPrecision, int minPrecision) const
double toDouble (const QString &s, bool *ok=0) const
QString formatNumber (float i) const
float toFloat (const QString &s, bool *ok=0) const
QString formatPercent (double i, int decimals=0) const
QString formatCurrency (double amount, const QString &currency) const
QString formatDateTime (const QDateTime &dateTime, DateType dateType=DateLong, TimeType timeType=TimeLong, CalendarType calendarType=DefaultCalendar) const
QString formatDateTime (const QDateTime &dateTime, CalendarType calendarType) const
QString formatDateTime (const MCalendar &mCalendar, DateType datetype=DateLong, TimeType timetype=TimeLong) const
QString formatDateTimeICU (const QDateTime &dateTime, const QString &formatString) const
QString formatDateTimeICU (const MCalendar &mCalendar, const QString &formatString) const
QString formatDateTime (const QDateTime &dateTime, const QString &formatString) const
QString formatDateTime (const MCalendar &mCalendar, const QString &formatString) const
QString formatPhoneNumber (const QString &phoneNumber, PhoneNumberGrouping grouping=DefaultPhoneNumberGrouping) const
QString icuFormatString (DateType dateType=DateLong, TimeType timeType=TimeLong, CalendarType calendarType=DefaultCalendar) const
QDateTime parseDateTime (const QString &dateTime, DateType dateType=DateLong, TimeType timeType=TimeLong, CalendarType calendarType=DefaultCalendar) const
QDateTime parseDateTime (const QString &dateTime, CalendarType calendarType) const
QString monthName (const MCalendar &mCalendar, int monthNumber) const
QString monthName (const MCalendar &mCalendar, int monthNumber, DateSymbolContext context, DateSymbolLength symbolLength) const
QString weekdayName (const MCalendar &mCalendar, int weekday) const
QString weekdayName (const MCalendar &mCalendar, int weekday, DateSymbolContext context, DateSymbolLength symbolLength) const
void copyCatalogsFrom (const MLocale &other)
void installTrCatalog (const QString &name)
void removeTrCatalog (const QString &name)
bool isInstalledTrCatalog (const QString &name) const
QString translate (const char *context, const char *sourceText, const char *comment=0, int n=-1)
QString toLocalizedNumbers (const QString &text) const
void connectSettings ()
void disconnectSettings ()

Static Public Member Functions

static void clearSystemDefault ()
static void setConfigItemFactory (const MLocaleAbstractConfigItemFactory *factory)
static const
MLocaleAbstractConfigItemFactory
configItemFactory ()
static MLocalecreateSystemMLocale ()
static MLocale createCLocale ()
static void setDefault (const MLocale &locale)
static QString toLocalizedNumbers (const QString &text, const QString &targetDigits)
static QString toLatinNumbers (const QString &text)
static void setDataPaths (const QStringList &dataPaths)
static void setDataPath (const QString &dataPath)
static QStringList dataPaths ()
static void setTranslationPaths (const QStringList &paths)
static void addTranslationPath (const QString &path)
static void removeTranslationPath (const QString &path)
static QStringList translationPaths ()
static QString localeScript (const QString &locale)
static QString languageEndonym (const QString &locale)
static Qt::LayoutDirection directionForText (const QString &text)
static Qt::LayoutDirection defaultLayoutDirection ()

Static Protected Member Functions

static MLocalegetDefault ()

Detailed Description

MLocale is a class that implements locale dependent data formatting as well as translation, collation and calendar systems.

For more general information about Internationalization in libmeegotouch see also the Internationalization Guidelines

The locale system in the MeeGo Touch UI Framework is separated into different categories. These correspond roughly to the LC_* environment variables of POSIX. MLocale is created with one main language setting but category settings can be used to override specific details. For example it is possible to set the main language to “en_US” to get user interface messages in English but set the MLcCollate category to “fi_FI” to get Finnish collation and set the MLcNumeric category to “de_DE” to get German number formatting.

The calendar system in the MeeGo Touch UI Framework supports a number of non-Gregorian calendar systems. The calendar is used to create presentations of date and time.

The collation system in the MeeGo Touch UI Framework supports a number of collation systems. The actual collation is done with the MCollator class.

The translation system in the MeeGo Touch UI Framework differs a bit from the usual practice used in any other translation system (e.g, Qt’s tr() or GNU’s gettext). In the MeeGo Touch UI Framework, a developer has to use both logical names and Engineering English to translate a string. Whenever no translation is available, the Engineering English version, which is auto-generated from the source code, is displayed instead of the logical names to make testing easier. The displayed Engineering English is prefixed with “!! ” to make it obvious that no translation was found and a proper translation still needs to be added. Internally, the MeeGo Touch UI Framework translation system uses the Qt translation system (using the QTranslator class). The translation source file is in .ts format version 3.0. Usually the translation source file is not generated from code, but rather generated by some other means (e.g from the UI specification).

If one wants to react when the locale settings are changed, one can connect to the settingsChanged() signal by using the connectSettings() method.

Note:
The methods are not thread-safe. For number/string formatting etc. the class is re-entrant. If one needs to have formatting in multiple threads it is suggested to create separate locales.

Member Enumeration Documentation

Calendar type.

Enumerator:
DefaultCalendar 
GregorianCalendar 
IslamicCalendar 
ChineseCalendar 
IslamicCivilCalendar 
HebrewCalendar 
JapaneseCalendar 
BuddhistCalendar 
PersianCalendar 
CopticCalendar 
EthiopicCalendar 

Category type for the locale.

Enumerator:
MLcMessages 
MLcTime 
MLcCollate 
MLcNumeric 
MLcMonetary 
MLcName 
MLcTelephone 

Set of possible collations.

Enumerator:
DefaultCollation 
PhonebookCollation 
PinyinCollation 
TraditionalCollation 
StrokeCollation 
DirectCollation 
PosixCollation 
Big5hanCollation 
Gb2312hanCollation 

Type to select the strength of an MCollator object.

For an explanation of the collation strengths see the Unicode Collation Algorithm.

Enumerator:
CollatorStrengthPrimary 
CollatorStrengthSecondary 
CollatorStrengthTertiary 
CollatorStrengthQuaternary 
CollatorStrengthIdentical 

Return type for MCollator::compare(). Denotes the order of two strings.

Enumerator:
LessThan 
Equal 
GreaterThan 

Type for locale dependent date symbol presentation.

Chooses whether the returned name should be stand-alone or in context.

Example:

Using DateSymbolStandalone will select “sunnuntai” for Sunday in Finnish language whereas DateSymbolFormat will select the inflected form “sunnuntaina”.

Enumerator:
DateSymbolFormat 
DateSymbolStandalone 

Length type for date symbol presentation.

Chooses how much the returned name should be abbreviated.

Example:

For the first day of the week in English language, using DateSymbolAbbreviated will select “Sun”, using DateSymbolWide will select “Sunday”, and using DateSymbolNarrow will select “S”.

Enumerator:
DateSymbolAbbreviated 
DateSymbolWide 
DateSymbolNarrow 

enum for Date formatting.

This correlates closely with the date type in ICU and Unicode CLDR. The values “DateShort”, “DateMedium”, “DateLong”, “DateFull”, have the same meaning as the respective data types in ICU.

The value “DateYearAndMonth” is a libmeegotouch addition to format only the year and the month without the day. “DateYearAndMonth” implies “TimeNone”. For example in Finnish locale the result of using “DateYearAndMonth” is something like “Joulukuu 2011” whereas in Chinese locale the result is something like “2011年 十二月”. This is useful for something like a month view in calendar where a headline showing the year and the month is needed but without the day because the days are shown in a table below the headline.

The value “DateWeekdayAbbreviatedAndDayOfMonth” is a libmeegotouch addition to format only the weekday name in abbreviated form and the day of the month. For example in Finnish locale the result of using “DateWeekdayAbbreviatedAndDayOfMonth” is something like “ma 5” whereas in Chinese locale it is something like “5日周一”.

The value “DateWeekdayWideAndDayOfMonth” is also a libmeegotouch addition, similar to “DateWeekdayAbbreviatedAndDayOfMonth”. It uses a longer format of the weekday name. For example in Finnish locale it would result in something like “maanantaina 5" whereas in Chinese locale it is something like “5日星期一”.

See also:
MLocale::TimeType
Enumerator:
DateNone 
DateShort 
DateMedium 
DateLong 
DateFull 
DateYearAndMonth 
DateWeekdayAbbreviatedAndDayOfMonth 
DateWeekdayWideAndDayOfMonth 

\ brief Grouping formats for phone numbers The phone number grouping specifies, how phone numbers will be displayed to the user. NoGrouping means that the phone numbers are not grouped at all. NorthAmericanGrouping means that the phone numbers are grouped according to the "North American Numbering Plan" DefaultGrouping means that grouping is done according to the current system settings.

Enumerator:
DefaultPhoneNumberGrouping 
NoPhoneNumberGrouping 
NorthAmericanPhoneNumberGrouping 

Type to select 12 hour clock or 24 hour clock or default.

Chooses whether 12 hour clock or 24 hour clock should be forced or whether the default for the current locale should be used.

For example, the “en_US” locale uses a 12 hour clock by default, i.e. in case of “en_US”, both “LocaleDefaultTimeFormat24h“ and “TwelveHourTimeFormat24h” will have the effect that a 12 hour clock is used.

“TwentyFourHourTimeFormat24h” and “TwelveHourTimeFormat24h” will force the use of a 24 hour clock or 12 hour clock, respectively, no matter which one is used by default in this locale.

Enumerator:
LocaleDefaultTimeFormat24h 
TwelveHourTimeFormat24h 
TwentyFourHourTimeFormat24h 

enum for Time formatting.

This correlates closely with the time type in ICU and Unicode CLDR

See also:
MLocale::DateType
Enumerator:
TimeNone 
TimeShort 
TimeMedium 
TimeLong 
TimeFull 
Enumerator:
Monday 
Tuesday 
Wednesday 
Thursday 
Friday 
Saturday 
Sunday 

enum for weekday types

See also:
MLocale::Weekday
Enumerator:
WeekdayTypeWeekday 
WeekdayTypeWeekend 
WeekdayTypeWeekendOnset 
WeekdayTypeWeekendCease 

Constructor & Destructor Documentation

ML10N::MLocale::MLocale ( QObject parent = 0  )  [explicit]

Constructs a MLocale as a copy of the current system default locale.

Constructs a MLocale with data copied from default Locale.

Parameters:
parent the Object’s parent

If MLocale is instantiated with this constructor, i.e. without the parameter specifying the locale name in ICU format as in the other constructor MLocale(const QString &localeName, QObject *parent), it will return a copy of the system default locale, if this already exists. If the system default locale does not exist yet, it is created based on the global settings in the relevant gconf keys. If the gconf settings are not available the system default locale is created based on the contents of the LANG environment variable.

The copy of the system default locale created may already have a list of translation catalogs installed, more translation catalogs can be added using installTrCatalog().

See also:
MLocale(const QString &localeName, QObject *parent)
installTrCatalog(const QString &name)
setDefault(const MLocale &locale)
ML10N::MLocale::MLocale ( const QString localeName,
QObject parent = 0 
) [explicit]

Constructs a MLocale from a ICU format locale ID string.

Parameters:
localeName ICU format locale ID string.
parent the Object’s parent

For details about ICU format locale ID strings see http://userguide.icu-project.org/locale .

Examples for ICU format locale ID strings
Locale ID Language Script Country Variant Keywords Comment
fi_FI fi FI Finnish language in Finland, default sorting order
fi_FI@collation=phonebook fi FI collation=phonebook Finnish language in Finland, phonebook sorting order
zh_CN@collation=stroke;calendar=chinese zh CN collation=stroke;calendar=chinese Simplified Chinese with sorting via stroke-count and Chinese calendar
See also:
MLocale(QObject *parent)
ML10N::MLocale::MLocale ( const MLocale other,
QObject parent = 0 
)

Copy constructor.

ML10N::MLocale::~MLocale (  )  [virtual]

Destructor.


Member Function Documentation

void ML10N::MLocale::addTranslationPath ( const QString path  )  [static]

Append a path to the translation file lookup directories.

If the path to be added is already in the list of translation paths, nothing happens, i.e. the path is not appended again to the end of the path list.

See also:
translationPaths()
setTranslationPaths(const QStringList &paths)
removeTranslationPath(const QString &path)
MLocale::CalendarType ML10N::MLocale::calendarType (  )  const

Returns calendar type.

QString ML10N::MLocale::categoryCountry ( Category  category  )  const

Returns the country code of the locale category in ISO-3166 format.

same as country(), only for a specific category.

See also:
categoryName()
categoryLanguage()
categoryScript()
categoryVariant()
name()
language()
script()
country()
variant()
QString ML10N::MLocale::categoryLanguage ( Category  category  )  const

Returns the language code of the locale category in ISO-639 format.

same as language(), only for a specific category.

See also:
categoryName()
categoryScript()
categoryCountry()
categoryVariant()
name()
language()
script()
country()
variant()
QString ML10N::MLocale::categoryName ( Category  category  )  const

Returns the string representation of the locale category.

same as name(), only for a specific category.

The string representation of the locale category is the full ICU locale ID string. See the ICU user guide for examples.

See also:
categoryLanguage()
categoryScript()
categoryCountry()
categoryVariant()
name()
language()
script()
country()
variant()
QString ML10N::MLocale::categoryScript ( Category  category  )  const

Returns the script code of the locale category in ISO-15924 format.

same as script(), only for a specific category.

Returns the part of the locale category name which specifies the script in form of ISO 15924 script codes

If that part of the locale category name was not specified, i.e. if the default script for that language and country is used, it returns an empty string. For example, if the locale category name is “ru_RU”, an empty string is returned and not “Cyrl” which is the ISO 15924 code of the Cyrillic script used by the “ru_RU” locale.

If you need to find out which scripts are used by a certain locale use localeScripts() const instead.

See also:
categoryName()
categoryLanguage()
categoryCountry()
categoryVariant()
localeScripts() const
name()
language()
script()
country()
variant()
QString ML10N::MLocale::categoryVariant ( Category  category  )  const

Returns the variant of the locale category.

same as variant(), only for a specific category.

See also:
categoryName()
categoryLanguage()
categoryScript()
categoryCountry()
name()
language()
script()
country()
variant()
void ML10N::MLocale::clearSystemDefault (  )  [static]
MLocale::Collation ML10N::MLocale::collation (  )  const

Returns the collation mode.

MCollator ML10N::MLocale::collator (  )  const

Returns a MCollator which compares QStrings based on language/country/collation rules.

const MLocaleAbstractConfigItemFactory * ML10N::MLocale::configItemFactory (  )  [static]

Returns the factory that is used to create config items.

If there was no factory previously set or the factory is 0, a default MLocaleNullConfigItemFactory is created upon the first call to this function.

void ML10N::MLocale::connectSettings (  ) 

Monitors all changes in the locale related gconf keys.

After calling this method, all changes in the locale related gconf keys will change this locale according to the changes in the gconf keys, and emit the settingsChanged() signal.

void ML10N::MLocale::copyCatalogsFrom ( const MLocale other  ) 

Copies translations from another MLocale the catalogs are reloaded based on the locale settings.

QString ML10N::MLocale::country (  )  const

Returns the country code of the locale in ISO-3166 format.

If the country code cannot be parsed out of the locale name an empty string is returned.

Example: If the locale name is “fi_FI” this will return “FI”. If the locale name is “es_419” this will return “419”. “419” is the generic code for Latin American Spanisch. This “es_419” is used in the translations to have one common translation for all Latin American locales instead of individual ones like for all locales like “es_MX”.

See also:
name()
language()
script()
variant()
QString ML10N::MLocale::countryEndonym (  )  const

Returns the endonym of the country of the locale.

The country endonym is the name of the country which is used by the inhabitants of that country.

Examples for country endonyms
English exonymLanguage endonym
GermanyDeutschland
RussiaРоссия
Japan日本
MLocale ML10N::MLocale::createCLocale (  )  [static]

returns a "C" locale

using this

achieves the same as:

 MLocale locale("en_US_POSIX");

libicu handles the string “en_US_POSIX” as synonym for posix locale behaviour.

MLocale * ML10N::MLocale::createSystemMLocale (  )  [static]
QStringList ML10N::MLocale::dataPaths (  )  [static]

Returns the list of data paths used by ICU.

See also:
setDataPaths(const QStringList &dataPaths)
setDataPath(const QString &dataPath)
QString ML10N::MLocale::decimalPoint (  )  const

returns the decimal point character of this locale.

Qt::LayoutDirection ML10N::MLocale::defaultLayoutDirection (  )  [static]

Static method to obtain the layout direction of the default locale.

This returns the layout direction of the system default locale, i.e. of the locale which has been set with setDefault().

See the longer explanation at textDirection() for what layout direction is returned depending on the locale id.

See also:
textDirection() const
directionForText(const QString & text)
setDefault(const MLocale &locale)
TimeFormat24h ML10N::MLocale::defaultTimeFormat24h (  )  const

Returns whether 24 hour or 12 hour format is used by default.

returns MLocale::TwelveHourTimeFormat24h if this locale would use 12 hour mode by default and MLocale::TwentyFourHourTimeFormat24h if this locale would use 24 hour mode by default.

Actually this locale may use a different mode because the default can be overridden, this method shows only what the default would be if it were not overridden.

See also:
timeFormat24h() const
setTimeFormat24h(TimeFormat24h timeFormat24h)
Qt::LayoutDirection ML10N::MLocale::directionForText ( const QString text  )  [static]

Static method to obtain the text direction for a given text.

This returns the text direction for a (paragraph) of text according to the rules to determine the Paragraph Level in the Unicode Bidirectional Algorithm. I.e. it looks for the first character of L, AL, or R in the paragraph, if such a character is found and it is of type AL or R, the text direction is Qt::RightToLeft else Qt::LeftToRight.

If the text is empty or if it only contains digits, whitespace, punctuation characters or other characters with no strong text direction, this function returns Qt::LayoutDirectionAuto.

Notice that this will only work well for plain text; rich text might contain markup tags (e.g., <b>) that might also be detected as having a meaningful text direction.

See also:
textDirection() const
defaultLayoutDirection()
void ML10N::MLocale::disconnectSettings (  ) 

Disconnects from change monitoring in settings After calling this method, all changes in the settings will no longer emit settingsChanged() signal.

QStringList ML10N::MLocale::exemplarCharactersIndex (  )  const

Returns a list of character or strings to be used in indices.

This returns an QStringList of characters (or character sequences) which can be used as index characters in user interfaces. Which index characters are useful depends on the locale set in lc_collation as the collation (sorting) rules depend on the locale.

For example, if lc_collation is set to Czech locale (i.e. if MLocale::categoryName(MLocale::MLcCollate) returns “cs_CZ”) this will return a list like:

“A B C Č D E F G H CH I J K L M N O P Q R Ř S Š T U V W X Y Z Ž”

Note that this also contains the character sequence “CH” as an index “character” because in Czech CH is sorted as if it were a single character after H. Therefore, CH deserves its own entry in a collation index for Czech.

For more details about such index characters see:

QString ML10N::MLocale::formatCurrency ( double  amount,
const QString currency 
) const

Formats an amount of currency.

Parameters:
amount amount to format
currency three letter currency code in ISO-4217 format, e.g. EUR or USD
QString ML10N::MLocale::formatDateTime ( const QDateTime dateTime,
DateType  dateType = DateLong,
TimeType  timeType = TimeLong,
CalendarType  calendarType = DefaultCalendar 
) const

Creates a string presentation for a date time with explicit format lengths.

Parameters:
dateTime time object to create representation from
dateType style of date formatting
timeType style of time formatting
calendarType calendar type to use for formatting

If dateType is MLocale::DateNone and timeType is MLocale::TimeNone, an empty string is returned.

Using this can be considerably slower than using formatDateTime(const MCalendar &mCalendar, DateType datetype = DateLong, TimeType timetype = TimeLong) const, see the example there.

See also:
formatDateTime(const MCalendar &mCalendar, DateType datetype = DateLong, TimeType timetype = TimeLong) const
QString ML10N::MLocale::formatDateTime ( const QDateTime dateTime,
CalendarType  calendarType 
) const

String presentation with explicit calendar type.

Parameters:
dateTime time to format
calendarType calendar to use

This uses the TimeLong and DateLong formats.

Using this can be considerably slower than using formatDateTime(const MCalendar &mCalendar, DateType datetype = DateLong, TimeType timetype = TimeLong) const, see the example there.

See also:
formatDateTime(const QDateTime &dateTime, DateType dateType = DateLong, TimeType timeType = TimeLong, CalendarType calendarType = DefaultCalendar) const
formatDateTime(const MCalendar &mCalendar, DateType datetype = DateLong, TimeType timetype = TimeLong) const
QString ML10N::MLocale::formatDateTime ( const MCalendar mCalendar,
DateType  datetype = DateLong,
TimeType  timetype = TimeLong 
) const

Formats MCalendar using its native calendar system.

Parameters:
mCalendar Calendar holding the datetime to format
datetype format for date
timetype format for time

If dateType is MLocale::DateNone and timeType is MLocale::TimeNone, an empty string is returned.

The return value of this method does not necessarily start with an uppercase letter because it cannot know in which context the returned string will be used. Therefore, it is left to the application to uppercase the first letter if the context requires is. Uppercasing the first letter could be done as in the following example:

 QString formattedDateTime;
 QDateTime current = QDateTime::currentDateTime();
 MLocale locale;
 MCalendar calendar;
 calendar.setDateTime(current);
 formattedDateTime = locale.formatDateTime(calendar, MLocale::DateMedium, MLocale::TimeMedium);
 // Make the first letter uppercase:
 if (!formattedDateTime.isEmpty())
    formattedDateTime[0] = locale.toUpper(formattedDateTime.at(0))[0];

If many dates and times need to be formatted, this method should be preferred over formatDateTime(const QDateTime &dateTime, DateType dateType = DateLong, TimeType timeType = TimeLong, CalendarType calendarType = DefaultCalendar) const because the latter one creates an MCalendar and sets it to the QDateTime. It is wasteful to create a new MCalendar many times, it is better to create the MCalendar only once, change the date and time of this calendar as needed and use this MCalendar for formatting. Example:

 QString formattedDateTime;
 QDateTime current = QDateTime::currentDateTime();
 MLocale locale;
 MCalendar calendar;
 for(int i=0 ; i < 5000 ; i++) {
     current.addSecs(36);
     calendar.setDateTime(current);
     formattedDateTime = locale.formatDateTime(calendar, MLocale::DateMedium, MLocale::TimeMedium);
 }
See also:
formatDateTime(const QDateTime &dateTime, DateType dateType = DateLong, TimeType timeType = TimeLong, CalendarType calendarType = DefaultCalendar) const
formatDateTime(const QDateTime &dateTime, CalendarType calendarType) const
QString ML10N::MLocale::formatDateTime ( const QDateTime dateTime,
const QString formatString 
) const

creates a string presentation for a QDateTime with specific format string

Parameters:
dateTime QDateTime to format
formatString in ISO-14652 date time format
See also:
formatDateTime(const MCalendar &mCalendar, const QString &formatString) const
QString ML10N::MLocale::formatDateTime ( const MCalendar mCalendar,
const QString formatString 
) const

Formats a date string based on ISO-14652 (draft) pattern.

See also:
formatDateTime(const QDateTime &dateTime, const QString &formatString) const;

For more information about the format characters used here see ISO-14652 (draft) or the man page of “date” or the documentation of the glibc function “strftime” .

The pattern may contain the following symbols to be replaced with the corresponding information:

  • %a FDCC-set’s abbreviated weekday name.
  • %A FDCC-set’s stand-alone full weekday name. “stand-alone” means that for example for “Thursday” in Finnish “torstai” is returned and not the inflected form “torstaina”.
  • %b FDCC-set’s abbreviated month name.
  • %B FDCC-set’s stand-alone full month name. “stand-alone” means that for example for “Oktober” in Finnish “lokakuu” is returned and not the inflected form “lokakuuta”.
  • %c FDCC-set’s appropriate date and time representation.
  • %C Century (a year divided by 100 and truncated to integer) as decimal number (00-99).
  • %d Day of the month as a decimal number (01-31).
  • %D Date in the format mm/dd/yy.
  • %e Day of the month as a decimal number (1-31 in at two-digit field with leading <space> fill).
  • %F The date in the format YYYY-MM-DD (An ISO 8601 format).
  • %g Week-based year within century, as a decimal number (00-99).
  • %G Week-based year with century, as a decimal number (for example 1997).
  • %h A synonym for b.
  • %H Hour (24-hour clock), as a decimal number (00-23).
  • %I Hour (12-hour clock), as a decimal number (01-12).
  • %j Day of the year, as a decimal number (001-366).
  • %m Month, as a decimal number (01-13).
  • %M Minute, as a decimal number (00-59).
  • %n A <newline> character.
  • %p FDCC-set’s equivalent of either AM or PM.
  • %r locale specific 12-hour clock time using the AM/PM notation Similar to “I:M p” but the exact format does depend more on the locale. E.g. for “en_GB” locale the result may look like “12:15 PM” with a colon between the hours and he minutes whereas for “fi_FI” locale a dot may be used as the separator, like “12.15 ip.”. The exact result depends on how the TimeShort format for the locale is implemented in ICU.
  • %R locale specific 24-hour clock time. Similar to “H:M” but the exact format depends on the locale. E.g. for “en_GB” locale the result may look like “14:15” and for “fi_FI” locale the result may look like “14.15”. The exact result depends on how the TimeShort format for the locale is implemented in ICU.
  • %S Seconds, as a decimal number (00-61).
  • %t A <tab> character.
  • %T 24-hour clock time, in the format HH:MM:SS.
  • %u Weekday, as a decimal number (1(Monday)-7).
  • %U Week number of the year (Sunday as the first day of the week) as a decimal number (00-53). All days in a new year preceding the first Sunday are considered to be in week 0.
  • %v Same as %V, for compatibility
  • %V Week of the year (Monday as the first day of the week), as a decimal number (01-53). The method for determining the week number is as specified by ISO 8601.
  • %w Weekday, as a decimal number (0(Sunday)-6).
  • %W Week number of the year (Monday as the first day of the week), as a decimal number (00-53). All days in a new year preceding the first Monday are considered to be in week 0.
  • %x FDCC-set’s appropriate date representation.
  • %X FDCC-set’s appropriate time representation.
  • %y Year within century (00-99).
  • %Y Year with century, as a decimal number.
  • %z The offset from UTC in the ISO 8601 format "-0430" (meaning 4 hours 30 minutes behind UTC, west of Greenwich), or by no characters if no time zone is determinable.
  • %Z Time-zone name, or no characters if no time zone is determinable.
  • %% A <percent-sign> character.
QString ML10N::MLocale::formatDateTimeICU ( const QDateTime dateTime,
const QString formatString 
) const
QString ML10N::MLocale::formatDateTimeICU ( const MCalendar mCalendar,
const QString formatString 
) const
QString ML10N::MLocale::formatNumber ( short  i  )  const

Returns the string representation of a number.

Parameters:
i number to format
See also:
formatNumber(qlonglong i) const
formatNumber(int i) const
formatNumber(double i, int precision) const
formatNumber(float i) const
QString ML10N::MLocale::formatNumber ( int  i  )  const

Returns the string representation of a number.

Parameters:
i number to format
See also:
formatNumber(qlonglong i) const
formatNumber(short i) const
formatNumber(double i, int precision) const
formatNumber(float i) const
QString ML10N::MLocale::formatNumber ( qlonglong  i  )  const

Returns the string representation of a number.

Parameters:
i number to format
See also:
formatNumber(short i) const
formatNumber(int i) const
formatNumber(float i) const
formatNumber(double i, int precision) const
QString ML10N::MLocale::formatNumber ( double  i,
int  maxPrecision = -1 
) const

Returns the string representation of a number.

Parameters:
i number to format
maxPrecision maximum number of fractional digits

This just calls formatNumber(i, maxPrecision, 0).

See also:
formatNumber(qlonglong i) const
formatNumber(short i) const
formatNumber(int i) const
formatNumber(float i) const
QString ML10N::MLocale::formatNumber ( double  i,
int  maxPrecision,
int  minPrecision 
) const

Returns the string representation of a number.

Parameters:
i number to format
maxPrecision maximum number of fractional digits
minPrecision minimum number of fractional digits

minPrecision is bound to be between 0 and maxPrecision inclusive.

See also:
formatNumber(qlonglong i) const
formatNumber(short i) const
formatNumber(int i) const
formatNumber(float i) const
QString ML10N::MLocale::formatNumber ( float  i  )  const

Returns the string representation of a number.

Parameters:
i number to format

Examples:

 // format a number to a string according to the conventions of the
 // current system default locale:
 MLocale locale;  // gets the current system default locale
 QString numberString = locale.formatNumber(12345670.89);
 // format a number to a string using US English conventions no
 // matter what the current system default locale is:
 MLocale locale("en_US");
 QString numberString = locale.formatNumber(12345670.89);
 // now numberString contains “12,345,670.89”
 // format a number to a string using Arabic conventions no
 // matter what the current system default locale is:
 MLocale locale("ar");
 QString numberString = locale.formatNumber(12345670.89);
 // now numberString contains: “١٢٬٣٤٥٬٦٧٠٫٨٩”
See also:
formatNumber(qlonglong i) const
formatNumber(short i) const
formatNumber(int i) const
formatNumber(double i, int precision) const
QString ML10N::MLocale::formatPercent ( double  i,
int  decimals = 0 
) const

Returns the string representation of a number as percentage.

Parameters:
i number to format
decimals number of digits shown after decimal separator

Example:

 MLocale locale; // gets the current system default locale
 QString percentString = locale.formatPercent(0.0123, 2);
Examples of formatPercent results
localedouble valuedecimalsresult
en_US0.012321.23%
en_US12.345678941,234.5679%
de_CH12.345678941'234.5679%
tr_TR12.34567894% 1.234,5679
QString ML10N::MLocale::formatPhoneNumber ( const QString phoneNumber,
PhoneNumberGrouping  grouping = DefaultPhoneNumberGrouping 
) const

Formats a phone number according to the given grouping.

MLocale & ML10N::MLocale::getDefault (  )  [static, protected]

Returns the default locale object.

QString ML10N::MLocale::icuFormatString ( DateType  dateType = DateLong,
TimeType  timeType = TimeLong,
CalendarType  calendarType = DefaultCalendar 
) const

returns ICU date and time format string of the current locale

Parameters:
dateType style of date formatting
timeType style of time formatting
calendarType calendar to use for formatting
QString ML10N::MLocale::indexBucket ( const QString str  )  const

Returns the name of an appropriate sort bucket for a string.

This function is useful to get index titles when sorting a large amount of strings like in a telephone book, a list of videos etc. The list of useful index titles is language specific, for example for Czech (“cs_CZ” locale) it is

“A B C Č D E F G H CH I J K L M N O P Q R Ř S Š T U V W X Y Z Ž”

for Japanese (“ja_JP=standard” locale, same as “ja_JP”) it is

“あ か さ た な は ま や ら わ”

and for traditional Chinese (“zh_TW=stroke”, same as “zh_TW”) locale it is

“一 丁 三 丑 丙 丞 串 並 亟 乘 乾 傢 亂 僧 億 儒 優 叢 嚥 勸 儷 儼 囌 囑 廳”

This function is helpful to find out which bucket a string will be sorted into when sorting locale aware.

Examples for “cs_CZ” locale:

Strings to sort and buckets for “cs_CZ” locale
String Bucket
cesta C
češtinǎ Č
chemie CH
ů U
α Α
Α Α
沙紀

Examples for “ja_JP=standard” locale:

Strings to sort and buckets for “ja_JP=standard” locale
String Bucket
richard R
さき
ジョン
はなこ

Examples for “zh_TW=stroke” locale:

Strings to sort and buckets for “zh_TW=stroke” locale
String Bucket
John J
宁驰
柳 君蘅

As can be seen in the above examples, this function tries to return useful extra buckets for strings which sort out of the range of the bucket list of the language of the current locale. For example if one is running in Czech locale but has also some Japanese and some Greek names in the contact list these foreign strings sort outside of the range of the Czech bucket list. This function tries to create useful extra buckets for these foreign strings.

For applications using an MAbstractItemModel, it is probably more convenient to use the MLocaleBuckets class that uses this function internally.

See also:
MLocaleBuckets
exemplarCharactersIndex()
indexBucket(const QString &str, const QStringList &buckets, const MCollator &collator)
QString ML10N::MLocale::indexBucket ( const QString str,
const QStringList buckets,
const MCollator collator 
) const

Internal version of MLocale::indexBucket().

Parameters:
str String to find a bucket for
buckets bucket list (result of MLocale::exemplarCharactersIndex())
collator collator to use for sorting.

This overloaded function is more efficient if a large number of index buckets is to be retrieved since it can re-use the buckets list and the collator from one call to the next. Before the first call, initialize the 'buckets' list with MLocale::exemplarCharactersIndex().

On top of that, please take care to set the strength of the collator passed as an argument to primary strength, if this is not done the resulting buckets will be slightly wrong.

But use primary strength only for the collator used to get the buckets, not for the collator used to do the actual sorting. The collator used to do the actual sorting should be set to quaternary strength in most cases.

For an explanation of the collation strengths see the Unicode Collation Algorithm.

Example:

 MLocale locale; // gets the current system default locale
 MCollator collator = locale.collator();
 // IMPORTANT: don’t forget to set the collator for the buckets to
 // primary strength:
 collator.setStrength(MLocale::CollatorStrengthPrimary);
 QStringList buckets = locale.exemplarCharactersIndex();
 // now you can find the index bucket for a name, for example
 // in case of “Abraham”, the bucket will be “A” in “en_US” locale and most
 // other locales.
 QString bucket = indexBucket(QString::fromUtf8("Abraham"), buckets, collator);
See also:
indexBucket(const QString &str)
void ML10N::MLocale::installTrCatalog ( const QString name  ) 

installs a translation catalog

Parameters:
name of the translation catalog to install

Adds this translation catalog to the list of translation catalogs used by this MLocale.

The list of catalogs used by the system default locale is the list of catalogs which will be used when translating strings with qtTrId() or tr().

Usually the catalog name should be specified without the “.qm” file extension and without the locale specific part of the file name. I.e. one should usually call installTrCatalog("foo") and not installTrCatalog("foo_en_US.qm").

If only the basename of the catalog (e.g. "foo") is specified, installTrCatalog() installs both the engineering English file for this catalog and the real translations for this catalog for the locale. The engineering English gets lowest priority by prepending it to the list of already installed catalogs and the real translations get highest priority by appending it to the list of already installed catalog names.

Example:

Add translation catalogs “foo” and “bar” to the catalogs used by the system default locale:

 // get current system default locale
 MLocale locale;
 // install a translation catalog
 // (this catalog is added to the list of catalogs already used
 // by the system default locale):
 locale.installTrCatalog("foo");
 locale.installTrCatalog("bar");
 // make the locale with the added translation catalog the new system
 // default:
 MLocale::setDefault(locale);

In this example, after calling locale.installTrCatalog("foo") the internal list of installed catalog names of the locale looks like:

    "foo.qm" "bar.qm" ... previous catalog list ... "foo" "bar"

Priority in this list increases from left to right.

Eventually, this list of catalog names is evaluated and translation files are loaded from the file system. The translation files are searched in the directories in the translation path list, see translationPaths().

For entries in the list of catalog names which end with “.qm” the names are used “as is”, i.e. in the example above the files “foo.qm” and “bar.qm” are loaded for these entries. For entries in the list of catalog names which do not end with “.qm”, a locale specific file name part and a “.qm” extension is added and Qt-like fallbacks for the file name to load are used. As an example, let’s assume that the name of the locale is “en_US”, then the following file names are tried to get the real translations for the catalog name “foo”:

 foo_en_US.qm
 foo_en_US
 foo_en.qm
 foo_en

and the first one which exists is loaded.

Note that the search for fallbacks for the real translation stops at “foo_en”. This is slightly different from the behaviour of QTranslator::load() because proceeding to the fallback “foo.qm” would load engineering English if “foo.qm” exists which is not what we want when trying to load real translations because this might add engineering English with the wrong priority (highest priority) to the list of translation catalogs if the real translation happens to be missing.

If the settings of the locale change, the list of translation catalog names is reevaluated and translations may switch to a different language (see connectSettings(), disconnectSettings(), settingsChanged(), localeSettingsChanged()).

If a full file name including a “.qm” extension is specified as the argument of installTrCatalog(), this catalog name is always appended to the list of catalog names, i.e. used with highest priority. This means that after calling locale.installTrCatalog("foo_en_US.qm") the internal list of installed catalog names looks like:

    ... previous catalog list ... "foo_en_US.qm"

This is mainly intended for testing to force loading of a fully specified translation file with highest priority. Except for testing this should not be used because in the above example with “foo_en_US.qm”, the locale specific part does not change according to the locale settings but always stays like this. And loading an engineering English file by specifying the full file name, i.e. installTrCatalog("foo.qm") should also be used only for testing because this adds the engineering English with highest priority which is usually wrong.

After a locale has been made the system default with setDefault(), the translation catalogs which have been installed into that locale are available for use with qtTrId(), i.e. one can use code like this to translate a string:

 // translate a string:

 //% "Hello"
 QString translatedString = qtTrId("hello_msg");
See also:
isInstalledTrCatalog(const QString &name)
removeTrCatalog(const QString &name)
setDefault(const MLocale &locale)
translationPaths()
setTranslationPaths(const QStringList &paths)
addTranslationPath(const QString &path)
removeTranslationPath(const QString &path)
bool ML10N::MLocale::isInstalledTrCatalog ( const QString name  )  const

checks whether a translation catalog is installed nor not

Parameters:
name of the translation catalog to check

returns true if such a translation catalog has been installed already, false if not.

See also:
installTrCatalog(const QString &name)
removeTrCatalog(const QString &name)
bool ML10N::MLocale::isValid (  )  const

Returns true if MLocale is valid and can be used.

QString ML10N::MLocale::joinStringList ( const QStringList texts  )  const

join a list of strings according to the conventions of the locale

Parameters:
texts the texts to be joined

This method is intended to join a list of strings with commas according to the conventions of the locale. For example, if you want to join a list of names like

“John Doe”, “Judy Roe”, “James Doe”

the result might be “John Doe, Judy Roe, James Doe” in English and many other locales, but for example in Arabic locales or Chinese locales, different versions of the comma may be used.

On top of that, if the list contains both texts in left-to-right scripts and texts right-to-left scripts, texts which have a different direction then the firsts text maybe reordered strangely if all texts are only joined with some separator. Especially if the texts to be joined contain symbols, for example parentheses, weird bidi reordering may happen. To prevent nonsensical bidi reordering, the direction of each text in the list is checked and directional markers are inserted to make sure each individual text is reordered correctly.

QString ML10N::MLocale::language (  )  const

Returns the language code of the locale in ISO-639 format.

If the language code cannot be parsed out of the locale name an empty string is returned.

Example: If the locale name is “fi_FI”, this will return “fi”.

See also:
name()
script()
country()
variant()
QString ML10N::MLocale::languageEndonym (  )  const

Returns the endonym of the language of the locale.

The language endonym is the name of the language which is used by the native speakers of this language.

Examples for language endonyms
English exonymLanguage endonym
GermanDeutsch
Russianрусский язык
Japanese日本語
static QString ML10N::MLocale::languageEndonym ( const QString locale  )  [static]

Static method to obtain endonym for locale. Can be used to obtain endonym without instantiating MLocale, useful when obtaining a list of endonyms for a lot of languages.

static QString ML10N::MLocale::localeScript ( const QString locale  )  [static]

Static method to obtain primary script of locale. Can be used to obtain primary script without instantiating MLocale, useful when obtaining a list of scripts for a lot of languages. Primary script means a script returned by script() or first item in languageScripts().

QStringList ML10N::MLocale::localeScripts (  )  const

Returns the list of scripts used by the locale.

This returns the scripts used by the locale, in form of ISO 15924 script codes. Most locales use only one script but there are a few locales which use several scripts.

Examples for script codes
locale namescript codes
en_USLatn
sr_RSCyrl
sr_Cyrl_RSCyrl
sr_Latn_RSLatn
zh_Hant_TWHani, Bopo
ja_JPKana, Hira, Hani
void ML10N::MLocale::localeSettingsChanged (  )  [signal]

Signal emitted when the default system locale changes.

QString ML10N::MLocale::monthName ( const MCalendar mCalendar,
int  monthNumber,
DateSymbolContext  context,
DateSymbolLength  symbolLength 
) const

Returns the locale dependent name for a month choosing context and length.

See also:
QString monthName(const MCalendar &mCalendar, int monthNumber) const
QString ML10N::MLocale::monthName ( const MCalendar mCalendar,
int  monthNumber 
) const

Returns the locale dependent name for a month number.

calls the 4 argument version of monthName() with context = MLocale::DateSymbolStandalone and symbolLength = MLocale::DateSymbolWide

See also:
QString monthName(const MCalendar &mCalendar, int monthNumber, DateSymbolContext context, DateSymbolLength symbolLength) const
QString ML10N::MLocale::name (  )  const

Returns the string representation of the locale.

The string representation of the locale is the full ICU locale ID string. See the ICU user guide for examples.

See also:
language()
script()
country()
variant()
MLocale & ML10N::MLocale::operator= ( const MLocale other  ) 

Assignment operator.

QDateTime ML10N::MLocale::parseDateTime ( const QString dateTime,
CalendarType  calendarType 
) const

Creates a datetime object from a string with explicit calendar type.

Parameters:
dateTime string to parse
calendarType calendar to use
QDateTime ML10N::MLocale::parseDateTime ( const QString dateTime,
DateType  dateType = DateLong,
TimeType  timeType = TimeLong,
CalendarType  calendarType = DefaultCalendar 
) const

Creates a datetime object from a string with explicit format lengths.

Parameters:
dateTime string to parse
dateType style of date formatting
timeType style of time formatting
calendarType calendar to use for formatting

If dateType is MLocale::DateNone and timeType is MLocale::TimeNone, an invalid QDateTime is returned.

void ML10N::MLocale::removeTranslationPath ( const QString path  )  [static]
void ML10N::MLocale::removeTrCatalog ( const QString name  ) 

removes a translation catalog

Parameters:
name of the translation catalog to remove

Removes the catalog from the list of translation catalogs used by this MLocale.

See also:
isInstalledTrCatalog(const QString &name)
installTrCatalog(const QString &name)
QString ML10N::MLocale::script (  )  const

Returns the script code of the locale in ISO-15924 format.

Returns the part of the locale name which specifies the script in form of ISO 15924 script codes

If that part of the locale name was not specified, i.e. if the default script for that language and country is used, it returns an empty string. For example, if the locale name is “ru_RU”, an empty string is returned and not “Cyrl” which is the ISO 15924 code of the Cyrillic script used by the “ru_RU” locale.

If you need to find out which scripts are used by a certain locale use localeScripts() const instead.

See also:
name()
language()
country()
variant()
localeScripts() const
void ML10N::MLocale::setCalendarType ( CalendarType  calendar  ) 

Sets calendar type.

void ML10N::MLocale::setCategoryLocale ( Category  category,
const QString localeName 
)

Sets category with specified locale string.

Parameters:
localeName ICU format locale ID string.
void ML10N::MLocale::setCollation ( Collation  collation  ) 

Sets the collation mode.

void ML10N::MLocale::setConfigItemFactory ( const MLocaleAbstractConfigItemFactory factory  )  [static]

Tells MLocale to use this factory to create config items

A MLocaleAbstractConfigItem is an abstraction from the way how MLocale gets and sets config values of the system. These can be for example the current language or region of the system. Users of the MLocale library can implement a factory if needed. for an example look at the MLocaleGConfConfigItemFactory.

void ML10N::MLocale::setDataPath ( const QString dataPath  )  [static]

Sets the data paths used by ICU to the given path.

Parameters:
dataPath the data path

convenience function to set the data path used by ICU to a single directory

See also:
setDataPaths(const QStringList &dataPaths)
dataPaths()
void ML10N::MLocale::setDataPaths ( const QStringList dataPaths  )  [static]

Sets the DataPaths for the (ICU) locale system to the given paths.

Parameters:
dataPaths a list of paths

This should be called at most once in a process before creating any MLocale instances. This function is not thread-safe. Use it before doing anything with MLocale instances from multiple threads.

This function calls u_setDataDirectory() in libicu, see also http://icu-project.org/apiref/icu4c/putil_8h.html.

libmeegotouch initialises this data path to the value of the macro

     M_ICUEXTRADATA_DIR

which is normally set to

     /usr/share/mlocale/icu/

usually one should not change this.

The user data itself should be in the ICU specific subdirectories at the given paths, e.g. a user override file for some of the basic data of the Finnish locale should be in

     /usr/share/mlocale/icu/usrdt42l/fi.res

and a user override file for the lang data of the Finnish locale should be in

     /usr/share/mlocale/icu/usrdt42l/lang/fi.res

etc.

See also:
void setDataPath(const QString &dataPath)
dataPaths()
void ML10N::MLocale::setDefault ( const MLocale locale  )  [static]

Sets the default locale.

void ML10N::MLocale::setTimeFormat24h ( TimeFormat24h  timeFormat24h  ) 

Sets whether 24 hour clock, 12 hour clock or default is used.

Parameters:
timeFormat24h enum to choose the 12/24 hour mode

If MLocale::TwelveHourTimeFormat24h is given as the parameter the locale is forced to use 24 hour mode, if MLocale::TwentyFourHourTimeFormat24h is given as the parameter the locale is forced to use 12 hour mode. If MLocale::LocaleDefaultTimeFormat24 is given as the parameter the locale is neither forced to use 12 nor 24 hour mode, it uses the default for this locale then.

See also:
timeFormat24h() const
defaultTimeFormat24h() const
void ML10N::MLocale::settingsChanged (  )  [signal]
void ML10N::MLocale::setTranslationPaths ( const QStringList paths  )  [static]

Sets the paths that are used as base directories for using translations The translation path modification methods are not thread-safe.

The default translation path is

     *    /usr/share/l10n/meegotouch
     * 

i.e. if none of the translation path modification methods is used, the list of translation paths contains only this entry.

See also:
translationPaths()
addTranslationPath(const QString &path)
removeTranslationPath(const QString &path)
Qt::LayoutDirection ML10N::MLocale::textDirection (  )  const

Returns the text direction of the locale.

This function unfortunately has a confusing name, it is not the direction of a certain amount of text, which is detected by directionForText(const QString &text). For a purely Arabic text for example, directionForText() will always return Qt::RightToLeft no matter what the current locale is (it is a static function, thus independent of the current locale, the result only depends on th text given as an argument).

This function here actually returns the layout direction for the current locale.

The layout direction of the QApplication is set to what textDirection() returns for the system default locale (which can be set with setDefault(const MLocale &locale)).

The layout direction returned here used to be Qt::RightToLeft for locales which use RTL scripts (e.g. Arabic, Hebrew, ...) and Qt::LeftToRight for locales which use LTR scripts (e.g. English, Chinese, Russian, ...)

Now this has changed because it has been requested to disable layout reversal by default, therefore this function will always return Qt::LeftToRight by default now, even for locales with RTL scripts like Arabic or Hebrew.

This new behaviour can be overridden by setting the option “layout-direction” in the full locale name. “layout-direction=rtl” forces right-to-left layout direction “layout-direction=ltr” forces left-to-right layout direction and “layout-direction=auto” sets the layout direction to the direction of the script used by the locale, i.e. “layout-direction=auto” reproduces the previous behaviour.

Examples:

Examples for locale names and layout reversal behaviour
Locale ID textDirection() defaultLayoutDirection()
ar_EG Qt::LeftToRight Qt::LeftToRight
ar_EG@layout-direction=ltr Qt::LeftToRight Qt::LeftToRight
ar_EG@layout-direction=rtl Qt::RightToLeft Qt::RightToLeft
ar_EG@layout-direction=auto Qt::RightToLeft Qt::LayoutDirectionAuto
en_US Qt::LeftToRight Qt::LeftToRight
en_US@layout-direction=ltr Qt::LeftToRight Qt::LeftToRight
en_US@layout-direction=rtl Qt::RightToLeft Qt::RightToLeft
en_US@layout-direction=auto Qt::LeftToRight Qt::LayoutDirectionAuto
See also:
defaultLayoutDirection()
directionForText()
setDefault(const MLocale &locale)
MLocale::TimeFormat24h ML10N::MLocale::timeFormat24h (  )  const

Returns whether 24 hour clock, 12 hour clock or default is used.

returns MLocale::TwelveHourTimeFormat24h if 12 hour mode is forced for this locale, returns MLocale::TwentyFourHourTimeFormat24h if 24 hour mode is forced for this locale and returns MLocale::LocaleDefaultTimeFormat24h if the 12/24 hour mode is not forced but left to what this locale would use by default.

See also:
setTimeFormat24h(TimeFormat24h timeFormat24h)
defaultTimeFormat24h() const
double ML10N::MLocale::toDouble ( const QString s,
bool *  ok = 0 
) const

Returns the double represented by a localized string.

Parameters:
s localized string to parse
ok pointer to a bool indicating success or failure

If ok is not NULL, reports failure by setting *ok to false and success by setting *ok to true.

See also:
formatNumber(double i, int precision) const
float ML10N::MLocale::toFloat ( const QString s,
bool *  ok = 0 
) const

Returns the float represented by a localized string.

Parameters:
s localized string to parse
ok pointer to a bool indicating success or failure

If ok is not NULL, reports failure by setting *ok to false and success by setting *ok to true.

See also:
formatNumber(float i) const
int ML10N::MLocale::toInt ( const QString s,
bool *  ok = 0 
) const

Returns the int represented by a localized string.

Parameters:
s localized string to parse
ok pointer to a bool indicating success or failure

If ok is not NULL, reports failure by setting *ok to false and success by setting *ok to true.

See also:
formatNumber(int i) const
QString ML10N::MLocale::toLatinNumbers ( const QString text  )  [static]

converts all localized digits in the input to Latin digits

Parameters:
text a string which may contain various localized digits

This is static, i.e. it does not depend on a specific locale.

It converts all sorts of localized digits, for example Eastern Arabic digits, Devanagari digits, CJK full-width digits ... to the usual Latin digits.

On top of that, it removes directional formatting codes like RLM markers, strings containing numbers in Arabic may contain such markers, they should be removed when converting to Latin numbers.

Other characters in the input apart from digits and directional formatting codes are returned unchanged.

See also:
toLocalizedNumbers(const QString &text)
toLocalizedNumbers(const QString &text, const QString &targetDigits)
QString ML10N::MLocale::toLocalizedNumbers ( const QString text,
const QString targetDigits 
) [static]

converts all localized digits in the input to the given localized digits

Parameters:
text a string which may contain various localized digits
targetDigits a string of length 10 containing the target digits

This is static, i.e. it does not depend on a specific locale.

It converts all sorts of localized digits, for example Eastern Arabic digits, Devanagari digits, CJK full-width digits ... to the digits in the string given as the second parameter. The string given as the second parameter must have exactly a length of 10 specifying the digits of the desired target numbering system.

Only digits are changed, nothing else, except if the target digits are "0123456789", i.e. Latin digits, then it removes directional formatting codes as well, i.e. it behaves like like toLatinNumbers(const QString &text).

See also:
toLocalizedNumbers(const QString &text)
toLatinNumbers(const QString &text)
QString ML10N::MLocale::toLocalizedNumbers ( const QString text  )  const

converts all digits in the input to localized digits

Parameters:
text a string which may contain various localized digits

This converts all digits in the input, whether they are already localized or not, into digits localized for the current locale.

For example, if the input contains Devanagari digits and Latin digits, and if the current locale uses Eastern Arabic digits, both the Devanagari digits and the Latin digits are converted to Eastern Arabic digits.

Only digits are changed, nothing else, except if the target digits are Latin digits, then it behaves like toLatinNumbers(const QString &text) which removes directional formatting codes as well.

See also:
toLocalizedNumbers(const QString &text, const QString &targetDigits)
toLatinNumbers(const QString &text)
qlonglong ML10N::MLocale::toLongLong ( const QString s,
bool *  ok = 0 
) const

Returns the qlonglong represented by a localized string.

Parameters:
s localized string to parse
ok pointer to a bool indicating success or failure

If ok is not NULL, reports failure by setting *ok to false and success by setting *ok to true.

See also:
formatNumber(qlonglong i) const
QString ML10N::MLocale::toLower ( const QString string  )  const

locale-aware and context-sensitive conversion to lowercase

Parameters:
string the string to convert to lowercase

returns the lowercased string.

Use this instead of QString::toLower() if locale-aware and context-sensitive conversion to lowercase is required.

This is implemented using libicu, if libmeegotouch is compiled without libicu, QString::toLower() is used as a fallback.

QString::toLower() is not locale-aware and not context-sensitive, i.e. neither the locale nor the context influence its behaviour.

Therefore, it does not work correctly for Greek, where the character "Σ" (capital sigma) lowercases to either "ς" (small final sigma) or "σ" (small sigma) depending on whether the capital sigma is the last letter in a word. (It is context-dependent.)

Neither does it work for Lithuanian and Turkic languages where a “combining dot above” character may need to be removed in certain cases. (It “contracts” and is language- and context-dependent.)

For details see Unicode Case Mappings.

See also:
toUpper()
short ML10N::MLocale::toShort ( const QString s,
bool *  ok = 0 
) const

Returns the short represented by a localized string.

Parameters:
s localized string to parse
ok pointer to a bool indicating success or failure

If ok is not NULL, reports failure by setting *ok to false and success by setting *ok to true.

See also:
formatNumber(short i) const
QString ML10N::MLocale::toUpper ( const QString string  )  const

locale-aware, context-sensitive conversion to uppercase

Parameters:
string the string to convert to uppercase

returns the uppercased string.

Use this instead of QString::toUpper() if locale-aware and context-sensitive conversion to lowercase is required.

This is implemented using libicu, if libmeegotouch is compiled without libicu, QString::toUpper() is used as a fallback.

QString::toUpper() is not locale-aware and not context-sensitive, i.e. neither the locale nor the context influence its behaviour.

See also:
toLower()
QString ML10N::MLocale::translate ( const char *  context,
const char *  sourceText,
const char *  comment = 0,
int  n = -1 
)

tr() compatibility translation method.

Parameters:
context context of the translation
sourceText text to translate
comment about the translation. may be helpful when creating translation files
n plurality
QStringList ML10N::MLocale::translationPaths (  )  [static]
QString ML10N::MLocale::variant (  )  const

Returns the variant of the locale.

If the variant code cannot be parsed out of the locale name an empty string is returned.

Example: If the locale name is sr_Latn_RS_REVISED@currency=USD this will return REVISED.

See also:
name()
language()
script()
country()
QString ML10N::MLocale::weekdayName ( const MCalendar mCalendar,
int  weekday 
) const
QString ML10N::MLocale::weekdayName ( const MCalendar mCalendar,
int  weekday,
DateSymbolContext  context,
DateSymbolLength  symbolLength 
) const

Returns locale dependent weekday name choosing context and length.

See also:
weekdayName(const MCalendar &mCalendar, int weekday) const

Copyright © 2010 Nokia Corporation
MeeGo Touch