| # kdecore Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# KLocale Class Reference

KLocale provides support for country specific stuff like the national language. class for supporting locale settings and national language. More...

`#include <klocale.h>`

Collaboration diagram for KLocale:

[legend]
List of all members.

## Public Types
enum | SignPosition { ParensAround = 0, BeforeQuantityMoney = 1, AfterQuantityMoney = 2, BeforeMoney = 3, AfterMoney = 4 }
| Various positions for where to place the positive or negative sign when they are related to a monetary value. More...
enum | MeasureSystem { Metric, Imperial }
| The Metric system will give you information in mm, while the Imperial system will give you information in inches. More...
## Public Member Functions
| KLocale (const QString &catalogue, KConfig *config=0)
| Constructs a KLocale with the given catalogue name.
| KLocale (const KLocale &rhs)
| Copy constructor.
KLocale & | operator= (const KLocale &rhs)
| Assignment operator.
| ~KLocale ()
| Destructor.
QString | translate (const char *index) const
| Translates the string into the corresponding string in the national language, if available.
QString | translate (const char *index, const char *fallback) const
| Translates the string into the corresponding string in the national language, if available.
QString | translate (const char *singular, const char *plural, unsigned long n) const
| Used to get the correct, translated singular or plural of a word.
bool | setCharset (const QString &charset)
| This class or method is obsolete, it is provided for compatibility only. Changes the current charset used for fonts.
bool | setEncoding (int mibEnum)
| Changes the current encoding.
bool | setLanguage (const QString &language)
| Changes the current language.
bool | setLanguage (const QStringList &languages)
| Changes the list of prefed languages for the locale.
bool | setCountry (const QString &country)
| Changes the current country.
QString | decimalSymbol () const
| Returns what a decimal point should look like ("." or "," etc.) according to the current locale or user settings.
QString | thousandsSeparator () const
| Returns what the thousands separator should look like ("," or "." etc.) according to the current locale or user settings.
QString | currencySymbol () const
| Returns what the symbol denoting currency in the current locale as as defined by user settings should look like.
QString | monetaryDecimalSymbol () const
| Returns what a decimal point should look like ("." or "," etc.) for monetary values, according to the current locale or user settings.
QString | monetaryThousandsSeparator () const
| Returns what a thousands separator for monetary values should look like ("," or " " etc.) according to the current locale or user settings.
QString | positiveSign () const
| Returns what a positive sign should look like ("+", " ", etc.) according to the current locale or user settings.
QString | negativeSign () const
| Returns what a negative sign should look like ("-", etc.) according to the current locale or user settings.
int | fracDigits () const
| The number of fractional digits to include in numeric/monetary values (usually 2).
bool | positivePrefixCurrencySymbol () const
| If and only if the currency symbol precedes a positive value, this will be true.
bool | negativePrefixCurrencySymbol () const
| If and only if the currency symbol precedes a negative value, this will be true.
SignPosition | positiveMonetarySignPosition () const
| Returns the position of a positive sign in relation to a monetary value.
SignPosition | negativeMonetarySignPosition () const
| Denotes where to place a negative sign in relation to a monetary value.
QString | formatMoney (double num, const QString &currency=QString::null, int digits=-1) const
| Given a double, converts that to a numeric string containing the localized monetary equivalent.
QString | formatMoney (const QString &numStr) const
| This class or method is obsolete, it is provided for compatibility only. This function differs from the above only in that it can take a QString as the argument for convenience.
QString | formatNumber (double num, int precision=-1) const
| Given a double, converts that to a numeric string containing the localized numeric equivalent.
QString | formatNumber (const QString &numStr) const
| This class or method is obsolete, it is provided for compatibility only. This function differs from the above only in that it can take a QString as the argument for convenience.
bool | nounDeclension () const
| Use this to determine whether nouns are declined in locale's language.
QString | formatDate (const QDate &pDate, bool shortFormat=false) const
| Returns a string formatted to the current locale's conventions regarding dates.
bool | dateMonthNamePossessive () const
| Use this to determine whether in dates a possessive form of month name is preferred ("of January" rather than "January").
QString | formatTime (const QTime &pTime, bool includeSecs=false) const
| Returns a string formatted to the current locale's conventions regarding times.
bool | use12Clock () const
| Use this to determine if the user wants a 12 hour clock.
bool | weekStartsMonday () const
| This class or method is obsolete, it is provided for compatibility only.
int | weekStartDay () const
| Use this to determine which day is the first day of the week.
QString | monthName (int i, bool shortName=false) const
| Returns a string containing the name of the month name.
QString | monthNamePossessive (int i, bool shortName=false) const
| Returns a string containing the possessive form of the month name.
QString | weekDayName (int i, bool shortName=false) const
| Returns a string containing the name of the week day.
QString | formatDateTime (const QDateTime &pDateTime, bool shortFormat=true, bool includeSecs=false) const
| Returns a string formated to the current locale's conventions regarding both date and time.
double | readMoney (const QString &numStr, bool *ok=0) const
| Converts a localized monetary string to a double.
double | readNumber (const QString &numStr, bool *ok=0) const
| Converts a localized numeric string to a double.
QDate | readDate (const QString &str, bool *ok=0) const
| Converts a localized date string to a QDate.
QDate | readDate (const QString &intstr, const QString &fmt, bool *ok=0) const
| Converts a localized date string to a QDate, using the specified format.
QTime | readTime (const QString &str, bool *ok=0) const
| Converts a localized time string to a QTime.
QString | language () const
| Returns the language used by this object.
QString | country () const
| Returns the country code of the country where the user lives.
QString | languages () const
| This class or method is obsolete, it is provided for compatibility only. Returns the languages selected by user.
QStringList | languagesTwoAlpha () const
| Returns the preferred languages as ISO 639-1 codes.
QStringList | languageList () const
| Returns the languages selected by user.
QString | charset () const
| This class or method is obsolete, it is provided for compatibility only. Returns the charset name by selected locale.
const char * | encoding () const
| Returns the user's preferred encoding.
int | encodingMib () const
| Returns the user's preferred encoding.
QTextCodec * | codecForEncoding () const
| Returns the user's preferred encoding.
void | setDateFormat (const QString &format)
| Changes the current date format.
void | setDateFormatShort (const QString &format)
| Changes the current short date format.
void | setDateMonthNamePossessive (bool possessive)
| Changes the form of month name used in dates.
void | setTimeFormat (const QString &format)
| Changes the current time format.
void | setWeekStartsMonday (bool start)
| This class or method is obsolete, it is provided for compatibility only.
void | setWeekStartDay (int day)
| Changes how KLocale defines the first day in week.
QString | dateFormat () const
| Returns the currently selected date format.
QString | dateFormatShort () const
| Returns the currently selected short date format.
QString | timeFormat () const
| Returns the currently selected time format.
void | setDecimalSymbol (const QString &symbol)
| Changes the symbol used to identify the decimal pointer.
void | setThousandsSeparator (const QString &separator)
| Changes the separator used to group digits when formating numbers.
void | setPositiveSign (const QString &sign)
| Changes the sign used to identify a positive number.
void | setNegativeSign (const QString &sign)
| Changes the sign used to identify a negative number.
void | setPositiveMonetarySignPosition (SignPosition signpos)
| Changes the sign position used for positive monetary values.
void | setNegativeMonetarySignPosition (SignPosition signpos)
| Changes the sign position used for negative monetary values.
void | setPositivePrefixCurrencySymbol (bool prefix)
| Changes the position where the currency symbol should be printed for positive monetary values.
void | setNegativePrefixCurrencySymbol (bool prefix)
| Changes the position where the currency symbol should be printed for negative monetary values.
void | setFracDigits (int digits)
| Changes the number of digits used when formating numbers.
void | setMonetaryThousandsSeparator (const QString &separator)
| Changes the separator used to group digits when formating monetary values.
void | setMonetaryDecimalSymbol (const QString &symbol)
| Changes the symbol used to identify the decimal pointer for monetary values.
void | setCurrencySymbol (const QString &symbol)
| Changes the current currency symbol.
int | pageSize () const
| Returns the preferred page size for printing.
void | setPageSize (int paperFormat)
| Changes the preferred page size when printing.
MeasureSystem | measureSystem () const
| Returns which measuring system we use.
void | setMeasureSystem (MeasureSystem value)
| Changes the preferred measuring system.
void | insertCatalogue (const QString &catalogue)
| Adds another catalogue to search for translation lookup.
void | removeCatalogue (const QString &catalogue)
| Removes a catalog for translation lookup.
void | setActiveCatalogue (const QString &catalogue)
| Sets the active catalog for translation lookup.
QString | translateQt (const char *context, const char *sourceText, const char *message) const
| Translates a message as a QTranslator is supposed to.
QStringList | allLanguagesTwoAlpha () const
| Returns list of all known ISO 639-1 codes.
QString | twoAlphaToLanguageName (const QString &code) const
| Convert a ISO 639-1 code to a human readable form.
QStringList | allCountriesTwoAlpha () const
| Returns list of all known country codes.
QString | twoAlphaToCountryName (const QString &code) const
| Convert a country code to a human readable form.
## Static Public Member Functions
void | splitLocale (const QString &str, QString &language, QString &country, QString &charset)
| Returns the parts of the parameter str understood as language setting the format is language_COUNTRY.charset.
void | setMainCatalogue (const char *catalogue)
| Use this to as main catalogue for *all* KLocales, if not the appname will be used.
QString | langLookup (const QString &fname, const char *rtype="html")
| Finds localized resource in resourceDir( rtype ) + + fname.
QString | defaultLanguage ()
| Returns the name of the internal language.
QString | defaultCountry ()
| Returns the name of the default country.
QString | _initLanguage (KConfigBase *config)
## Static Protected Member Functions
void | initInstance ()
## Friends
class | KGlobal

