• Skip to content
  • Skip to link menu
KDE 4.3 API Reference
  • KDE API Reference
  • kdelibs
  • Sitemap
  • Contact Us
 

KDECore

KLocale Class Reference

KLocale provides support for country specific stuff like the national language. More...

#include <klocale.h>

List of all members.

Public Types

enum  DateFormat { ShortDate, LongDate, FancyShortDate, FancyLongDate }
enum  DateTimeFormatOption { TimeZone = 0x01, Seconds = 0x02 }
enum  DigitSet { ArabicDigits, ArabicIndicDigits, EasternArabicIndicDigits, DevenagariDigits }
enum  MeasureSystem { Metric, Imperial }
enum  ReadDateFlags { NormalFormat = 1, ShortFormat = 2 }
enum  ReadTimeFlags { WithSeconds = 0, WithoutSeconds = 1 }
enum  SignPosition {
  ParensAround = 0, BeforeQuantityMoney = 1, AfterQuantityMoney = 2, BeforeMoney = 3,
  AfterMoney = 4
}

Public Member Functions

QStringList allCountriesList () const
QList< DigitSet > allDigitSetsList () const
QStringList allLanguagesList () const
const KCalendarSystem * calendar () const
QString calendarType () const
QTextCodec * codecForEncoding () const
QString convertDigits (const QString &str, DigitSet digitSet, bool ignoreContext=false) const
void copyCatalogsTo (KLocale *locale)
QString country () const
QString countryCodeToName (const QString &country) const
QString currencySymbol () const
QString dateFormat () const
QString dateFormatShort () const
bool dateMonthNamePossessive () const
DigitSet dateTimeDigitSet () const
QString decimalSymbol () const
DigitSet digitSet () const
QString digitSetToName (DigitSet digitSet, bool withDigits=false) const
const QByteArray encoding () const
int encodingMib () const
int fileEncodingMib () const
QString formatByteSize (double size) const
QString formatDate (const QDate &date, DateFormat format=LongDate) const
QString formatDateTime (const KDateTime &dateTime, DateFormat format=ShortDate, DateTimeFormatOptions options=0) const
QString formatDateTime (const QDateTime &dateTime, DateFormat format=ShortDate, bool includeSecs=false) const
QString formatDuration (unsigned long mSec) const
QString formatLong (long num) const
QString formatMoney (double num, const QString &currency=QString(), int digits=-1) const
QString formatNumber (const QString &numStr, bool round=true, int precision=2) const
QString formatNumber (double num, int precision=-1) const
QString formatTime (const QTime &pTime, bool includeSecs=false, bool isDuration=false) const
int fracDigits () const
void insertCatalog (const QString &catalog)
bool isApplicationTranslatedInto (const QString &language)
 KLocale (const KLocale &rhs)
 KLocale (const QString &catalog, const QString &language, const QString &country=QString(), KConfig *config=0)
 KLocale (const QString &catalog, KSharedConfig::Ptr config=KSharedConfig::Ptr())
