class KLocale |
|
KLocale provides support for country specific stuff like
the national language.
KLocale supports translating, as well as specifying the format for numbers, currency, time, and date. Use KGlobal.locale() to get pointer to the global KLocale object, containing the applications current locale settings. For example, to format the date May 17, 1995 in the current locale, use:
QString date = KGlobal.locale()->formatDate(QDate(1995,5,17));
Author Stephan Kulow |
|
Constructs a KLocale with the given catalog name.
The constructor looks for an entry Locale/Language in the
configuration file.
If no config file is specified, it will also look for languages
using the environment variables (KDE_LANG, LC_MESSAGES, LC_ALL, LANG),
as well as the global configuration file. If KLocale is not able to use
any of the specified languages, the default language (en_US) will be
used.
If you specify a configuration file, it has to be valid until the KLocale object is destroyed. catalog - The name of the main language file config - The configuration file to use. |
|
|
Copy constructor. |
|
|
Provides list of all known country codes.
Use countryCodeToName(country) to get human readable, localized country names. Returns a list of all country codes See also countryCodeToName |
|
Provides list of all known language codes.
Use languageCodeToName(language) to get human readable, localized language names. Returns list of all language codes See also languageCodeToName |
|
Returns a pointer to the calendar system object.
Returns the current calendar system instance |
|
Returns the name of the calendar system that is currently being
used by the system.
Returns the name of the calendar system |
|
Returns the user's preferred encoding. Should never be NULL.
Returns The codec for the preferred encoding See also encoding See also encodingMib |
|
Copies the catalogs of this objct to an other KLocale object. |
|
Returns the country code of the country where the user lives.
defaultCountry() is returned by default, if no other available.
Use countryCodeToName(country) to get human readable, localized country names. Returns the country code for the user See also countryCodeToName |
|
Convert a known country code to a human readable, localized form.
If an unknown country code is supplied, empty string is returned;
this will never happen if the code has been obtained by one of the
KLocale methods.
code - the country code Returns the human readable and localized form of the country name See also country See also allCountriesList |
|
Returns what the symbol denoting currency in the current locale
as as defined by user settings should look like.
Returns The default currency symbol used by locale. |
|
Returns the currently selected date format.
Returns Current date format. See also setDateFormat() |
|
Returns the currently selected short date format.
Returns Current short date format. See also setDateFormatShort() |
|
Use this to determine whether in dates a possessive form of month
name is preferred ("of January" rather than "January")
Returns If possessive form should be used |
|
Returns what a decimal point should look like ("." or "," etc.)
according to the current locale or user settings.
Returns The decimal symbol used by locale. |
|
Returns the name of the default country.
Returns Name of the default country |
|
Returns the name of the internal language.
Returns Name of the default language |
|
Returns the user's preferred encoding.
Returns The name of the preferred encoding See also codecForEncoding See also encodingMib |
|
Returns the user's preferred encoding.
Returns The Mib of the preferred encoding See also encoding See also codecForEncoding |
|
Returns the file encoding.
Returns The Mib of the file encoding See also QFile.encodeName See also QFile.decodeName |
|
Converts size from bytes to the string representation using the
IEC 60027-2 standard
Example: formatByteSize(1024) returns "1.0 KiB" - size size in bytes Returns converted size as a string - e.g. 123.4 KiB , 12.0 MiB |
|
Returns a string formatted to the current locale's conventions
regarding dates.
date - the date to be formatted. format - category of date format to use Returns The date as a string |
|
Returns a string formatted to the current locale's conventions
regarding both date and time.
dateTime - the date and time to be formatted format - category of date format to use options - additional output options Returns The date and time as a string |
|
Returns a string formatted to the current locale's conventions
regarding both date and time.
dateTime - the date and time to be formatted format - category of date format to use options - additional output options Returns The date and time as a string |
|
Given a number of milliseconds, converts that to a string containing
the localized equivalent
e.g. given formatDuration(60000), returns "1.0 minutes" mSec - Time duration in milliseconds Returns converted duration as a string - e.g. "5.5 seconds" "23.0 minutes" |
|
Given an integer, converts that to a numeric string containing
the localized numeric equivalent.
e.g. given 123456L, return "123,456" (for some European country). num - The number to convert Returns The number as a localized string |
|
Given a double, converts that to a numeric string containing
the localized monetary equivalent.
e.g. given 123456, return "$ 123,456.00". num - The number we want to format currency - The currency symbol you want. digits - Number of fractional digits, or -1 for the default value Returns The number of money as a localized string See also fracDigits() |
|
Given a double, converts that to a numeric string containing
the localized numeric equivalent.
e.g. given 123456.78F, return "123,456.78" (for some European country). If precision isn't specified, 2 is used. This function is a wrapper that is provided for convenience. num - The number to convert precision - Number of fractional digits used. Returns The number as a localized string See also formatNumber(const QString, bool, int) |
|
Given a string representing a number, converts that to a numeric
string containing the localized numeric equivalent.
e.g. given 123456.78F, return "123,456.78" (for some European country). numStr - The number to format, as a string. round - Round fractional digits. (default true) precision - Number of fractional digits used for rounding. Unused if round=false. (default 2) Returns The number as a localized string |
|
Returns a string formatted to the current locale's conventions
regarding times.
pTime - The time to be formatted. includeSecs - if true, seconds are included in the output, otherwise only hours and minutes are formatted. isDuration - if true, the given time is a duration, not a clock time. This means "am/pm" shouldn't be displayed. Returns The time as a string |
|
The number of fractional digits to include in numeric/monetary
values (usually 2).
Returns Default number of fractional digits used by locale. |
|
Adds another catalog to search for translation lookup.
This function is useful for extern libraries and/or code,
that provide there own messages.
If the catalog does not exist for the chosen language, it will be ignored and en_US will be used. catalog - The catalog to add. |
|
Checks whether or not the active catalog is found for the given language.
language - language to check |
|
Deprecated
Finds localized resource in resourceDir( rtype ) + \ Since KDE 4.1, this service is provided in a slightly different form, automatically by e.g. KStandardDirs.locate() and other KDE core classes dealing with paths. For manual use, it is replaced by localizedFilePath(). fname - relative path to find rtype - resource type to use Returns path to localized resource See also localizedFilePath |
|
Returns the language code used by this object. The domain AND the
library translation must be available in this language.
defaultLanguage() is returned by default, if no other available.
Use languageCodeToName(language) to get human readable, localized language name. Returns the currently used language code See also languageCodeToName |
|
Convert a known language code to a human readable, localized form.
If an unknown language code is supplied, empty string is returned;
this will never happen if the code has been obtained by one of the
KLocale methods.
language - the language code Returns the human readable and localized form if the code is known, empty otherwise See also language See also languageList See also allLanguagesList |
|
Returns the language codes selected by user, ordered by decreasing
priority.
Use languageCodeToName(language) to get human readable, localized language name. Returns list of language codes See also languageCodeToName |
|
@since 4.1
Tries to find a path to the localized file for the given original path. This is intended mainly for non-text resources (images, sounds, etc.), whereas text resources should be handled in more specific ways. The possible localized paths are checked in turn by priority of set languages, in form of dirname/l10n/ll/basename, where dirname and basename are those of the original path, and ll is the language code. KDE core classes which resolve paths internally (e.g. KStandardDirs) will usually perform this lookup behind the scene. In general, you should pipe resource paths through this method only on explicit translators' request, or when a resource is an obvious candidate for localization (e.g. a splash screen or a custom icon with some text drawn on it). filePath - path to the original file Returns path to the localized file if found, original path otherwise |
|
Returns which measuring system we use.
Returns The preferred measuring system |
|
Returns what a decimal point should look like ("." or "," etc.)
for monetary values, according to the current locale or user
settings.
Returns The monetary decimal symbol used by locale. |
|
Returns what a thousands separator for monetary values should
look like ("," or " " etc.) according to the current locale or
user settings.
Returns The monetary thousands separator used by locale. |
|
Denotes where to place a negative sign in relation to a
monetary value.
Returns Where/how to print the negative sign. See also SignPosition |
|
If and only if the currency symbol precedes a negative value,
this will be true.
Returns True if the currency symbol precedes negative numbers. |
|
Returns what a negative sign should look like ("-", etc.)
according to the current locale or user settings.
Returns The negative sign used by locale. |
|
Use this to determine whether nouns are declined in
locale's language. This property should remain
read-only (no setter function)
Returns If nouns are declined |
|
Returns the preferred page size for printing.
Returns The preferred page size, cast it to QPrinter.PageSize |
|
Returns the position of a positive sign in relation to a
monetary value.
Returns Where/how to print the positive sign. See also SignPosition |
|
If and only if the currency symbol precedes a positive value,
this will be true.
Returns Where to print the currency symbol for positive numbers. |
|
Returns what a positive sign should look like ("+", " ", etc.)
according to the current locale or user settings.
Returns The positive sign used by locale. |
|
Converts a localized date string to a QDate.
The bool pointed by ok will be invalid if the date entered was not valid.
str - the string we want to convert. ok - the boolean that is set to false if it's not a valid date. If ok is 0, it will be ignored Returns The string converted to a QDate |
|
Converts a localized date string to a QDate, using the specified format. You will usually not want to use this method. |
|
Converts a localized date string to a QDate.
This method is stricter than readDate(str,&ok): it will either accept
a date in full format or a date in short format, depending on flags.
str - the string we want to convert. flags - whether the date string is to be in full format or in short format. ok - the boolean that is set to false if it's not a valid date. If ok is 0, it will be ignored Returns The string converted to a QDate |
|
Converts a localized monetary string to a double.
numStr - the string we want to convert. ok - the boolean that is set to false if it's not a number. If ok is 0, it will be ignored Returns The string converted to a double |
|
Converts a localized numeric string to a double.
numStr - the string we want to convert. ok - the boolean that is set to false if it's not a number. If ok is 0, it will be ignored Returns The string converted to a double |
|
Converts a localized time string to a QTime.
This method will try to parse it with seconds, then without seconds.
The bool pointed to by ok will be set to false if the time entered was
not valid.
str - the string we want to convert. ok - the boolean that is set to false if it's not a valid time. If ok is 0, it will be ignored Returns The string converted to a QTime |
|
Converts a localized time string to a QTime.
This method is stricter than readTime(str,&ok): it will either accept
a time with seconds or a time without seconds.
Use this method when the format is known by the application.
str - the string we want to convert. flags - whether the time string is expected to contain seconds or not. ok - the boolean that is set to false if it's not a valid time. If ok is 0, it will be ignored Returns The string converted to a QTime |
|
Removes a catalog for translation lookup.
catalog - The catalog to remove. See also insertCatalog() |
|
Sets the active catalog for translation lookup.
catalog - The catalog to activate. |
|
Changes the current calendar system to the calendar specified.
Currently "gregorian" and "hijri" are supported. If the calendar
system specified is not found, gregorian will be used.
calendarType - the name of the calendar type |
|
Changes the current country. The current country will be left
unchanged if failed. It will force a reload of the country specific
configuration.
country - The ISO 3166 country code. Returns True on success. |
|
Changes the current currency symbol.
symbol - The new currency symbol |
|
Changes the current date format.
The format of the date is a string which contains variables that will be replaced: Everything else in the format string will be taken as is. For example, March 20th 1989 with the format "%y:%m:%d" results in "89:03:20". format - The new date format |
|
Changes the current short date format.
The format of the date is a string which contains variables that will be replaced: Everything else in the format string will be taken as is. For example, March 20th 1989 with the format "%y:%m:%d" results in "89:03:20". format - The new short date format |
|
Changes the form of month name used in dates.
possessive - True if possessive forms should be used |
|
Changes the symbol used to identify the decimal pointer.
symbol - The new decimal symbol. |
|
Changes the current encoding.
mibEnum - The mib of the preferred codec Returns True on success. |
|
Changes the number of digits used when formating numbers.
digits - The default number of digits to use. |
|
Changes the current language. The current language will be left
unchanged if failed. It will force a reload of the country specific
configuration as well.
language - the language code Returns true on success |
|
Changes the list of preferred languages for the locale. The first valid
language in the list will be used, or the default language (en_US)
if none of the specified languages were available.
languages - the list of language codes Returns true if one of the specified languages were used |
|
Use this as main catalog for *all* KLocales, if not the appname
will be used. This function is best to be the very first instruction
in your program's main function as it only has an effect before the
first KLocale object is created.
catalog - Catalog to override all other main Catalogs. |
|
Changes the preferred measuring system.
Returns value The preferred measuring system |
|
Changes the symbol used to identify the decimal pointer for monetary
values.
symbol - The new decimal symbol. |
|
Changes the separator used to group digits when formating monetary values.
separator - The new thousands separator. |
|
Changes the sign position used for negative monetary values.
signpos - The new sign position |
|
Changes the position where the currency symbol should be printed for
negative monetary values.
prefix - True if the currency symbol should be prefixed instead of postfixed |
|
Changes the sign used to identify a negative number.
sign - Sign used for negative numbers. |
|
Changes the preferred page size when printing.
paperFormat - the new preferred page size in the format QPrinter.PageSize |
|
Changes the sign position used for positive monetary values.
signpos - The new sign position |
|
Changes the position where the currency symbol should be printed for
positive monetary values.
prefix - True if the currency symbol should be prefixed instead of postfixed |
|
Changes the sign used to identify a positive number. Normally this is
left blank.
sign - Sign used for positive numbers. |
|
Changes the separator used to group digits when formating numbers.
separator - The new thousands separator. |
|
Changes the current time format.
The format of the time is string a which contains variables that will be replaced: Everything else in the format string will be taken as is. For example, 5.23pm with the format "%H:%M" results in "17:23". format - The new time format |
|
Changes how KLocale defines the first day in week.
day - first day of the week (Monday=1..Sunday=7) as integer |
|
Parses locale string into distinct parts.
The format of locale is language_COUNTRY@modifier.CHARSET
locale - the locale string to split language - set to the language part of the locale country - set to the country part of the locale modifier - set to the modifer part of the locale charset - set to the charset part of the locale |
|
Returns what the thousands separator should look
like ("," or "." etc.)
according to the current locale or user settings.
Returns The thousands separator used by locale. |
|
Returns the currently selected time format.
Returns Current time format. See also setTimeFormat() |
|
Translates a message as a QTranslator is supposed to. The parameters are similar to i18n(), but the result value has other semantics (it can be QString()) |
|
Raw translation from message catalogs.
Never use this directly to get message translations. See i18n* and ki18n* calls related to KLocalizedString. msg - the message. Must not be null. Must be UTF-8 encoded. lang - language in which the translation was found. If no translation was found, KLocale.defaultLanguage() is reported. If null, the language is not reported. trans - raw translation, or original if not found. If no translation was found, original message is reported. If null, the translation is not reported. See also KLocalizedString |
|
Raw translation from message catalogs, with given context.
Context + message are used as the lookup key in catalogs.
Never use this directly to get message translations. See i18n* and ki18n* calls related to KLocalizedString. ctxt - the context. Must not be null. Must be UTF-8 encoded. msg - the message. Must not be null. Must be UTF-8 encoded. lang - language in which the translation was found. If no translation was found, KLocale.defaultLanguage() is reported. If null, the language is not reported. trans - raw translation, or original if not found. If no translation was found, original message is reported. If null, the translation is not reported. See also KLocalizedString |
|
Raw translation from message catalogs, with given singular/plural form.
Singular form is used as the lookup key in catalogs.
Never use this directly to get message translations. See i18n* and ki18n* calls related to KLocalizedString. singular - the singular form. Must not be null. Must be UTF-8 encoded. plural - the plural form. Must not be null. Must be UTF-8 encoded. n - number on which the forms are decided. lang - language in which the translation was found. If no translation was found, KLocale.defaultLanguage() is reported. If null, the language is not reported. trans - raw translation, or original if not found. If no translation was found, original message is reported (either plural or singular, as determined by n ). If null, the translation is not reported. See also KLocalizedString |
|
Raw translation from message catalogs, with given context and
singular/plural form.
Context + singular form is used as the lookup key in catalogs.
Never use this directly to get message translations. See i18n* and ki18n* calls related to KLocalizedString. ctxt - the context. Must not be null. Must be UTF-8 encoded. singular - the singular form. Must not be null. Must be UTF-8 encoded. plural - the plural form. Must not be null. Must be UTF-8 encoded. n - number on which the forms are decided. lang - language in which the translation was found. If no translation was found, KLocale.defaultLanguage() is reported. If null, the language is not reported. trans - raw translation, or original if not found. If no translation was found, original message is reported (either plural or singular, as determined by n ). If null, the translation is not reported. See also KLocalizedString |
|
Use this to determine if the user wants a 12 hour clock.
Returns If the user wants 12h clock |
|
Reports whether evaluation of translation scripts is enabled.
Returns true if script evaluation is enabled, false otherwise. |
|
Use this to determine which day is the first day of the week.
Returns an integer (Monday=1..Sunday=7) |
Format for date string.
ShortDate | - | - | ||
LongDate | - | - | ||
FancyShortDate | - | - | ||
FancyLongDate | - | - |
Options for formatting date-time values.
TimeZone | - 0x01 | - | ||
Seconds | - 0x02 | - |
The Metric system will give you information in mm, while the Imperial system will give you information in inches.
Metric | - | - | ||
Imperial | - | - |
Flags for readDate()
NormalFormat | - 1 | - | ||
ShortFormat | - 2 | - |
Flags for readTime()
WithSeconds | - 0 | - | ||
WithoutSeconds | - 1 | - |
Put parantheses around the quantity, e.g. "$ (217)"
ParensAround | - 0 | - | ||
BeforeQuantityMoney | - 1 | - | ||
AfterQuantityMoney | - 2 | - | ||
BeforeMoney | - 3 | - | ||
AfterMoney | - 4 | - |