## Detailed Description

KLocale provides support for country specific stuff like the national language. class for supporting locale settings and national language.

KLocale supports translating, as well as specifying the format for numbers, currency, time, and date.

Author:
  Stephan Kulow <coolo@kde.org>, Preston Brown <pbrown@kde.org>, Hans Petter Bieker <bieker@kde.org>, Lukas Tinkl <lukas.tinkl@suse.cz>

Definition at line 92 of file klocale.h.

## Member Enumeration Documentation

enum KLocale::SignPosition

| Various positions for where to place the positive or negative sign when they are related to a monetary value. Definition at line 246 of file klocale.h. Referenced by negativeMonetarySignPosition(), and positiveMonetarySignPosition().

enum KLocale::MeasureSystem

| The Metric system will give you information in mm, while the Imperial system will give you information in inches. Definition at line 873 of file klocale.h. Referenced by measureSystem().

## Constructor & Destructor Documentation

KLocale::KLocale | ( | const QString & | catalogue,
|  | KConfig * | config = 0
| ) |

  | Constructs a KLocale with the given catalogue 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 fie. If we were not able to use non 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. Parameters:
  catalogue | The name of the main language file
  config | The configuration file to use.
Definition at line 70 of file klocale.cpp. References KInstance::config(), KGlobal::instance(), and QString::isEmpty().