QString language () const
QString languageCodeToName (const QString &language) const
QStringList languageList () const
QString localizedFilePath (const QString &filePath) const
MeasureSystem measureSystem () const
QString monetaryDecimalSymbol () const
DigitSet monetaryDigitSet () const
QString monetaryThousandsSeparator () const
SignPosition negativeMonetarySignPosition () const
bool negativePrefixCurrencySymbol () const
QString negativeSign () const
bool nounDeclension () const
KLocale & operator= (const KLocale &rhs)
int pageSize () const
SignPosition positiveMonetarySignPosition () const
bool positivePrefixCurrencySymbol () const
QString positiveSign () const
QString prettyFormatDuration (unsigned long mSec) const
QDate readDate (const QString &str, ReadDateFlags flags, bool *ok=0) const
QDate readDate (const QString &intstr, const QString &fmt, bool *ok=0) const
QDate readDate (const QString &str, bool *ok=0) const
double readMoney (const QString &numStr, bool *ok=0) const
double readNumber (const QString &numStr, bool *ok=0) const
QTime readTime (const QString &str, ReadTimeFlags flags, bool *ok=0) const
QTime readTime (const QString &str, bool *ok=0) const
QString removeAcceleratorMarker (const QString &label) const
void removeCatalog (const QString &catalog)
void setActiveCatalog (const QString &catalog)
void setCalendar (const QString &calendarType)
bool setCountry (const QString &country, KConfig *config)
void setCurrencySymbol (const QString &symbol)
void setDateFormat (const QString &format)
void setDateFormatShort (const QString &format)
void setDateMonthNamePossessive (bool possessive)
void setDateTimeDigitSet (DigitSet digitSet)
void setDecimalSymbol (const QString &symbol)
void setDigitSet (DigitSet digitSet)
bool setEncoding (int mibEnum)
void setFracDigits (int digits)
bool setLanguage (const QStringList &languages)
bool setLanguage (const QString &language, KConfig *config)
void setMeasureSystem (MeasureSystem value)
void setMonetaryDecimalSymbol (const QString &symbol)
void setMonetaryDigitSet (DigitSet digitSet)
void setMonetaryThousandsSeparator (const QString &separator)
void setNegativeMonetarySignPosition (SignPosition signpos)
void setNegativePrefixCurrencySymbol (bool prefix)
void setNegativeSign (const QString &sign)
void setPageSize (int paperFormat)
void setPositiveMonetarySignPosition (SignPosition signpos)
void setPositivePrefixCurrencySymbol (bool prefix)
void setPositiveSign (const QString &sign)
void setThousandsSeparator (const QString &separator)
void setTimeFormat (const QString &format)
void setWeekDayOfPray (int day)
void setWeekStartDay (int day)
void setWorkingWeekEndDay (int day)
void setWorkingWeekStartDay (int day)
QString thousandsSeparator () const
QString timeFormat () const
QString translateQt (const char *context, const char *sourceText, const char *comment) const
void translateRaw (const char *ctxt, const char *singular, const char *plural, unsigned long n, QString *lang, QString *trans) const
void translateRaw (const char *singular, const char *plural, unsigned long n, QString *lang, QString *trans) const
void translateRaw (const char *ctxt, const char *msg, QString *lang, QString *trans) const
void translateRaw (const char *msg, QString *lang, QString *trans) const
bool use12Clock () const
bool useTranscript () const
int weekDayOfPray () const
int weekStartDay () const
int workingWeekEndDay () const
int workingWeekStartDay () const
virtual ~KLocale ()

Static Public Member Functions

static QString defaultCountry ()
static QString defaultLanguage ()
static QString langLookup (const QString &fname, const char *rtype="html")
static void setMainCatalog (const char *catalog)
static void splitLocale (const QString &locale, QString &language, QString &country, QString &modifier, QString &charset)

Detailed Description

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 <coolo@kde.org>, Preston Brown <pbrown@kde.org>, Hans Petter Bieker <bieker@kde.org>, Lukas Tinkl <lukas.tinkl@suse.cz> class for supporting locale settings and national language

Definition at line 68 of file klocale.h.


Member Enumeration Documentation

enum KLocale::DateFormat

Format for date string.

Enumerator:
ShortDate 

Short (numeric) date format, e.g.

08-04-2007

LongDate 

Long (text) date format, e.g.

Sunday 08 April 2007

FancyShortDate 

Same as ShortDate for dates a week or more ago.

For more recent dates, it is represented as Today, Yesterday, or the weekday name.

FancyLongDate 

Same as LongDate for dates a week or more ago.

For more recent dates, it is represented as Today, Yesterday, or the weekday name.

Definition at line 523 of file klocale.h.

enum KLocale::DateTimeFormatOption

Options for formatting date-time values.

Enumerator:
TimeZone 

Include a time zone string.

Seconds 

Include the seconds value.

Definition at line 562 of file klocale.h.

enum KLocale::DigitSet
Since:
4.3

The set of digit characters used to display and enter numbers.

Enumerator:
ArabicDigits 

0123456789 (European and some Asian languages and western Arabic dialects)

ArabicIndicDigits 

٠١٢٣٤٥٦٧٨٩ (eastern Arabic dialects).

EasternArabicIndicDigits 

۰۱۲۳۴۵۶۷۸۹ (Persian and Urdu).

DevenagariDigits 

०१२३४५६७८९ (Hindi)

Definition at line 252 of file klocale.h.

enum KLocale::MeasureSystem

The Metric system will give you information in mm, while the Imperial system will give you information in inches.

Enumerator:
Metric 

Metric system (used e.g. in Europe).

Imperial 

