KLocale Class Reference
from PyKDE4.kdecore import *
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));
Hans Petter Bieker <bieker@kde.org>, Lukas Tinkl <lukas.tinkl@suse.cz> class for supporting locale settings and national language
Enumerations | |
BinarySizeUnits | { DefaultBinaryUnits, UnitByte, UnitKiloByte, UnitMegaByte, UnitGigaByte, UnitTeraByte, UnitPetaByte, UnitExaByte, UnitZettaByte, UnitYottaByte, UnitLastUnit } |
BinaryUnitDialect | { DefaultBinaryDialect, IECBinaryDialect, JEDECBinaryDialect, MetricBinaryDialect, LastBinaryDialect } |
CalendarSystem | { QDateCalendar, CopticCalendar, EthiopianCalendar, GregorianCalendar, HebrewCalendar, IslamicCivilCalendar, IndianNationalCalendar, JalaliCalendar, JapaneseCalendar, JulianCalendar, MinguoCalendar, ThaiCalendar } |
DateFormat | { ShortDate, LongDate, FancyShortDate, FancyLongDate, IsoDate, IsoWeekDate, IsoOrdinalDate } |
DateTimeComponent | { Year, YearName, Month, MonthName, Day, DayName, JulianDay, EraName, EraYear, YearInEra, DayOfYear, DayOfYearName, DayOfWeek, DayOfWeekName, Week, WeekYear, MonthsInYear, WeeksInYear, DaysInYear, DaysInMonth, DaysInWeek, Hour, Minute, Second, Millisecond, DayPeriod, DayPeriodHour, Timezone, TimezoneName, UnixTime } |
DateTimeComponentFormat | { DefaultComponentFormat, ShortNumber, LongNumber, NarrowName, ShortName, LongName } |
DateTimeFormatOption | { TimeZone, Seconds } |
DateTimeFormatStandard | { KdeFormat, PosixFormat, UnicodeFormat } |
DateTimeParseMode | { LiberalParsing } |
DigitSet | { ArabicDigits, ArabicIndicDigits, EasternArabicIndicDigits, DevenagariDigits, BengaliDigits, GujaratiDigits, GurmukhiDigits, KannadaDigits, KhmerDigits, MalayalamDigits, OriyaDigits, TamilDigits, TeluguDigits, ThaiDigits } |
MeasureSystem | { Metric, Imperial } |
ReadDateFlags | { NormalFormat, ShortFormat, IsoFormat, IsoWeekFormat, IsoOrdinalFormat } |
ReadTimeFlags | { WithSeconds, WithoutSeconds } |
SignPosition | { ParensAround, BeforeQuantityMoney, AfterQuantityMoney, BeforeMoney, AfterMoney } |
TimeFormatOption | { TimeDefault, TimeWithoutSeconds, TimeWithoutAmPm, TimeDuration, TimeFoldHours } |
TimeProcessingOption | { ProcessStrict, ProcessNonStrict } |
WeekNumberSystem | { DefaultWeekNumber, IsoWeekNumber, FirstFullWeek, FirstPartialWeek, SimpleWeek } |
Methods | |
__init__ (self, QString catalog, KSharedPtr | |
__init__ (self, QString catalog, QString language, QString country=QString(), KConfig config=0) | |
QStringList | allCountriesList (self) |
[KLocale.DigitSet] | allDigitSetsList (self) |
QStringList | allLanguagesList (self) |
KLocale.BinaryUnitDialect | binaryUnitDialect (self) |
KCalendarSystem | calendar (self) |
KLocale.CalendarSystem | calendarSystem (self) |
QString | calendarType (self) |
QTextCodec | codecForEncoding (self) |
QString | convertDigits (self, QString str, KLocale.DigitSet digitSet, bool ignoreContext=0) |
copyCatalogsTo (self, KLocale locale) | |
QString | country (self) |
QString | countryCodeToName (self, QString country) |
QString | countryDivisionCode (self) |
KCurrencyCode | currency (self) |
QString | currencyCode (self) |
QStringList | currencyCodeList (self) |
QString | currencySymbol (self) |
QString | dateFormat (self) |
QString | dateFormatShort (self) |
bool | dateMonthNamePossessive (self) |
KLocale.DigitSet | dateTimeDigitSet (self) |
QString | dayPeriodText (self, QTime time, KLocale.DateTimeComponentFormat format=KLocale.DefaultComponentFormat) |
int | decimalPlaces (self) |
QString | decimalSymbol (self) |
KLocale.DigitSet | digitSet (self) |
QString | digitSetToName (self, KLocale.DigitSet digitSet, bool withDigits=0) |
QByteArray | encoding (self) |
int | encodingMib (self) |
int | fileEncodingMib (self) |
QString | formatByteSize (self, float size) |
QString | formatByteSize (self, float size, int precision, KLocale.BinaryUnitDialect dialect=KLocale.DefaultBinaryDialect, KLocale.BinarySizeUnits specificUnit=KLocale.DefaultBinaryUnits) |
QString | formatDate (self, QDate date, KLocale.DateFormat format=KLocale.LongDate) |
QString | formatDateTime (self, QDateTime dateTime, KLocale.DateFormat format=KLocale.ShortDate, bool includeSecs=0) |
QString | formatDateTime (self, KDateTime dateTime, KLocale.DateFormat format=KLocale.ShortDate, KLocale.DateTimeFormatOptions options=0) |
QString | formatDuration (self, long mSec) |
QString | formatLocaleTime (self, QTime pTime, KLocale.TimeFormatOptions options=KLocale.TimeDefault) |
QString | formatLong (self, long num) |
QString | formatMoney (self, float num, QString currency=QString(), int precision=-1) |
QString | formatNumber (self, float num, int precision=-1) |
QString | formatNumber (self, QString numStr, bool round=1, int precision=2) |
QString | formatTime (self, QTime pTime, bool includeSecs=0, bool isDuration=0) |
int | fracDigits (self) |
insertCatalog (self, QString catalog) | |
QStringList | installedLanguages (self) |
bool | isApplicationTranslatedInto (self, QString language) |
QString | language (self) |
QString | languageCodeToName (self, QString language) |
QStringList | languageList (self) |
QString | localizedFilePath (self, QString filePath) |
KLocale.MeasureSystem | measureSystem (self) |
int | monetaryDecimalPlaces (self) |
QString | monetaryDecimalSymbol (self) |
KLocale.DigitSet | monetaryDigitSet (self) |
QString | monetaryThousandsSeparator (self) |
KLocale.SignPosition | negativeMonetarySignPosition (self) |
bool | negativePrefixCurrencySymbol (self) |
QString | negativeSign (self) |
bool | nounDeclension (self) |
int | pageSize (self) |
KLocale.SignPosition | positiveMonetarySignPosition (self) |
bool | positivePrefixCurrencySymbol (self) |
QString | positiveSign (self) |
QString | prettyFormatDuration (self, long mSec) |
QDate, bool ok | readDate (self, QString str) |
QDate, bool ok | readDate (self, QString intstr, QString fmt) |
QDate, bool ok | readDate (self, QString str, KLocale.ReadDateFlags flags) |
QTime | readLocaleTime (self, QString str, bool ok=0, KLocale.TimeFormatOptions options=KLocale.TimeDefault, KLocale.TimeProcessingOptions processing=KLocale.ProcessNonStrict) |
float, bool ok | readMoney (self, QString numStr) |
float, bool ok | readNumber (self, QString numStr) |
QTime, bool ok | readTime (self, QString str) |
QTime, bool ok | readTime (self, QString str, KLocale.ReadTimeFlags flags) |
QString | removeAcceleratorMarker (self, QString label) |
removeCatalog (self, QString catalog) | |
reparseConfiguration (self) | |
setActiveCatalog (self, QString catalog) | |
setBinaryUnitDialect (self, KLocale.BinaryUnitDialect newDialect) | |
setCalendar (self, QString calendarType) | |
setCalendarSystem (self, KLocale.CalendarSystem calendarSystem) | |
bool | setCountry (self, QString country, KConfig config) |
bool | setCountryDivisionCode (self, QString countryDivision) |
setCurrencyCode (self, QString newCurrencyCode) | |
setCurrencySymbol (self, QString symbol) | |
setDateFormat (self, QString format) | |
setDateFormatShort (self, QString format) | |
setDateMonthNamePossessive (self, bool possessive) | |
setDateTimeDigitSet (self, KLocale.DigitSet digitSet) | |
setDecimalPlaces (self, int digits) | |
setDecimalSymbol (self, QString symbol) | |
setDigitSet (self, KLocale.DigitSet digitSet) | |
bool | setEncoding (self, int mibEnum) |
setFracDigits (self, int digits) | |
bool | setLanguage (self, QString language, KConfig config) |
bool | setLanguage (self, QStringList languages) |
setMeasureSystem (self, KLocale.MeasureSystem value) | |
setMonetaryDecimalPlaces (self, int digits) | |
setMonetaryDecimalSymbol (self, QString symbol) | |
setMonetaryDigitSet (self, KLocale.DigitSet digitSet) | |
setMonetaryThousandsSeparator (self, QString separator) | |
setNegativeMonetarySignPosition (self, KLocale.SignPosition signpos) | |
setNegativePrefixCurrencySymbol (self, bool prefix) | |
setNegativeSign (self, QString sign) | |
setPageSize (self, int paperFormat) | |
setPositiveMonetarySignPosition (self, KLocale.SignPosition signpos) | |
setPositivePrefixCurrencySymbol (self, bool prefix) | |
setPositiveSign (self, QString sign) | |
setThousandsSeparator (self, QString separator) | |
setTimeFormat (self, QString format) | |
setWeekDayOfPray (self, int day) | |
setWeekNumberSystem (self, KLocale.WeekNumberSystem weekNumberSystem) | |
setWeekStartDay (self, int day) | |
setWorkingWeekEndDay (self, int day) | |
setWorkingWeekStartDay (self, int day) | |
QString | thousandsSeparator (self) |
QString | timeFormat (self) |
QString | translateQt (self, QString context, QString sourceText, QString comment) |
translateRaw (self, QString msg, QString lang, QString trans) | |
translateRaw (self, QString ctxt, QString msg, QString lang, QString trans) | |
translateRaw (self, QString singular, QString plural, long n, QString lang, QString trans) | |
translateRaw (self, QString ctxt, QString singular, QString plural, long n, QString lang, QString trans) | |
translateRawFrom (self, QString catname, QString msg, QString lang, QString trans) | |
translateRawFrom (self, QString catname, QString ctxt, QString msg, QString lang, QString trans) | |
translateRawFrom (self, QString catname, QString singular, QString plural, long n, QString lang, QString trans) | |
translateRawFrom (self, QString catname, QString ctxt, QString singular, QString plural, long n, QString lang, QString trans) | |
bool | use12Clock (self) |
bool | useTranscript (self) |
int | weekDayOfPray (self) |
KLocale.WeekNumberSystem | weekNumberSystem (self) |
int | weekStartDay (self) |
int | workingWeekEndDay (self) |
int | workingWeekStartDay (self) |
Static Methods | |
QString | defaultCountry () |
QString | defaultCurrencyCode () |
QString | defaultLanguage () |
QString | langLookup (QString fname, QString rtype="html") |
setMainCatalog (QString catalog) | |
splitLocale (QString locale, QString language, QString country, QString modifier, QString charset) |
Method Documentation
__init__ | ( | self, | ||
QString | catalog, | |||
KSharedPtr |
config=KSharedConfig.Ptr() | |||
) |
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. Note that a setLocale() will be performed on the config using the current locale language, which may cause a sync() and reparseConfiguration() which will save any changes you have made and load any changes other shared copies have made.
- 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).
__init__ | ( | self, | ||
QString | catalog, | |||
QString | language, | |||
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.
If you specify a configuration file, a setLocale() will be performed on the config using the current locale language, which may cause a sync() and reparseConfiguration() which will save any changes you have made.
- Parameters:
-
catalog the name of the main language file language the ISO Language Code for the locale, e.g. "en" for English country the ISO Country Code for the locale, e.g. "us" for USA config a configuration file with a Locale group detailing locale-related preferences (such as language and formatting options).
QStringList allCountriesList | ( | self ) |
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
[KLocale.DigitSet] allDigitSetsList | ( | self ) |
- Since:
- 4.3
Provides list of all known digit set identifiers.
- Returns:
- list of all digit set identifiers
- See also:
- DigitSet
- See also:
- digitSetToName
QStringList allLanguagesList | ( | self ) |
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
- See also:
- installedLanguages
KLocale.BinaryUnitDialect binaryUnitDialect | ( | self ) |
Returns the user's configured binary unit dialect. e.g. if MetricBinaryDialect is returned then the values configured for how much a set of bytes are worth would be 10^(3*n) and KB (1000 bytes == 1 KB), in this case.
Will never return DefaultBinaryDialect.
- Since:
- 4.4
- Returns:
- User's configured binary unit dialect
- See also:
- BinaryUnitDialect
KCalendarSystem calendar | ( | self ) |
Returns a pointer to the calendar system object.
- Returns:
- the current calendar system instance
KLocale.CalendarSystem calendarSystem | ( | self ) |
- Since:
- 4.6
Returns the type of Calendar System used in this Locale
- See also:
- KLocale.CalendarSystem
- See also:
- KCalendarSystem
- Returns:
- the type of Calendar System
QString calendarType | ( | self ) |
- Deprecated:
- use calendarSystem() instead
Returns the name of the calendar system that is currently being used by the system.
- See also:
- calendarSystem()
- Returns:
- the name of the calendar system
QTextCodec codecForEncoding | ( | self ) |
Returns the user's preferred encoding. Should never be NULL.
- Returns:
- The codec for the preferred encoding
- See also:
- encoding
- See also:
- encodingMib
QString convertDigits | ( | self, | ||
QString | str, | |||
KLocale.DigitSet | digitSet, | |||
bool | ignoreContext=0 | |||
) |
- 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
copyCatalogsTo | ( | self, | ||
KLocale | locale | |||
) |
Copies the catalogs of this object to an other KLocale object.
- Parameters:
-
locale the destination KLocale object
QString country | ( | self ) |
Returns the country code of the country where the user lives.
The returned code complies with the ISO 3166-1 alpha-2 standard, except by KDE convention it is returned in lowercase whereas the official standard is uppercase. See http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 for details.
defaultCountry() is returned by default, if no other available, this will always be uppercase 'C'.
Use countryCodeToName(country) to get human readable, localized country names.
- Returns:
- the country code for the user
- See also:
- countryCodeToName
QString countryCodeToName | ( | self, | ||
QString | country | |||
) |
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
- See also:
- allCountriesList
QString countryDivisionCode | ( | self ) |
- Since:
- 4.6
Returns the Country Division Code of the Country where the user lives. When no value is set, then the Country Code will be returned.
The returned code complies with the ISO 3166-2 standard. See http://en.wikipedia.org/wiki/ISO_3166-2 for details.
Note that unlike country() this method will return the correct case, i.e. normally uppercase..
In KDE 4.6 it is the apps responsibility to obtain a translation for the code, translation and other services will be priovided in KDE 4.7.
- Returns:
- the Country Division Code for the user
- See also:
- setCountryDivisionCode
KCurrencyCode currency | ( | self ) |
- Since:
- 4.4
Returns the Currency Code object for the current locale
- Returns:
- The default Currency Code object used by locale.
QString currencyCode | ( | self ) |
- Since:
- 4.4
Returns the ISO 4217 Currency Code for the current locale
- Returns:
- The default ISO Currency Code used by locale.
QStringList currencyCodeList | ( | self ) |
- Since:
- 4.4
Returns the ISO Currency Codes used in the locale, ordered by decreasing priority.
Use KCurrency.currencyCodeToName(currencyCode) to get human readable, localized language name.
- Returns:
- list of ISO Currency Codes
- See also:
- currencyCodeToName
QString currencySymbol | ( | self ) |
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.
QString dateFormat | ( | self ) |
Returns the currently selected date format.
- Returns:
- Current date format.
- See also:
- setDateFormat()
QString dateFormatShort | ( | self ) |
Returns the currently selected short date format.
- Returns:
- Current short date format.
- See also:
- setDateFormatShort()
bool dateMonthNamePossessive | ( | self ) |
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
KLocale.DigitSet dateTimeDigitSet | ( | self ) |
- Since:
- 4.3
Returns the identifier of the digit set used to display dates and time.
- Returns:
- the digit set identifier
- See also:
- DigitSet
- See also:
- digitSetToName
QString dayPeriodText | ( | self, | ||
QTime | time, | |||
KLocale.DateTimeComponentFormat | format=KLocale.DefaultComponentFormat | |||
) |
- Since:
- 4.6
Returns the Day Period matching the time given
- Parameters:
-
time the time to return the day period for format the format to return teh day period in
- Returns:
- the Day Period for the given time
int decimalPlaces | ( | self ) |
- Since:
- 4.4
The number of decimal places to include in numeric values (usually 2).
- Returns:
- Default number of numeric decimal places used by locale.
QString decimalSymbol | ( | self ) |
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.
KLocale.DigitSet digitSet | ( | self ) |
- Since:
- 4.3
Returns the identifier of the digit set used to display numbers.
- Returns:
- the digit set identifier
- See also:
- DigitSet
- See also:
- digitSetToName
QString digitSetToName | ( | self, | ||
KLocale.DigitSet | digitSet, | |||
bool | withDigits=0 | |||
) |
- 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
QByteArray encoding | ( | self ) |
Returns the user's preferred encoding.
- Returns:
- The name of the preferred encoding
- See also:
- codecForEncoding
- See also:
- encodingMib
int encodingMib | ( | self ) |
Returns the user's preferred encoding.
- Returns:
- The Mib of the preferred encoding
- See also:
- encoding
- See also:
- codecForEncoding
int fileEncodingMib | ( | self ) |
Returns the file encoding.
- Returns:
- The Mib of the file encoding
- See also:
- QFile.encodeName
- See also:
- QFile.decodeName
QString formatByteSize | ( | self, | ||
float | size | |||
) |
- Since:
- 4.4
Converts size from bytes to the appropriate string representation using the binary unit dialect dialect and the specific units specificUnit.
Example: formatByteSize(1000, unit, KLocale.BinaryUnitKilo) returns: for KLocale.MetricBinaryUnits, "1.0 kB", for KLocale.IECBinaryUnits, "0.9 KiB", for KLocale.JEDECBinaryUnits, "0.9 KB".
- Parameters:
-
size size in bytes precision number of places after the decimal point to use. KDE uses 1 by default so when in doubt use 1. dialect binary unit standard to use. Use DefaultBinaryUnits to use the localized user selection unless you need to use a specific unit type (such as displaying a flash memory size in JEDEC). specificUnit specific unit size to use in result. Use DefaultBinarySize to automatically select a unit that will return a sanely-sized number.
- Returns:
- converted size as a translated string including the units. E.g. "1.23 KiB", "2 GB" (JEDEC), "4.2 kB" (Metric).
- See also:
- BinaryUnitDialect
QString formatByteSize | ( | self, | ||
float | size, | |||
int | precision, | |||
KLocale.BinaryUnitDialect | dialect=KLocale.DefaultBinaryDialect, | |||
KLocale.BinarySizeUnits | specificUnit=KLocale.DefaultBinaryUnits | |||
) |
- Since:
- 4.4
Converts size from bytes to the appropriate string representation using the binary unit dialect dialect and the specific units specificUnit.
Example: formatByteSize(1000, unit, KLocale.BinaryUnitKilo) returns: for KLocale.MetricBinaryUnits, "1.0 kB", for KLocale.IECBinaryUnits, "0.9 KiB", for KLocale.JEDECBinaryUnits, "0.9 KB".
- Parameters:
-
size size in bytes precision number of places after the decimal point to use. KDE uses 1 by default so when in doubt use 1. dialect binary unit standard to use. Use DefaultBinaryUnits to use the localized user selection unless you need to use a specific unit type (such as displaying a flash memory size in JEDEC). specificUnit specific unit size to use in result. Use DefaultBinarySize to automatically select a unit that will return a sanely-sized number.
- Returns:
- converted size as a translated string including the units. E.g. "1.23 KiB", "2 GB" (JEDEC), "4.2 kB" (Metric).
- See also:
- BinaryUnitDialect
QString formatDate | ( | self, | ||
QDate | date, | |||
KLocale.DateFormat | format=KLocale.LongDate | |||
) |
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
QString formatDateTime | ( | self, | ||
QDateTime | dateTime, | |||
KLocale.DateFormat | format=KLocale.ShortDate, | |||
bool | includeSecs=0 | |||
) |
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
QString formatDateTime | ( | self, | ||
KDateTime | dateTime, | |||
KLocale.DateFormat | format=KLocale.ShortDate, | |||
KLocale.DateTimeFormatOptions | options=0 | |||
) |
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
QString formatDuration | ( | self, | ||
long | mSec | |||
) |
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"
QString formatLocaleTime | ( | self, | ||
QTime | pTime, | |||
KLocale.TimeFormatOptions | options=KLocale.TimeDefault | |||
) |
- Since:
- 4.4
Returns a string formatted to the current locale's conventions regarding times.
- Parameters:
-
pTime the time to be formatted options format option to use when formatting the time
- Returns:
- The time as a string
QString formatLong | ( | self, | ||
long | num | |||
) |
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
QString formatMoney | ( | self, | ||
float | num, | |||
QString | currency=QString(), | |||
int | precision=-1 | |||
) |
Given a double, converts that to a numeric string containing the localized monetary equivalent.
e.g. given 123456, return "$ 123,456.00".
If precision isn't specified or is < 0, then the default monetaryDecimalPlaces() is used.
- Parameters:
-
num The number we want to format currency The currency symbol you want. precision Number of decimal places displayed
- Returns:
- The number of money as a localized string
- See also:
- monetaryDecimalPlaces()
QString formatNumber | ( | self, | ||
float | num, | |||
int | precision=-1 | |||
) |
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).
If precision isn't specified or is < 0, then the default decimalPlaces() is used.
- 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.
- Returns:
- The number as a localized string
QString formatNumber | ( | self, | ||
QString | numStr, | |||
bool | round=1, | |||
int | precision=2 | |||
) |
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).
If precision isn't specified or is < 0, then the default decimalPlaces() is used.
- 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.
- Returns:
- The number as a localized string
QString formatTime | ( | self, | ||
QTime | pTime, | |||
bool | includeSecs=0, | |||
bool | isDuration=0 | |||
) |
- Deprecated:
- replaced by formatLocaleTime()
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
int fracDigits | ( | self ) |
- Deprecated:
- use decimalPlaces() or monetaryDecimalPlaces()
The number of fractional digits to include in monetary values (usually 2).
- Returns:
- Default number of fractional digits used by locale.
insertCatalog | ( | self, | ||
QString | catalog | |||
) |
Adds another catalog to search for translation lookup. This function is useful for extern libraries and/or code, that provide their 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.
QStringList installedLanguages | ( | self ) |
- Since:
- 4.6
Provides list of all installed KDE Language Translations.
Use languageCodeToName(language) to get human readable, localized language names.
- Returns:
- list of all installed language codes
- See also:
- languageCodeToName
bool isApplicationTranslatedInto | ( | self, | ||
QString | language | |||
) |
Checks whether or not the active catalog is found for the given language.
- Parameters:
-
language language to check
QString language | ( | self ) |
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
QString languageCodeToName | ( | self, | ||
QString | language | |||
) |
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
- See also:
- languageList
- See also:
- allLanguagesList
- See also:
- installedLanguages
QStringList languageList | ( | self ) |
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
QString localizedFilePath | ( | self, | ||
QString | filePath | |||
) |
- 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
KLocale.MeasureSystem measureSystem | ( | self ) |
Returns which measuring system we use.
- Returns:
- The preferred measuring system
int monetaryDecimalPlaces | ( | self ) |
- Since:
- 4.4
The number of decimal places to include in monetary values (usually 2).
- Returns:
- Default number of monetary decimal places used by locale.
QString monetaryDecimalSymbol | ( | self ) |
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.
KLocale.DigitSet monetaryDigitSet | ( | self ) |
- Since:
- 4.3
Retuns the digit set used to display monetary values.
- Returns:
- the digit set identifier
- See also:
- DigitSet
- See also:
- digitSetToName
QString monetaryThousandsSeparator | ( | self ) |
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.
KLocale.SignPosition negativeMonetarySignPosition | ( | self ) |
Denotes where to place a negative sign in relation to a monetary value.
- Returns:
- Where/how to print the negative sign.
- See also:
- SignPosition
bool negativePrefixCurrencySymbol | ( | self ) |
If and only if the currency symbol precedes a negative value, this will be true.
- Returns:
- True if the currency symbol precedes negative numbers.
QString negativeSign | ( | self ) |
Returns what a negative sign should look like ("-", etc.) according to the current locale or user settings.
- Returns:
- The negative sign used by locale.
bool nounDeclension | ( | self ) |
- 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
int pageSize | ( | self ) |
Returns the preferred page size for printing.
- Returns:
- The preferred page size, cast it to QPrinter.PageSize
KLocale.SignPosition positiveMonetarySignPosition | ( | self ) |
Returns the position of a positive sign in relation to a monetary value.
- Returns:
- Where/how to print the positive sign.
- See also:
- SignPosition
bool positivePrefixCurrencySymbol | ( | self ) |
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.
QString positiveSign | ( | self ) |
Returns what a positive sign should look like ("+", " ", etc.) according to the current locale or user settings.
- Returns:
- The positive sign used by locale.
QString prettyFormatDuration | ( | self, | ||
long | mSec | |||
) |
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
QDate, bool ok readDate | ( | self, | ||
QString | str | |||
) |
Converts a localized date string to a QDate. This method is stricter than readDate(str,&ok): it will only accept a date in a specific format, depending on flags.
- Parameters:
-
str the string we want to convert. flags what format the the date string will be in 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
- See also:
- KCalendarSystem.readDate()
QDate, bool ok readDate | ( | self, | ||
QString | intstr, | |||
QString | fmt | |||
) |
Converts a localized date string to a QDate. This method is stricter than readDate(str,&ok): it will only accept a date in a specific format, depending on flags.
- Parameters:
-
str the string we want to convert. flags what format the the date string will be in 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
- See also:
- KCalendarSystem.readDate()
QDate, bool ok readDate | ( | self, | ||
QString | str, | |||
KLocale.ReadDateFlags | flags | |||
) |
Converts a localized date string to a QDate. This method is stricter than readDate(str,&ok): it will only accept a date in a specific format, depending on flags.
- Parameters:
-
str the string we want to convert. flags what format the the date string will be in 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
- See also:
- KCalendarSystem.readDate()
QTime readLocaleTime | ( | self, | ||
QString | str, | |||
bool | ok=0, | |||
KLocale.TimeFormatOptions | options=KLocale.TimeDefault, | |||
KLocale.TimeProcessingOptions | processing=KLocale.ProcessNonStrict | |||
) |
- Since:
- 4.4
Converts a localized time string to a QTime. This method is stricter than readTime(str, &ok) in that it will either accept a time with seconds or a time without seconds.
- 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. options format option to apply when formatting the time processing if set to ProcessStrict, checking will be strict and the read time string has to have the exact time format specified. If set to ProcessNonStrict processing the time is lax and spaces in the time string can be left out.
- Returns:
- The string converted to a QTime
float, bool ok readMoney | ( | self, | ||
QString | numStr | |||
) |
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
float, bool ok readNumber | ( | self, | ||
QString | numStr | |||
) |
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
QTime, bool ok readTime | ( | self, | ||
QString | str | |||
) |
- Deprecated:
- replaced readLocaleTime()
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
QTime, bool ok readTime | ( | self, | ||
QString | str, | |||
KLocale.ReadTimeFlags | flags | |||
) |
- Deprecated:
- replaced readLocaleTime()
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
QString removeAcceleratorMarker | ( | self, | ||
QString | label | |||
) |
- 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
removeCatalog | ( | self, | ||
QString | catalog | |||
) |
Removes a catalog for translation lookup.
- Parameters:
-
catalog The catalog to remove.
- See also:
- insertCatalog()
reparseConfiguration | ( | self ) |
- Since:
- 4.8
Reparse locale configuration files for the current selected language.
setActiveCatalog | ( | self, | ||
QString | catalog | |||
) |
Sets the active catalog for translation lookup.
- Parameters:
-
catalog The catalog to activate.
setBinaryUnitDialect | ( | self, | ||
KLocale.BinaryUnitDialect | newDialect | |||
) |
Sets newDialect to be the default dialect for this locale (and only this locale). Newly created KLocale objects will continue to default to the user's choice.
- Parameters:
-
newDialect the new dialect to set as default for this locale object.
- Since:
- 4.4
setCalendar | ( | self, | ||
QString | calendarType | |||
) |
- Deprecated:
- use setCalendarSystem() instead
Changes the current calendar system to the calendar specified. If the calendar system specified is not found, gregorian will be used.
- See also:
- setCalendarSystem()
- Parameters:
-
calendarType the name of the calendar type
setCalendarSystem | ( | self, | ||
KLocale.CalendarSystem | calendarSystem | |||
) |
- Since:
- 4.6
Sets the type of Calendar System to use in this Locale
- See also:
- KLocale.CalendarSystem
- See also:
- KCalendarSystem
- Parameters:
-
calendarSystem the Calendar System to use
bool setCountry | ( | self, | ||
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.
An empty country value will set the country to the system default.
If you specify a configuration file, a setLocale() will be performed on the config using the current locale language, which may cause a sync() and reparseConfiguration() which will save any changes you have made.
- Parameters:
-
country the ISO 3166 country code config a configuration file with a Locale group detailing locale-related preferences (such as language and formatting options).
- Returns:
- true on success, false on failure
bool setCountryDivisionCode | ( | self, | ||
QString | countryDivision | |||
) |
- Since:
- 4.6
Sets the Country Division Code of the Country where the user lives.
The code must comply with the ISO 3166-2 standard. See http://en.wikipedia.org/wiki/ISO_3166-2 for details.
In KDE 4.6 it is the apps responsibility to validate the input, full validation and other services will be provided in KDE 4.7.
- Parameters:
-
countryDivision the Country Division Code for the user
- Returns:
- true on success, false on failure
- See also:
- countryDivisionCode
setCurrencyCode | ( | self, | ||
QString | newCurrencyCode | |||
) |
- Since:
- 4.4
Changes the current ISO Currency Code.
- Parameters:
-
newCurrencyCode The new Currency Code
setCurrencySymbol | ( | self, | ||
QString | symbol | |||
) |
Changes the current currency symbol.
This symbol should be consistant with the selected Currency Code
- Parameters:
-
symbol The new currency symbol
- See also:
- currencyCode, KCurrency.currencySymbols
setDateFormat | ( | self, | ||
QString | format | |||
) |
Changes the current date format.
The format of the date is a string which contains variables that will be replaced:
Everything else in the format string will be taken as is. For example, March 20th 1989 with the format "%y:%m:%d" results in "89:03:20".
- Parameters:
-
format The new date format
setDateFormatShort | ( | self, | ||
QString | format | |||
) |
Changes the current short date format.
The format of the date is a string which contains variables that will be replaced:
Everything else in the format string will be taken as is. For example, March 20th 1989 with the format "%y:%m:%d" results in "89:03:20".
- Parameters:
-
format The new short date format
setDateMonthNamePossessive | ( | self, | ||
bool | possessive | |||
) |
Changes the form of month name used in dates.
- Parameters:
-
possessive True if possessive forms should be used
setDateTimeDigitSet | ( | self, | ||
KLocale.DigitSet | digitSet | |||
) |
- Since:
- 4.3
Set digit characters used to display dates and time.
- Parameters:
-
digitSet the digit set identifier
- See also:
- DigitSet
setDecimalPlaces | ( | self, | ||
int | digits | |||
) |
- Since:
- 4.4
Changes the number of decimal places used when formating numbers.
- Parameters:
-
digits The default number of digits to use.
setDecimalSymbol | ( | self, | ||
QString | symbol | |||
) |
Changes the symbol used to identify the decimal pointer.
- Parameters:
-
symbol The new decimal symbol.
setDigitSet | ( | self, | ||
KLocale.DigitSet | digitSet | |||
) |
- Since:
- 4.3
Changes the set of digit characters used to display numbers.
- Parameters:
-
digitSet the digit set identifier
- See also:
- DigitSet
bool setEncoding | ( | self, | ||
int | mibEnum | |||
) |
Changes the current encoding.
- Parameters:
-
mibEnum The mib of the preferred codec
- Returns:
- True on success.
setFracDigits | ( | self, | ||
int | digits | |||
) |
- Deprecated:
- use setDecimalPlaces() or setMonetaryDecimalPlaces()
Changes the number of digits used when formating numbers.
- Parameters:
-
digits The default number of digits to use.
bool setLanguage | ( | self, | ||
QString | language, | |||
KConfig | config | |||
) |
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
bool setLanguage | ( | self, | ||
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
setMeasureSystem | ( | self, | ||
KLocale.MeasureSystem | value | |||
) |
Changes the preferred measuring system.
- Returns:
- value The preferred measuring system
setMonetaryDecimalPlaces | ( | self, | ||
int | digits | |||
) |
- Since:
- 4.4
Changes the number of decimal places used when formating money.
- Parameters:
-
digits The default number of digits to use.
setMonetaryDecimalSymbol | ( | self, | ||
QString | symbol | |||
) |
Changes the symbol used to identify the decimal pointer for monetary values.
- Parameters:
-
symbol The new decimal symbol.
setMonetaryDigitSet | ( | self, | ||
KLocale.DigitSet | digitSet | |||
) |
- Since:
- 4.3
Set digit characters used to display monetary values.
- Parameters:
-
digitSet the digit set identifier
- See also:
- DigitSet
setMonetaryThousandsSeparator | ( | self, | ||
QString | separator | |||
) |
Changes the separator used to group digits when formating monetary values.
- Parameters:
-
separator The new thousands separator.
setNegativeMonetarySignPosition | ( | self, | ||
KLocale.SignPosition | signpos | |||
) |
Changes the sign position used for negative monetary values.
- Parameters:
-
signpos The new sign position
setNegativePrefixCurrencySymbol | ( | self, | ||
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
setNegativeSign | ( | self, | ||
QString | sign | |||
) |
Changes the sign used to identify a negative number.
- Parameters:
-
sign Sign used for negative numbers.
setPageSize | ( | self, | ||
int | paperFormat | |||
) |
Changes the preferred page size when printing.
- Parameters:
-
paperFormat the new preferred page size in the format QPrinter.PageSize
setPositiveMonetarySignPosition | ( | self, | ||
KLocale.SignPosition | signpos | |||
) |
Changes the sign position used for positive monetary values.
- Parameters:
-
signpos The new sign position
setPositivePrefixCurrencySymbol | ( | self, | ||
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
setPositiveSign | ( | self, | ||
QString | sign | |||
) |
Changes the sign used to identify a positive number. Normally this is left blank.
- Parameters:
-
sign Sign used for positive numbers.
setThousandsSeparator | ( | self, | ||
QString | separator | |||
) |
Changes the separator used to group digits when formating numbers.
- Parameters:
-
separator The new thousands separator.
setTimeFormat | ( | self, | ||
QString | format | |||
) |
Changes the current time format.
The format of the time is string a which contains variables that will be replaced:
Everything else in the format string will be taken as is. For example, 5.23pm with the format "%H:%M" results in "17:23".
- Parameters:
-
format The new time format
setWeekDayOfPray | ( | self, | ||
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
setWeekNumberSystem | ( | self, | ||
KLocale.WeekNumberSystem | weekNumberSystem | |||
) |
- Since:
- 4.6
Sets the type of Week Number System to use in this Locale
- See also:
- Klocale.WeekNumberSystem
- See also:
- weekNumberSystem()
- Parameters:
-
weekNumberSystem the Week Number System to use
setWeekStartDay | ( | self, | ||
int | day | |||
) |
Changes how KLocale defines the first day in week.
- Parameters:
-
day first day of the week (Monday=1..Sunday=7) as integer
setWorkingWeekEndDay | ( | self, | ||
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
setWorkingWeekStartDay | ( | self, | ||
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
QString thousandsSeparator | ( | self ) |
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.
QString timeFormat | ( | self ) |
Returns the currently selected time format.
- Returns:
- Current time format.
- See also:
- setTimeFormat()
QString translateQt | ( | self, | ||
QString | context, | |||
QString | sourceText, | |||
QString | comment | |||
) |
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())
translateRaw | ( | self, | ||
QString | msg, | |||
QString | lang, | |||
QString | trans | |||
) |
Like translateRawFrom, with implicit lookup through all loaded catalogs.
- Deprecated:
- Use translateRawFrom with null or empty catalog name.
translateRaw | ( | self, | ||
QString | ctxt, | |||
QString | msg, | |||
QString | lang, | |||
QString | trans | |||
) |
Like translateRawFrom, with implicit lookup through all loaded catalogs.
- Deprecated:
- Use translateRawFrom with null or empty catalog name.
translateRaw | ( | self, | ||
QString | singular, | |||
QString | plural, | |||
long | n, | |||
QString | lang, | |||
QString | trans | |||
) |
Like translateRawFrom, with implicit lookup through all loaded catalogs.
- Deprecated:
- Use translateRawFrom with null or empty catalog name.
translateRaw | ( | self, | ||
QString | ctxt, | |||
QString | singular, | |||
QString | plural, | |||
long | n, | |||
QString | lang, | |||
QString | trans | |||
) |
Like translateRawFrom, with implicit lookup through all loaded catalogs.
- Deprecated:
- Use translateRawFrom with null or empty catalog name.
translateRawFrom | ( | self, | ||
QString | catname, | |||
QString | msg, | |||
QString | lang, | |||
QString | trans | |||
) |
- Since:
- 4.5
Raw translation from a message catalog, with given context and singular/plural form. Context + singular form is used as the lookup key in the catalog. If catalog name is null or empty, all loaded catalogs are searched for the translation.
Never use this directly to get message translations. See i18n* and ki18n* calls related to KLocalizedString.
- Parameters:
-
catname the catalog name. Must be UTF-8 encoded. ctxt the context. Must not be null. Must be UTF-8 encoded. singular the singular form. Must not be null or empty. 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
translateRawFrom | ( | self, | ||
QString | catname, | |||
QString | ctxt, | |||
QString | msg, | |||
QString | lang, | |||
QString | trans | |||
) |
- Since:
- 4.5
Raw translation from a message catalog, with given context and singular/plural form. Context + singular form is used as the lookup key in the catalog. If catalog name is null or empty, all loaded catalogs are searched for the translation.
Never use this directly to get message translations. See i18n* and ki18n* calls related to KLocalizedString.
- Parameters:
-
catname the catalog name. Must be UTF-8 encoded. ctxt the context. Must not be null. Must be UTF-8 encoded. singular the singular form. Must not be null or empty. 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
translateRawFrom | ( | self, | ||
QString | catname, | |||
QString | singular, | |||
QString | plural, | |||
long | n, | |||
QString | lang, | |||
QString | trans | |||
) |
- Since:
- 4.5
Raw translation from a message catalog, with given context and singular/plural form. Context + singular form is used as the lookup key in the catalog. If catalog name is null or empty, all loaded catalogs are searched for the translation.
Never use this directly to get message translations. See i18n* and ki18n* calls related to KLocalizedString.
- Parameters:
-
catname the catalog name. Must be UTF-8 encoded. ctxt the context. Must not be null. Must be UTF-8 encoded. singular the singular form. Must not be null or empty. 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
translateRawFrom | ( | self, | ||
QString | catname, | |||
QString | ctxt, | |||
QString | singular, | |||
QString | plural, | |||
long | n, | |||
QString | lang, | |||
QString | trans | |||
) |
- Since:
- 4.5
Raw translation from a message catalog, with given context and singular/plural form. Context + singular form is used as the lookup key in the catalog. If catalog name is null or empty, all loaded catalogs are searched for the translation.
Never use this directly to get message translations. See i18n* and ki18n* calls related to KLocalizedString.
- Parameters:
-
catname the catalog name. Must be UTF-8 encoded. ctxt the context. Must not be null. Must be UTF-8 encoded. singular the singular form. Must not be null or empty. 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
bool use12Clock | ( | self ) |
Use this to determine if the user wants a 12 hour clock.
- Returns:
- If the user wants 12h clock
bool useTranscript | ( | self ) |
Reports whether evaluation of translation scripts is enabled.
- Returns:
- true if script evaluation is enabled, false otherwise.
int weekDayOfPray | ( | self ) |
Use this to determine which day is reserved for religious observance
- Since:
- 4.2
- Returns:
- day number (None = 0, Monday = 1, ..., Sunday = 7)
KLocale.WeekNumberSystem weekNumberSystem | ( | self ) |
- Since:
- 4.7
Returns the type of Week Number System used in this Locale
- See also:
- Klocale.WeekNumberSystem
- See also:
- setWeekNumberSystem()
- Returns:
- the Week Number System used
int weekStartDay | ( | self ) |
Use this to determine which day is the first day of the week.
- Returns:
- an integer (Monday=1..Sunday=7)
int workingWeekEndDay | ( | self ) |
Use this to determine which day is the last working day of the week.
- Since:
- 4.2
- Returns:
- an integer (Monday=1..Sunday=7)
int workingWeekStartDay | ( | self ) |
Use this to determine which day is the first working day of the week.
- Since:
- 4.2
- Returns:
- an integer (Monday=1..Sunday=7)
Static Method Documentation
QString defaultCountry | ( | ) |
Returns the code of the default country, i.e. "C"
This function will not provide a sensible value to use in your app, please use country() instead.
- See also:
- country
- Returns:
- Name of the default country
QString defaultCurrencyCode | ( | ) |
- Since:
- 4.4
Returns the ISO Code of the default currency.
- Returns:
- ISO Currency Code of the default currency
QString defaultLanguage | ( | ) |
Returns the name of the internal language.
- Returns:
- Name of the default language
QString langLookup | ( | QString | fname, | |
QString | rtype="html" | |||
) |
- 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
setMainCatalog | ( | QString | catalog | |
) |
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.
splitLocale | ( | QString | locale, | |
QString | language, | |||
QString | country, | |||
QString | modifier, | |||
QString | charset | |||
) |
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
Enumeration Documentation
BinarySizeUnits |
These binary units are used in KDE by the formatByteSize() functions.
NOTE: There are several different units standards: 1) SI (i.e. metric), powers-of-10. 2) IEC, powers-of-2, with specific units KiB, MiB, etc. 3) JEDEC, powers-of-2, used for solid state memory sizing which is why you see flash cards labels as e.g. 4GB. These (ab)use the metric units. Although JEDEC only defines KB, MB, GB, if JEDEC is selected all units will be powers-of-2 with metric prefixes for clarity in the event of sizes larger than 1024 GB.
Although 3 different dialects are possible this enum only uses metric names since adding all 3 different names of essentially the same unit would be pointless. Use BinaryUnitDialect to control the exact units returned.
- Since:
- 4.4
- See also:
- binaryUnitDialect
- Enumerator:
-
DefaultBinaryUnits = -1 UnitByte UnitKiloByte UnitMegaByte UnitGigaByte UnitTeraByte UnitPetaByte UnitExaByte UnitZettaByte UnitYottaByte UnitLastUnit = UnitYottaByte
BinaryUnitDialect |
This enum chooses what dialect is used for binary units.
Note: Although JEDEC abuses the metric prefixes and can therefore be confusing, it has been used to describe *memory* sizes for quite some time and programs should therefore use either Default, JEDEC, or IEC 60027-2 for memory sizes.
On the other hand network transmission rates are typically in metric so Default, Metric, or IEC (which is unambiguous) should be chosen.
Normally choosing DefaultBinaryUnits is the best option as that uses the user's selection for units.
- Since:
- 4.4
- See also:
- binaryUnitDialect
- See also:
- setBinaryUnitDialect
- Enumerator:
-
DefaultBinaryDialect = -1 IECBinaryDialect JEDECBinaryDialect MetricBinaryDialect LastBinaryDialect = MetricBinaryDialect
CalendarSystem |
- Since:
- 4.6
Available Calendar Systems
- See also:
- setCalendarSystem()
- See also:
- calendarSystem()
- Enumerator:
-
QDateCalendar = 1 CopticCalendar = 5 EthiopianCalendar = 6 GregorianCalendar = 8 HebrewCalendar = 9 IslamicCivilCalendar = 12 IndianNationalCalendar = 14 JalaliCalendar = 16 JapaneseCalendar = 19 JulianCalendar = 21 MinguoCalendar = 22 ThaiCalendar = 23
DateFormat |
Format for date string.
- Enumerator:
-
ShortDate LongDate FancyShortDate FancyLongDate IsoDate IsoWeekDate IsoOrdinalDate
DateTimeComponent |
- Since:
- 4.6
The various Components that make up a Date / Time In the future the Components may be combined as flags for dynamic generation of Date Formats.
- See also:
- KCalendarSystem
- See also:
- KLocalizedDate
- See also:
- DateTimeComponentFormat
- Enumerator:
-
Year = 0x1 YearName = 0x2 Month = 0x4 MonthName = 0x8 Day = 0x10 DayName = 0x20 JulianDay = 0x40 EraName = 0x80 EraYear = 0x100 YearInEra = 0x200 DayOfYear = 0x400 DayOfYearName = 0x800 DayOfWeek = 0x1000 DayOfWeekName = 0x2000 Week = 0x4000 WeekYear = 0x8000 MonthsInYear = 0x10000 WeeksInYear = 0x20000 DaysInYear = 0x40000 DaysInMonth = 0x80000 DaysInWeek = 0x100000 Hour = 0x200000 Minute = 0x400000 Second = 0x800000 Millisecond = 0x1000000 DayPeriod = 0x2000000 DayPeriodHour = 0x4000000 Timezone = 0x8000000 TimezoneName = 0x10000000 UnixTime = 0x20000000
DateTimeComponentFormat |
- Since:
- 4.6
Format used for individual Date/Time Components when converted to/from a string Largely equivalent to the UNICODE CLDR format width definitions 1..5
- See also:
- DateTimeComponentFormat
- Enumerator:
-
DefaultComponentFormat = -1 ShortNumber = 0 LongNumber NarrowName = 3 ShortName LongName
DateTimeFormatOption |
Options for formatting date-time values.
- Enumerator:
-
TimeZone = 0x01 Seconds = 0x02
DateTimeFormatStandard |
- Since:
- 4.4
Standard used for Date Time Format String
- Enumerator:
-
KdeFormat PosixFormat UnicodeFormat
DateTimeParseMode |
- Since:
- 4.6
Mode to use when parsing a Date Time input string
- Enumerator:
-
LiberalParsing
DigitSet |
- Since:
- 4.3
The set of digit characters used to display and enter numbers.
- Enumerator:
-
ArabicDigits ArabicIndicDigits EasternArabicIndicDigits DevenagariDigits BengaliDigits GujaratiDigits GurmukhiDigits KannadaDigits KhmerDigits MalayalamDigits OriyaDigits TamilDigits TeluguDigits ThaiDigits
MeasureSystem |
The Metric system will give you information in mm, while the Imperial system will give you information in inches.
- Enumerator:
-
Metric Imperial
ReadDateFlags |
Flags for readDate()
- Enumerator:
-
NormalFormat = 1 ShortFormat = 2 IsoFormat = 4 IsoWeekFormat = 8 IsoOrdinalFormat = 16
ReadTimeFlags |
Flags for the old version of readTime()
- Deprecated:
- replaced by TimeFormatOptions
- Enumerator:
-
WithSeconds = 0 WithoutSeconds = 1
SignPosition |
Various positions for where to place the positive or negative sign when they are related to a monetary value.
- Enumerator:
-
ParensAround = 0 BeforeQuantityMoney = 1 AfterQuantityMoney = 2 BeforeMoney = 3 AfterMoney = 4
TimeFormatOption |
- Since:
- 4.4
Format flags for readLocaleTime() and formatLocaleTime()
- Enumerator:
-
TimeDefault = 0x0 TimeWithoutSeconds = 0x1 TimeWithoutAmPm = 0x2 TimeDuration = 0x6 TimeFoldHours = 0xE
TimeProcessingOption |
Additional processing options for readLocaleTime().
@remarks This is currently used as an enum but declared as a flag to be extensible
- Enumerator:
-
ProcessStrict = 0x1 ProcessNonStrict = 0x2
WeekNumberSystem |
- Since:
- 4.6
System used for Week Numbers
- See also:
- setWeekNumberSystem()
- See also:
- weekNumberSystem()
- Enumerator:
-
DefaultWeekNumber = -1 IsoWeekNumber = 0 FirstFullWeek = 1 FirstPartialWeek = 2 SimpleWeek = 3