KLocale::KLocale | ( | const KLocale & | rhs | ) |

| Copy constructor. Definition at line 2087 of file klocale.cpp.

KLocale::~KLocale | ( |  | ) |

| Destructor. Definition at line 600 of file klocale.cpp.

## Member Function Documentation

KLocale & KLocale::operator= | ( | const KLocale & | rhs | ) |

| Assignment operator. Definition at line 2094 of file klocale.cpp. References d, m_country, m_currencySymbol, m_dateFormat, m_dateFormatShort, m_decimalSymbol, m_fracDigits, m_language, m_monetaryDecimalSymbol, m_monetaryThousandsSeparator, m_negativeMonetarySignPosition, m_negativePrefixCurrencySymbol, m_negativeSign, m_positiveMonetarySignPosition, m_positivePrefixCurrencySymbol, m_positiveSign, m_thousandsSeparator, and m_timeFormat.

QString KLocale::translate | ( | const char * | index | ) | const

  | Translates the string into the corresponding string in the national language, if available. If not, returns the string itself. There is a KDE wide message file that contains the most often used phrases, so we can avoid duplicating the translation of these phrases. If a phrase is not found in the catalogue given to the constructor, it will search in the system catalog. This makes it possible to override some phrases for your needs. The argument must be an UTF-8 encoded string (If you only use characters that are in US-ASCII you're on the safe side. But for e.g. german umlauts or french accents should be recoded to UTF-8) Parameters:
  index | The lookup text and default text, if not found.
Definition at line 640 of file klocale.cpp. Referenced by formatDateTime(), formatTime(), monthName(), monthNamePossessive(), and weekDayName().

QString KLocale::translate | ( | const char * | index,
|  | const char * | fallback
| ) | const

  | Translates the string into the corresponding string in the national language, if available. The real contents of the string is in the argument fallback, but the meaning of it is coded into the argument index. In some cases you'll need this function, when english is too ambiguous to express it. Most of the times the translators will tell you if it can't be translated as it, but think of cases as "New", where the translations differs depending on what is New. Or simple cases as "Open", that can be used to express something is open or it can be used to express that you want something to open... There are tons of such examples. If translate("Open") is not enough to translate it well, use translate("To Open", "Open") or translate("Is Open", "Open"). The english user will see "Open" in both cases, but the translated version may vary. Of course you can also use i18n() Parameters:
  index | The lookup text
  fallback | the default text, if not found
Returns: translation Definition at line 645 of file klocale.cpp. References QString::fromUtf8().

QString KLocale::translate | ( | const char * | singular,
|  | const char * | plural,
|  | unsigned long | n
| ) | const

  | Used to get the correct, translated singular or plural of a word. Parameters:
  singular | the singular form of the word, for example "file".
  plural | the plural form of the word. Must contain a "%n" that will be replaced by the number , for example "%n files"
  n | the number
Returns: the correct singular or plural for the selected language, depending on n Definition at line 681 of file klocale.cpp. References QString::find(), QString::fromUtf8(), QString::isEmpty(), and QStringList::split().

bool KLocale::setCharset | ( | const QString & | charset | ) |

  | This class or method is obsolete, it is provided for compatibility only. Changes the current charset used for fonts. Parameters:
  charset | The new charset
Returns: True on success.

bool KLocale::setEncoding | ( | int | mibEnum | ) |

  | Changes the current encoding. Parameters:
  mibEnum | The mib of the preferred codec
Returns: True on success. Definition at line 1999 of file klocale.cpp. References QTextCodec::codecForMib().

bool KLocale::setLanguage | ( | const QString & | language | ) |

  | 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. Parameters:
  language | The language code.
Returns: True on success. Definition at line 378 of file klocale.cpp. Referenced by setLanguage().

bool KLocale::setLanguage | ( | const QStringList & | languages | ) |

  | Changes the list of prefed languages for the locale. The first valid language in the list will be used, or the default (en_US) language will be used if non of the specified languages were available. Parameters:
  languages | The list of language codes.
Returns: True if one of the specified languages were used. Definition at line 392 of file klocale.cpp. References defaultLanguage(), languageList(), and setLanguage().

bool KLocale::setCountry | ( | const QString & | country | ) |

  | Changes the current country. The current country will be left unchanged if failed. It will force a reload of the country specific configuration. Parameters:
  country | The ISO 3166 country code.
Returns: True on success. Definition at line 335 of file klocale.cpp. References QString::isEmpty().

QString KLocale::decimalSymbol | ( |  | ) | const

| 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. Definition at line 896 of file klocale.cpp. Referenced by formatNumber(), and readNumber().

QString KLocale::thousandsSeparator | ( |  | ) | const

| 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. Definition at line 902 of file klocale.cpp. Referenced by formatNumber(), and readNumber().

QString KLocale::currencySymbol | ( |  | ) | const

| 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. Definition at line 908 of file klocale.cpp. Referenced by formatMoney(), and readMoney().

QString KLocale::monetaryDecimalSymbol | ( |  | ) | const

| 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. Definition at line 914 of file klocale.cpp. Referenced by formatMoney(), and readMoney().

QString KLocale::monetaryThousandsSeparator | ( |  | ) | const

| 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. Definition at line 920 of file klocale.cpp. Referenced by formatMoney(), and readMoney().

QString KLocale::positiveSign | ( |  | ) | const

| Returns what a positive sign should look like ("+", " ", etc.) according to the current locale or user settings. Returns: The positive sign used by locale. Definition at line 926 of file klocale.cpp. Referenced by formatMoney(), and formatNumber().

QString KLocale::negativeSign | ( |  | ) | const

| Returns what a negative sign should look like ("-", etc.) according to the current locale or user settings. Returns: The negative sign used by locale. Definition at line 932 of file klocale.cpp. Referenced by formatMoney(), formatNumber(), readMoney(), and readNumber().

int KLocale::fracDigits | ( |  | ) | const

| The number of fractional digits to include in numeric/monetary values (usually 2). Returns: Default number of fractional digits used by locale. Definition at line 938 of file klocale.cpp. Referenced by formatMoney().

bool KLocale::positivePrefixCurrencySymbol | ( |  | ) | const

| 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. Definition at line 944 of file klocale.cpp. Referenced by formatMoney().

bool KLocale::negativePrefixCurrencySymbol | ( |  | ) | const

| If and only if the currency symbol precedes a negative value, this will be true. Returns: True if the currency symbol precedes negative numbers. Definition at line 950 of file klocale.cpp. Referenced by formatMoney().

KLocale::SignPosition KLocale::positiveMonetarySignPosition | ( |  | ) | const

| Returns the position of a positive sign in relation to a monetary value. Returns: Where/how to print the positive sign. See also: SignPosition Definition at line 956 of file klocale.cpp. References SignPosition. Referenced by formatMoney().

KLocale::SignPosition KLocale::negativeMonetarySignPosition | ( |  | ) | const

| Denotes where to place a negative sign in relation to a monetary value. Returns: Where/how to print the negative sign. See also: SignPosition Definition at line 962 of file klocale.cpp. References SignPosition. Referenced by formatMoney(), and readMoney().

QString KLocale::formatMoney | ( | double | num,
|  | const QString & | currency = QString::null,
|  | int | digits = -1
| ) | const

  | Given a double, converts that to a numeric string containing the localized monetary equivalent. e.g. given 123456, return "$ 123,456.00". Parameters:
  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() Definition at line 980 of file klocale.cpp. References QString::append(), currencySymbol(), QString::find(), fracDigits(), QString::insert(), QString::isNull(), QString::length(), monetaryDecimalSymbol(), monetaryThousandsSeparator(), negativeMonetarySignPosition(), negativePrefixCurrencySymbol(), negativeSign(), QString::number(), positiveMonetarySignPosition(), positivePrefixCurrencySymbol(), positiveSign(), QString::prepend(), and QString::replace(). Referenced by formatMoney().

QString KLocale::formatMoney | ( | const QString & | numStr | ) | const

  | This class or method is obsolete, it is provided for compatibility only. This function differs from the above only in that it can take a QString as the argument for convenience. Parameters:
  numStr | The string you want to reformat.
Returns: The number of money as a localized string Definition at line 1041 of file klocale.cpp. References formatMoney(), and QString::toDouble().

QString KLocale::formatNumber | ( | double | num,
|  | int | precision = -1
| ) | const

  | Given a double, converts that to a numeric string containing the localized numeric equivalent. e.g. given 123456.78, return "123,456.78" (for some European country). If precision isn't specified, 2 is used. Parameters:
  num | The number to convert
  precision | Number of fractional digits used.
Returns: The number as a localized string Definition at line 1046 of file klocale.cpp. References decimalSymbol(), QString::find(), QString::insert(), QString::length(), negativeSign(), QString::number(), positiveSign(), QString::prepend(), QString::replace(), and thousandsSeparator(). Referenced by formatNumber().

QString KLocale::formatNumber | ( | const QString & | numStr | ) | const

  | This class or method is obsolete, it is provided for compatibility only. This function differs from the above only in that it can take a QString as the argument for convenience. Parameters:
  numStr | The string you want to convert.
Returns: The number as a formated string Definition at line 1064 of file klocale.cpp. References formatNumber(), and QString::toDouble().

bool KLocale::nounDeclension | ( |  | ) | const

| 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 Since: 3.1 Definition at line 872 of file klocale.cpp.

QString KLocale::formatDate | ( | const QDate & | pDate,
|  | bool | shortFormat = false
| ) | const

  | Returns a string formatted to the current locale's conventions regarding dates. Parameters:
  pDate | The date to be formated.
  shortFormat | True for non text dates.
Returns: The date as a string Definition at line 1069 of file klocale.cpp. References QString::at(), dateFormat(), dateFormatShort(), QDate::day(), QDate::dayOfWeek(), QString::length(), QDate::month(), monthName(), monthNamePossessive(), weekDayName(), and QDate::year(). Referenced by formatDateTime().

bool KLocale::dateMonthNamePossessive | ( |  | ) | const

| 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 Since: 3.1 Definition at line 878 of file klocale.cpp.

QString KLocale::formatTime | ( | const QTime & | pTime,
|  | bool | includeSecs = false
| ) | const

  | Returns a string formatted to the current locale's conventions regarding times. Parameters:
  pTime | The time to be formated.
  includeSecs | if true, seconds are included in the output, otherwise only hours and minutes are formatted.
Returns: The time as a string Definition at line 1584 of file klocale.cpp. References QString::at(), QTime::hour(), QString::length(), QTime::minute(), QTime::second(), timeFormat(), and translate(). Referenced by formatDateTime().

bool KLocale::use12Clock | ( |  | ) | const

| Use this to determine if the user wants a 12 hour clock. Returns: If the user wants 12h clock Definition at line 1663 of file klocale.cpp. References QString::contains(), QString::fromLatin1(), and timeFormat().

bool KLocale::weekStartsMonday | ( |  | ) | const

| This class or method is obsolete, it is provided for compatibility only. Please use the weekStartDay method instead. Use this to determine if the user wants the week to start on Monday. Returns: true if the week starts on Monday Definition at line 890 of file klocale.cpp.

int KLocale::weekStartDay | ( |  | ) | const

| Use this to determine which day is the first day of the week. Returns: an integer (Monday=1..Sunday=7) Since: 3.1 Definition at line 884 of file klocale.cpp.

QString KLocale::monthName | ( | int | i,
|  | bool | shortName = false
| ) | const

  | Returns a string containing the name of the month name. Parameters:
  i | the month number of the year starting at 1/January.
  shortName | we will return the short version of the string.
Returns: The name of the month Definition at line 463 of file klocale.cpp. References translate(). Referenced by formatDate(), and readDate().

QString KLocale::monthNamePossessive | ( | int | i,
|  | bool | shortName = false
| ) | const

  | Returns a string containing the possessive form of the month name. ("of January", "of February", etc.) It's needed in long format dates in some languages. Parameters:
  i | the month number of the year starting at 1/January.
  shortName | we will return the short version of the string.
Returns: The possessive form of the name of the month Since: 3.1 Definition at line 501 of file klocale.cpp. References translate(). Referenced by formatDate(), and readDate().

QString KLocale::weekDayName | ( | int | i,
|  | bool | shortName = false
| ) | const

  | Returns a string containing the name of the week day. Parameters:
  i | the day number of the week starting at 1/Monday.
  shortName | we will return the short version of the string.
Returns: The name of the day Definition at line 539 of file klocale.cpp. References translate(). Referenced by formatDate(), and readDate().

QString KLocale::formatDateTime | ( | const QDateTime & | pDateTime,
|  | bool | shortFormat = true,
|  | bool | includeSecs = false
| ) | const

  | Returns a string formated to the current locale's conventions regarding both date and time. Parameters:
  pDateTime | The date and time to be formated.
  shortFormat | using the short date format.
  includeSeconds | using the short date format.
Returns: The date and time as a string Definition at line 1682 of file klocale.cpp. References QString::arg(), QDateTime::date(), formatDate(), formatTime(), QDateTime::time(), and translate().

double KLocale::readMoney | ( | const QString & | numStr,
|  | bool * | ok = 0
| ) | const

  | Converts a localized monetary string to a double. Parameters:
  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 Definition at line 1217 of file klocale.cpp. References currencySymbol(), QString::find(), QString::isEmpty(), QString::left(), QString::length(), QString::mid(), monetaryDecimalSymbol(), monetaryThousandsSeparator(), negativeMonetarySignPosition(), negativeSign(), QString::remove(), QString::stripWhiteSpace(), and QString::toDouble().

double KLocale::readNumber | ( | const QString & | numStr,
|  | bool * | ok = 0
| ) | const

  | Converts a localized numeric string to a double. Parameters:
  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 Definition at line 1152 of file klocale.cpp. References decimalSymbol(), QString::find(), QString::left(), QString::length(), QString::mid(), negativeSign(), QString::remove(), QString::stripWhiteSpace(), thousandsSeparator(), and QString::toDouble().

QDate KLocale::readDate | ( | const QString & | str,
|  | bool * | ok = 0
| ) | const

  | Converts a localized date string to a QDate. The bool pointed by ok will be invalid if the date entered was not valid. Parameters:
  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 Definition at line 1331 of file klocale.cpp. References QDate::isValid().

QDate KLocale::readDate | ( | const QString & | intstr,
|  | const QString & | fmt,
|  | bool * | ok = 0
| ) | const

| Converts a localized date string to a QDate, using the specified format. You will usually not want to use this method. Definition at line 1345 of file klocale.cpp. References QString::at(), QDate::currentDate(), QChar::isSpace(), QString::length(), QString::lower(), QString::mid(), monthName(), monthNamePossessive(), QString::simplifyWhiteSpace(), and weekDayName().

QTime KLocale::readTime | ( | const QString & | str,
|  | bool * | ok = 0
| ) | const

  | Converts a localized time string to a QTime. The bool pointed by ok will be false if the time entered was not valid. Parameters:
  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 Definition at line 1471 of file klocale.cpp. References QTime::isValid().

QString KLocale::language | ( |  | ) | const

| Returns the language used by this object. The domain AND the library translation must be available in this language. "en_US" is default, if no other available. Returns: The currently used language. Definition at line 453 of file klocale.cpp. Referenced by KConfigBase::setLocale().

QString KLocale::country | ( |  | ) | const

| Returns the country code of the country where the user lives. "C" is default, if no other available Returns: The country code for the user. Definition at line 458 of file klocale.cpp.

QString KLocale::languages | ( |  | ) | const

| This class or method is obsolete, it is provided for compatibility only. Returns the languages selected by user. Returns: String containing language codes separated by colons Definition at line 1672 of file klocale.cpp. References QString::fromLatin1().

QStringList KLocale::languagesTwoAlpha | ( |  | ) | const

| Returns the preferred languages as ISO 639-1 codes. This means that information about country is removed. If the internal language code might be represented by more than one 639-1 code, they will all be listed (but only once). If the selected languages are "nn, nb, pt_BR", you will get: "nn, no, nb, pt". Returns: List of language codes See also: languageList Definition at line 2008 of file klocale.cpp. References QString::find(), QString::fromLatin1(), KConfigBase::hasKey(), languageList(), KConfigBase::readListEntry(), KConfigBase::setGroup(), and QString::truncate().

QStringList KLocale::languageList | ( |  | ) | const

| Returns the languages selected by user. The codes returned here is the internal language codes. Returns: List of language codes See also: languagesTwoAlpha Definition at line 1677 of file klocale.cpp. Referenced by langLookup(), languagesTwoAlpha(), and setLanguage().

QString KLocale::charset | ( |  | ) | const

| This class or method is obsolete, it is provided for compatibility only. Returns the charset name by selected locale. This will be the charset defined in the config file. NOTE: This is no longer the same as encoding. "iso-8859-1" is default Returns: Name of the preferred charset for fonts See also: encoding

const char * KLocale::encoding | ( |  | ) | const

| Returns the user's preferred encoding. Returns: The name of the preferred encoding See also: codecForEncoding encodingMib Definition at line 1984 of file klocale.cpp. References codecForEncoding(), and QTextCodec::name().

int KLocale::encodingMib | ( |  | ) | const

| Returns the user's preferred encoding. Returns: The Mib of the preferred encoding See also: encoding codecForEncoding Definition at line 1989 of file klocale.cpp. References codecForEncoding(), and QTextCodec::mibEnum().

QTextCodec * KLocale::codecForEncoding | ( |  | ) | const

| Returns the user's preferred encoding. Should never be NULL. Returns: The codec for the preferred encoding See also: encoding encodingMib Definition at line 1994 of file klocale.cpp. Referenced by KCharsets::codecForName(), encoding(), and encodingMib().

void KLocale::setDateFormat | ( | const QString & | format | ) |

  | Changes the current date format. The format of the date is a string which contains variables that will be replaced: Y with the century (e.g. "19" for "1984") y with the lower 2 digits of the year (e.g. "84" for "1984") n with the month (January="1", December="12") m with the month with two digits (January="01", December="12") e with the day of the month (e.g. "1" on the first of march) d with the day of the month with two digits(e.g. "01" on the first of march) b with the short form of the month (e.g. "Jan" for January) a with the short form of the weekday (e.g. "Wed" for Wednesday) A with the long form of the weekday (e.g. "Wednesday" for Wednesday) 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". Parameters:
  format | The new date format
Definition at line 1815 of file klocale.cpp. References QString::stripWhiteSpace().

void KLocale::setDateFormatShort | ( | const QString & | format | ) |

  | Changes the current short date format. The format of the date is a string which contains variables that will be replaced: Y with the century (e.g. "19" for "1984") y with the lower 2 digits of the year (e.g. "84" for "1984") n with the month (January="1", December="12") m with the month with two digits (January="01", December="12") e with the day of the month (e.g. "1" on the first of march) d with the day of the month with two digits(e.g. "01" on the first of march) b with the short form of the month (e.g. "Jan" for January) a with the short form of the weekday (e.g. "Wed" for Wednesday) A with the long form of the weekday (e.g. "Wednesday" for Wednesday) 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". Parameters:
  format | The new short date format
Definition at line 1821 of file klocale.cpp. References QString::stripWhiteSpace().

void KLocale::setDateMonthNamePossessive | ( | bool | possessive | ) |

  | Changes the form of month name used in dates. Parameters:
  possessive | True if possessive forms should be used
Since: 3.1 Definition at line 1827 of file klocale.cpp.

void KLocale::setTimeFormat | ( | const QString & | format | ) |

  | Changes the current time format. The format of the time is string a which contains variables that will be replaced: H with the hour in 24h format and 2 digits (e.g. 5pm is "17", 5am is "05") k with the hour in 24h format and one digits (e.g. 5pm is "17", 5am is "5") I with the hour in 12h format and 2 digits (e.g. 5pm is "05", 5am is "05") l with the hour in 12h format and one digits (e.g. 5pm is "5", 5am is "5") M with the minute with 2 digits (e.g. the minute of 07:02:09 is "02") S with the seconds with 2 digits (e.g. the minute of 07:02:09 is "09") p with pm or am (e.g. 17.00 is "pm", 05.00 is "am") Everything else in the format string will be taken as is. For example, 5.23pm with the format "%H:%M" results in "17:23". Parameters:
  format | The new time format
Definition at line 1833 of file klocale.cpp. References QString::stripWhiteSpace().

void KLocale::setWeekStartsMonday | ( | bool | start | ) |

  | This class or method is obsolete, it is provided for compatibility only. Please use setWeekStartDay instead. Changes how KLocale defines the first day in week. Parameters:
  start | True if Monday is the first day in the week
Definition at line 1839 of file klocale.cpp.

void KLocale::setWeekStartDay | ( | int | day | ) |

  | Changes how KLocale defines the first day in week. Parameters:
  day | first day of the week (Monday=1..Sunday=7) as integer
Since: 3.1 Definition at line 1848 of file klocale.cpp.

QString KLocale::dateFormat | ( |  | ) | const

| Returns the currently selected date format. Returns: Current date format. See also: setDateFormat() Definition at line 1857 of file klocale.cpp. Referenced by formatDate().

QString KLocale::dateFormatShort | ( |  | ) | const

| Returns the currently selected short date format. Returns: Current short date format. See also: setDateFormatShort() Definition at line 1863 of file klocale.cpp. Referenced by formatDate().

QString KLocale::timeFormat | ( |  | ) | const

| Returns the currently selected time format. Returns: Current time format. See also: setTimeFormat() Definition at line 1869 of file klocale.cpp. Referenced by formatTime(), and use12Clock().

void KLocale::setDecimalSymbol | ( | const QString & | symbol | ) |

  | Changes the symbol used to identify the decimal pointer. Parameters:
  symbol | The new decimal symbol.
Definition at line 1875 of file klocale.cpp. References QString::stripWhiteSpace().

void KLocale::setThousandsSeparator | ( | const QString & | separator | ) |

  | Changes the separator used to group digits when formating numbers. Parameters:
  separator | The new thousands separator.
Definition at line 1881 of file klocale.cpp.

void KLocale::setPositiveSign | ( | const QString & | sign | ) |

  | Changes the sign used to identify a positive number. Normally this is left blank. Parameters:
  sign | Sign used for positive numbers.
Definition at line 1888 of file klocale.cpp. References QString::stripWhiteSpace().

void KLocale::setNegativeSign | ( | const QString & | sign | ) |

  | Changes the sign used to identify a negative number. Parameters:
  sign | Sign used for negative numbers.
Definition at line 1894 of file klocale.cpp. References QString::stripWhiteSpace().

void KLocale::setPositiveMonetarySignPosition | ( | SignPosition | signpos | ) |

  | Changes the sign position used for positive monetary values. Parameters:
  signpos | The new sign position
Definition at line 1900 of file klocale.cpp.

void KLocale::setNegativeMonetarySignPosition | ( | SignPosition | signpos | ) |

  | Changes the sign position used for negative monetary values. Parameters:
  signpos | The new sign position
Definition at line 1906 of file klocale.cpp.

void KLocale::setPositivePrefixCurrencySymbol | ( | bool | prefix | ) |

  | Changes the position where the currency symbol should be printed for positive monetary values. Parameters:
  prefix | True if the currency symbol should be prefixed instead of postfixed
Definition at line 1912 of file klocale.cpp.

void KLocale::setNegativePrefixCurrencySymbol | ( | bool | prefix | ) |

  | Changes the position where the currency symbol should be printed for negative monetary values. Parameters:
  prefix | True if the currency symbol should be prefixed instead of postfixed
Definition at line 1918 of file klocale.cpp.

void KLocale::setFracDigits | ( | int | digits | ) |

  | Changes the number of digits used when formating numbers. Parameters:
  digits | The default number of digits to use.
Definition at line 1924 of file klocale.cpp.

void KLocale::setMonetaryThousandsSeparator | ( | const QString & | separator | ) |

  | Changes the separator used to group digits when formating monetary values. Parameters:
  separator | The new thousands separator.
Definition at line 1930 of file klocale.cpp.

void KLocale::setMonetaryDecimalSymbol | ( | const QString & | symbol | ) |

  | Changes the symbol used to identify the decimal pointer for monetary values. Parameters:
  symbol | The new decimal symbol.
Definition at line 1937 of file klocale.cpp. References QString::stripWhiteSpace().

void KLocale::setCurrencySymbol | ( | const QString & | symbol | ) |

  | Changes the current currency symbol. Parameters:
  symbol | The new currency symbol
Definition at line 1943 of file klocale.cpp. References QString::stripWhiteSpace().

int KLocale::pageSize | ( |  | ) | const

| Returns the preferred page size for printing. Returns: The preferred page size, cast it to QPrinter::PageSize Definition at line 1949 of file klocale.cpp.

void KLocale::setPageSize | ( | int | paperFormat | ) |

  | Changes the preferred page size when printing. Parameters:
  The | new preferred page size in the format QPrinter::PageSize
Definition at line 1955 of file klocale.cpp.

KLocale::MeasureSystem KLocale::measureSystem | ( |  | ) | const

| Returns which measuring system we use. Returns: The preferred measuring system Definition at line 1962 of file klocale.cpp. References MeasureSystem.

void KLocale::setMeasureSystem | ( | MeasureSystem | value | ) |

| Changes the preferred measuring system. Returns: value The preferred measuring system Definition at line 1968 of file klocale.cpp.

void KLocale::insertCatalogue | ( | const QString & | catalogue | ) |

  | Adds another catalogue to search for translation lookup. This function is useful for extern libraries and/or code, that provides its own messages. If the catalogue does not exist for the chosen language, it will be ignored and en_US will be used. Parameters:
  catalogue | The catalogue to add.
Definition at line 567 of file klocale.cpp.

void KLocale::removeCatalogue | ( | const QString & | catalogue | ) |

  | Removes a catalog for translation lookup. Parameters:
  catalogue | The catalogue to remove.
See also: insertCatalogue() Definition at line 576 of file klocale.cpp.

void KLocale::setActiveCatalogue | ( | const QString & | catalogue | ) |

  | Sets the active catalog for translation lookup. Parameters:
  catalogue | The catalogue to activate.
Definition at line 587 of file klocale.cpp. References KStdAction::save(). Referenced by KGlobal::setActiveInstance().

QString KLocale::translateQt | ( | const char * | context,
|  | const char * | sourceText,
|  | const char * | message
| ) | const

| 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::null) Since: 3.1 Definition at line 828 of file klocale.cpp.