Imperial system (used e.g. in the United States).

Definition at line 1105 of file klocale.h.

enum KLocale::ReadDateFlags

Flags for readDate().

Enumerator:
NormalFormat 

Only accept a date string in normal (long) format.

ShortFormat 

Only accept a date string in short format.

Definition at line 720 of file klocale.h.

enum KLocale::ReadTimeFlags

Flags for readTime().

Enumerator:
WithSeconds 

Only accept a time string with seconds. Default (no flag set).

WithoutSeconds 

Only accept a time string without seconds.

Definition at line 756 of file klocale.h.

enum KLocale::SignPosition

Various positions for where to place the positive or negative sign when they are related to a monetary value.

Enumerator:
ParensAround 

Put parantheses around the quantity, e.g.

"$ (217)"

BeforeQuantityMoney 

Prefix the quantity with the sign, e.g.

"$ -217"

AfterQuantityMoney 

Suffix the quanitity with the sign, e.g.

"$ 217-"

BeforeMoney 

Prefix the currency symbol with the sign, e.g.

"-$ 217"

AfterMoney 

Suffix the currency symbol with the sign, e.g.

"$- 217"

Definition at line 224 of file klocale.h.


Constructor & Destructor Documentation

KLocale::KLocale ( const QString &  catalog,
KSharedConfig::Ptr  config = KSharedConfig::Ptr() 
) [explicit]

Constructs a KLocale with the given catalog name.

The constructor looks for an entry Language in the group Locale in the configuration file.

If no configuration 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.

Parameters:
catalog the name of the main language file
config a configuration file with a Locale group detailing locale-related preferences (such as language and formatting options)

Definition at line 300 of file klocale.cpp.

KLocale::KLocale ( const QString &  catalog,
const QString &  language,
const QString &  country = QString(),
KConfig *  config = 0 
)

Constructs a KLocale with the given catalog name.

Allows you to override the language and, optionally, the country of this locale.

Parameters:
catalog the name of the main language file
language the language for the locale
country the country for the locale
config a configuration file with a Locale group detailing locale-related preferences (such as date and time formatting options)

Definition at line 305 of file klocale.cpp.

KLocale::KLocale ( const KLocale &  rhs  ) 

Copy constructor.

Definition at line 2565 of file klocale.cpp.

KLocale::~KLocale (  )  [virtual]

Destructor.

Definition at line 759 of file klocale.cpp.


Member Function Documentation

QStringList KLocale::allCountriesList (  )  const

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

Definition at line 2517 of file klocale.cpp.

QList< KLocale::DigitSet > KLocale::allDigitSetsList (  )  const
Since:
4.3

Provides list of all known digit set identifiers.

Returns:
list of all digit set identifiers
See also:
DigitSet
digitSetToName

Definition at line 929 of file klocale.cpp.

QStringList KLocale::allLanguagesList (  )  const

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

Definition at line 2500 of file klocale.cpp.

const KCalendarSystem * KLocale::calendar (  )  const

Returns a pointer to the calendar system object.

Returns:
the current calendar system instance

Definition at line 2556 of file klocale.cpp.

QString KLocale::calendarType (  )  const

Returns the name of the calendar system that is currently being used by the system.

Returns:
the name of the calendar system

Definition at line 2551 of file klocale.cpp.

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 2481 of file klocale.cpp.

QString KLocale::convertDigits ( const QString &  str,
DigitSet  digitSet,
bool  ignoreContext = false 
) const
Since:
4.3

Convert all digits in the string to the given digit set.

Conversion is normally not performed if the given digit set is not appropriate in the current locale and language context. Unconditional conversion may be requested by setting ignoreContext to true.

Parameters:
str the string to convert
digitSet the digit set identifier
ignoreContext unconditional conversion if true
Returns:
string with converted digits
See also:
DigitSet

Definition at line 980 of file klocale.cpp.

void KLocale::copyCatalogsTo ( KLocale *  locale  ) 

Copies the catalogs of this object to an other KLocale object.

Parameters:
locale the destination KLocale object

Definition at line 2581 of file klocale.cpp.

QString KLocale::country (  )  const

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

Definition at line 680 of file klocale.cpp.

QString KLocale::countryCodeToName ( const QString &  country  )  const

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.

Parameters:
country the country code
Returns:
the human readable and localized form of the country name
See also:
country
allCountriesList

Definition at line 2531 of file klocale.cpp.

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 1061 of file klocale.cpp.

QString KLocale::dateFormat (  )  const

Returns the currently selected date format.

Returns:
Current date format.
See also:
setDateFormat()

Definition at line 2339 of file klocale.cpp.

QString KLocale::dateFormatShort (  )  const

Returns the currently selected short date format.

Returns:
Current short date format.
See also:
setDateFormatShort()

Definition at line 2344 of file klocale.cpp.

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

Definition at line 1025 of file klocale.cpp.

KLocale::DigitSet KLocale::dateTimeDigitSet (  )  const
Since:
4.3

Returns the identifier of the digit set used to display dates and time.

Returns:
the digit set identifier
See also:
DigitSet
digitSetToName

Definition at line 2651 of file klocale.cpp.

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 1051 of file klocale.cpp.

QString KLocale::defaultCountry (  )  [static]

Returns the name of the default country.

Returns:
Name of the default country

Definition at line 2442 of file klocale.cpp.

QString KLocale::defaultLanguage (  )  [static]

Returns the name of the internal language.

Returns:
Name of the default language

Definition at line 2437 of file klocale.cpp.

KLocale::DigitSet KLocale::digitSet (  )  const
Since:
4.3

Returns the identifier of the digit set used to display numbers.

Returns:
the digit set identifier
See also:
DigitSet
digitSetToName

Definition at line 2631 of file klocale.cpp.

QString KLocale::digitSetToName ( DigitSet  digitSet,
bool  withDigits = false 
) const
Since:
4.3

Convert a digit set identifier to a human readable, localized name.

Parameters:
digitSet the digit set identifier
withDigits whether to add the digits themselves to the name
Returns:
the human readable and localized name of the digit set
See also:
DigitSet

Definition at line 953 of file klocale.cpp.

const QByteArray KLocale::encoding (  )  const

Returns the user's preferred encoding.

Returns:
The name of the preferred encoding
See also:
codecForEncoding
encodingMib

Definition at line 2452 of file klocale.cpp.

int KLocale::encodingMib (  )  const

Returns the user's preferred encoding.

Returns:
The Mib of the preferred encoding
See also:
encoding
codecForEncoding

Definition at line 2469 of file klocale.cpp.

int KLocale::fileEncodingMib (  )  const

Returns the file encoding.

Returns:
The Mib of the file encoding
See also:
QFile::encodeName
QFile::decodeName

Definition at line 2474 of file klocale.cpp.

QString KLocale::formatByteSize ( double  size  )  const

Converts size from bytes to the string representation using the IEC 60027-2 standard.

Example: formatByteSize(1024) returns "1.0 KiB"

Parameters:
size size in bytes
Returns:
converted size as a string - e.g. 123.4 KiB , 12.0 MiB

Definition at line 1360 of file klocale.cpp.

QString KLocale::formatDate ( const QDate &  date,
DateFormat  format = LongDate 
) const

Returns a string formatted to the current locale's conventions regarding dates.

Parameters:
date the date to be formatted
format category of date format to use
Returns:
the date as a string

Definition at line 1478 of file klocale.cpp.

QString KLocale::formatDateTime ( const KDateTime &  dateTime,
DateFormat  format = ShortDate,
DateTimeFormatOptions  options = 0 
) const

Returns a string formatted to the current locale's conventions regarding both date and time.

Parameters:
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

Definition at line 2156 of file klocale.cpp.

QString KLocale::formatDateTime ( const QDateTime &  dateTime,
DateFormat  format = ShortDate,
bool  includeSecs = false 
) const

Returns a string formatted to the current locale's conventions regarding both date and time.

Parameters:
dateTime the date and time to be formatted
format category of date format to use
includeSecs if true, the string will include the seconds part of the time; otherwise, the seconds will be omitted
Returns:
the date and time as a string

Definition at line 2138 of file klocale.cpp.

QString KLocale::formatDuration ( unsigned long  mSec  )  const

Given a number of milliseconds, converts that to a string containing the localized equivalent.

e.g. given formatDuration(60000), returns "1.0 minutes"

Parameters:
mSec Time duration in milliseconds
Returns:
converted duration as a string - e.g. "5.5 seconds" "23.0 minutes"

Definition at line 1411 of file klocale.cpp.