QStringList KLocale::allLanguagesTwoAlpha | ( |  | ) | const

| Returns list of all known ISO 639-1 codes. Returns: a list of all language codes Since: 3.1 Definition at line 2048 of file klocale.cpp.

QString KLocale::twoAlphaToLanguageName | ( | const QString & | code | ) | const

  | Convert a ISO 639-1 code to a human readable form. Parameters:
  code | the language ISO 639-1 code
Returns: the human readable form Since: 3.1 Definition at line 2056 of file klocale.cpp. References QString::lower().

QStringList KLocale::allCountriesTwoAlpha | ( |  | ) | const

| Returns list of all known country codes. Returns: a list of all country codes Since: 3.1 Definition at line 2065 of file klocale.cpp. References KGlobal::dirs(), and KStandardDirs::findAllResources().

QString KLocale::twoAlphaToCountryName | ( | const QString & | code | ) | const

  | Convert a country code to a human readable form. Parameters:
  code | the country code
Returns: the human readable form of the country name Since: 3.1 Definition at line 2079 of file klocale.cpp. References QString::lower(), KConfigBase::readEntry(), and KConfigBase::setGroup().

void KLocale::splitLocale | ( | const QString & | str,
|  | QString & | language,
|  | QString & | country,
|  | QString & | charset
| ) | `[static]`

  | Returns the parts of the parameter str understood as language setting the format is language_COUNTRY.charset. Parameters:
  str | The string to split.
  language | This will be set to the language part of the string.
  country | This will be set to the country part of the string.
  charset | This will be set to the charset part of the string.