QString KLocale::formatLong ( long  num  )  const

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).

Parameters:
num The number to convert
Returns:
The number as a localized string

Definition at line 1206 of file klocale.cpp.

QString KLocale::formatMoney ( double  num,
const QString &  currency = QString(),
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 1134 of file klocale.cpp.

QString KLocale::formatNumber ( const QString &  numStr,
bool  round = true,
int  precision = 2 
) const

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).

Parameters:
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

Definition at line 1307 of file klocale.cpp.

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.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.

Parameters:
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)

Definition at line 1199 of file klocale.cpp.

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

Returns a string formatted to the current locale's conventions regarding times.

Parameters:
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

Definition at line 2022 of file klocale.cpp.

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 1086 of file klocale.cpp.

void KLocale::insertCatalog ( const QString &  catalog  ) 

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.

Parameters:
catalog The catalog to add.

Definition at line 685 of file klocale.cpp.

bool KLocale::isApplicationTranslatedInto ( const QString &  language  ) 

Checks whether or not the active catalog is found for the given language.

Parameters:
language language to check

Definition at line 601 of file klocale.cpp.

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

Finds localized resource in resourceDir( rtype ) + <lang> + fname.

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().

Parameters:
fname relative path to find
rtype resource type to use
Returns:
path to localized resource
See also:
localizedFilePath

Definition at line 2201 of file klocale.cpp.

QString KLocale::language (  )  const

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

Definition at line 675 of file klocale.cpp.

QString KLocale::languageCodeToName ( const QString &  language  )  const

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.

Parameters:
language the language code
Returns:
the human readable and localized form if the code is known, empty otherwise
See also:
language
languageList
allLanguagesList

Definition at line 2508 of file klocale.cpp.

QStringList KLocale::languageList (  )  const

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

Definition at line 2123 of file klocale.cpp.

QString KLocale::localizedFilePath ( const QString &  filePath  )  const
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).

Parameters:
filePath path to the original file
Returns:
path to the localized file if found, original path otherwise

Definition at line 2588 of file klocale.cpp.

KLocale::MeasureSystem KLocale::measureSystem (  )  const

Returns which measuring system we use.

Returns:
The preferred measuring system

Definition at line 2427 of file klocale.cpp.

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 1066 of file klocale.cpp.

KLocale::DigitSet KLocale::monetaryDigitSet (  )  const
Since:
4.3

Retuns the digit set used to display monetary values.

Returns:
the digit set identifier
See also:
DigitSet
digitSetToName

Definition at line 2641 of file klocale.cpp.

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 1071 of file klocale.cpp.

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 1106 of file klocale.cpp.

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 1096 of file klocale.cpp.

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 1081 of file klocale.cpp.

bool KLocale::nounDeclension (  )  const
Deprecated:

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

Definition at line 1020 of file klocale.cpp.

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

Assignment operator.

Definition at line 2571 of file klocale.cpp.

int KLocale::pageSize (  )  const

Returns the preferred page size for printing.

Returns:
The preferred page size, cast it to QPrinter::PageSize

Definition at line 2416 of file klocale.cpp.

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 1101 of file klocale.cpp.

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 1091 of file klocale.cpp.

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 1076 of file klocale.cpp.

QString KLocale::prettyFormatDuration ( unsigned long  mSec  )  const

Given a number of milliseconds, converts that to a pretty string containing the localized equivalent.

e.g. given prettyFormatDuration(60001) returns "1 minute" given prettyFormatDuration(62005) returns "1 minute and 2 seconds" given prettyFormatDuration(90060000) returns "1 day and 1 hour"

Parameters:
mSec Time duration in milliseconds
Returns:
converted duration as a string. Units not interesting to the user, for example seconds or minutes when the first unit is day, are not returned because they are irrelevant. The same applies for seconds when the first unit is hour.
Since:
4.2

Definition at line 1444 of file klocale.cpp.

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

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.

Parameters:
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

Definition at line 1771 of file klocale.cpp.

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 1777 of file klocale.cpp.

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 1763 of file klocale.cpp.

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 1647 of file klocale.cpp.

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 1580 of file klocale.cpp.

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

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.

Parameters:
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

Definition at line 1923 of file klocale.cpp.

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

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.

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 1915 of file klocale.cpp.

QString KLocale::removeAcceleratorMarker ( const QString &  label  )  const
Since:
4.2

Removes accelerator marker from a UI text label.

Accelerator marker is not always a plain ampersand (&), so it is not enough to just remove it by QString::remove(). The label may contain escaped markers ("&&") which must be resolved and skipped, as well as CJK-style markers ("Foo (&F)") where the whole parenthesis construct should be removed. Therefore always use this function to remove accelerator marker from UI labels.

Parameters:
label UI label which may contain an accelerator marker
Returns:
label without the accelerator marker

Definition at line 2621 of file klocale.cpp.

void KLocale::removeCatalog ( const QString &  catalog  ) 

Removes a catalog for translation lookup.

Parameters:
catalog The catalog to remove.
See also:
insertCatalog()

Definition at line 736 of file klocale.cpp.

void KLocale::setActiveCatalog ( const QString &  catalog  ) 

Sets the active catalog for translation lookup.

Parameters:
catalog The catalog to activate.

Definition at line 749 of file klocale.cpp.

void KLocale::setCalendar ( const QString &  calendarType  ) 

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.

Parameters:
calendarType the name of the calendar type

Definition at line 2543 of file klocale.cpp.

bool KLocale::setCountry ( const QString &  country,
KConfig *  config 
)

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
config a configuration file with a Locale group detailing locale-related preferences (such as date and time formatting)
Returns:
true on success, false on failure

Definition at line 523 of file klocale.cpp.

void KLocale::setCurrencySymbol ( const QString &  symbol  ) 

Changes the current currency symbol.

Parameters:
symbol The new currency symbol