Definition at line 420 of file klocale.cpp. References QString::find(), QString::mid(), and QString::truncate().

void KLocale::setMainCatalogue | ( | const char * | catalogue | ) | `[static]`

  | Use this to as main catalogue 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 (and this is in common KDE applications quite early). Parameters:
  catalogue | Catalogue to override all other main catalogues.
Definition at line 1147 of file klocale.cpp.

QString KLocale::langLookup | ( | const QString & | fname,
|  | const char * | rtype = "html"
| ) | `[static]`

  | Finds localized resource in resourceDir( rtype ) + + fname. Parameters:
  fname | relative path to find
  rtype | resource type to use
Definition at line 1734 of file klocale.cpp. References defaultLanguage(), KGlobal::dirs(), QFileInfo::exists(), QFileInfo::isFile(), QFileInfo::isReadable(), languageList(), KGlobal::locale(), and KStandardDirs::resourceDirs().

QString KLocale::defaultLanguage | ( |  | ) | `[static]`

| Returns the name of the internal language. Returns: Name of the default language Definition at line 1974 of file klocale.cpp. References QString::fromLatin1(). Referenced by langLookup(), setLanguage(), and KConfigBase::setLocale().

QString KLocale::defaultCountry | ( |  | ) | `[static]`

| Returns the name of the default country. Returns: Name of the default country Definition at line 1979 of file klocale.cpp. References QString::fromLatin1().

The documentation for this class was generated from the following files:

- klocale.h
- klocale.cpp

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 12:49:48 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001