Definition at line 2411 of file klocale.cpp.

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 whole year (e.g. "2004" for "2004")
  • y with the lower 2 digits of the year (e.g. "04" for "2004")
  • 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)
  • B with the long form of the month (e.g. "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 2295 of file klocale.cpp.

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 whole year (e.g. "1984" 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)
  • B with the long form of the month (e.g. "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 2300 of file klocale.cpp.

void KLocale::setDateMonthNamePossessive ( bool  possessive  ) 

Changes the form of month name used in dates.

Parameters:
possessive True if possessive forms should be used

Definition at line 2305 of file klocale.cpp.

void KLocale::setDateTimeDigitSet ( DigitSet  digitSet  ) 
Since:
4.3

Set digit characters used to display dates and time.

Parameters:
digitSet the digit set identifier
See also:
DigitSet

Definition at line 2646 of file klocale.cpp.

void KLocale::setDecimalSymbol ( const QString &  symbol  ) 

Changes the symbol used to identify the decimal pointer.

Parameters:
symbol The new decimal symbol.

Definition at line 2354 of file klocale.cpp.

void KLocale::setDigitSet ( DigitSet  digitSet  ) 
Since:
4.3

Changes the set of digit characters used to display numbers.

Parameters:
digitSet the digit set identifier
See also:
DigitSet

Definition at line 2626 of file klocale.cpp.

bool KLocale::setEncoding ( int  mibEnum  ) 

Changes the current encoding.

Parameters:
mibEnum The mib of the preferred codec
Returns:
True on success.

Definition at line 2486 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 2395 of file klocale.cpp.

bool KLocale::setLanguage ( const QStringList &  languages  ) 

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.

Parameters:
languages the list of language codes
Returns:
true if one of the specified languages were used

Definition at line 558 of file klocale.cpp.

bool KLocale::setLanguage ( const QString &  language,
KConfig *  config 
)

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
config a configuration file with a Locale group detailing locale-related preferences (such as date and time formatting)
Returns:
true on success

Definition at line 536 of file klocale.cpp.

void KLocale::setMainCatalog ( const char *  catalog  )  [static]

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.

Parameters:
catalog Catalog to override all other main Catalogs.

Definition at line 1574 of file klocale.cpp.

void KLocale::setMeasureSystem ( MeasureSystem  value  ) 

Changes the preferred measuring system.

Returns:
value The preferred measuring system

Definition at line 2432 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 2406 of file klocale.cpp.

void KLocale::setMonetaryDigitSet ( DigitSet  digitSet  ) 
Since:
4.3

Set digit characters used to display monetary values.

Parameters:
digitSet the digit set identifier
See also:
DigitSet

Definition at line 2636 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 2400 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 2380 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 2390 of file klocale.cpp.

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 2370 of file klocale.cpp.

void KLocale::setPageSize ( int  paperFormat  ) 

Changes the preferred page size when printing.

Parameters:
paperFormat the new preferred page size in the format QPrinter::PageSize

Definition at line 2421 of file klocale.cpp.

void KLocale::setPositiveMonetarySignPosition ( SignPosition  signpos  ) 

Changes the sign position used for positive monetary values.

Parameters:
signpos The new sign position

Definition at line 2375 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 2385 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 2365 of file klocale.cpp.

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 2359 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 2310 of file klocale.cpp.

void KLocale::setWeekDayOfPray ( int  day  ) 

Changes how KLocale defines the day reserved for religious observance.

Since:
4.2
Parameters:
day day of the week for religious observance (None=0,Monday=1..Sunday=7) as integer

Definition at line 2333 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

Definition at line 2315 of file klocale.cpp.

void KLocale::setWorkingWeekEndDay ( int  day  ) 

Changes how KLocale defines the last working day in week.

Since:
4.2
Parameters:
day last working day of the week (Monday=1..Sunday=7) as integer

Definition at line 2327 of file klocale.cpp.

void KLocale::setWorkingWeekStartDay ( int  day  ) 

Changes how KLocale defines the first working day in week.

Since:
4.2
Parameters:
day first working day of the week (Monday=1..Sunday=7) as integer

Definition at line 2321 of file klocale.cpp.

void KLocale::splitLocale ( const QString &  locale,
QString &  language,
QString &  country,
QString &  modifier,
QString &  charset 
) [static]

Parses locale string into distinct parts.

The format of locale is language_COUNTRY@modifier.CHARSET

Parameters:
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

Definition at line 634 of file klocale.cpp.

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 1056 of file klocale.cpp.

QString KLocale::timeFormat (  )  const

Returns the currently selected time format.

Returns:
Current time format.
See also:
setTimeFormat()

Definition at line 2349 of file klocale.cpp.

QString KLocale::translateQt ( const char *  context,
const char *  sourceText,
const char *  comment 
) 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())

Definition at line 866 of file klocale.cpp.

void KLocale::translateRaw ( const char *  ctxt,
const char *  singular,
const char *  plural,
unsigned long  n,
QString *  lang,
QString *  trans 
) const

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.

Parameters:
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

Definition at line 859 of file klocale.cpp.

void KLocale::translateRaw ( const char *  singular,
const char *  plural,
unsigned long  n,
QString *  lang,
QString *  trans 
) const

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.

Parameters:
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

Definition at line 853 of file klocale.cpp.

void KLocale::translateRaw ( const char *  ctxt,
const char *  msg,
QString *  lang,
QString *  trans 
) const

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.

Parameters:
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

Definition at line 847 of file klocale.cpp.

void KLocale::translateRaw ( const char *  msg,
QString *  lang,
QString *  trans 
) const

Raw translation from message catalogs.

Never use this directly to get message translations. See the i18n and ki18n family of calls related to KLocalizedString.

Parameters:
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

Definition at line 841 of file klocale.cpp.

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 2114 of file klocale.cpp.

bool KLocale::useTranscript (  )  const

Reports whether evaluation of translation scripts is enabled.

Returns:
true if script evaluation is enabled, false otherwise.

Definition at line 2447 of file klocale.cpp.

int KLocale::weekDayOfPray (  )  const

Use this to determine which day is reserved for religious observance.

Since:
4.2
Returns:
day number (None = 0, Monday = 1, ..., Sunday = 7)

Definition at line 1045 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)

Definition at line 1030 of file klocale.cpp.

int KLocale::workingWeekEndDay (  )  const

Use this to determine which day is the last working day of the week.

Since:
4.2
Returns:
an integer (Monday=1..Sunday=7)

Definition at line 1040 of file klocale.cpp.

int KLocale::workingWeekStartDay (  )  const

Use this to determine which day is the first working day of the week.

Since:
4.2
Returns:
an integer (Monday=1..Sunday=7)

Definition at line 1035 of file klocale.cpp.


The documentation for this class was generated from the following files:
  • klocale.h
  • klocale.cpp

KDECore

Skip menu "KDECore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdelibs

Skip menu "kdelibs"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • Kate
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  •   WTF
  • kjsembed
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUtils
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver
Generated for kdelibs by doxygen 1.6.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal