1
/* This file is part of the KDE libraries
2
Copyright (C) 2012 Giorgos Tsiapaliwkas <terietor@gmail.com>
3
Copyright (C) 2012 Antonis Tsiapaliokas <kok3rs@gmail.com>
5
This library is free software; you can redistribute it and/or
6
modify it under the terms of the GNU Library General Public
7
License as published by the Free Software Foundation; either
8
version 2 of the License, or (at your option) any later version.
10
This library is distributed in the hope that it will be useful,
11
but WITHOUT ANY WARRANTY; without even the implied warranty of
12
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13
Library General Public License for more details.
15
You should have received a copy of the GNU Library General Public License
16
along with this library; see the file COPYING.LIB. If not, write to
17
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18
Boston, MA 02110-1301, USA.
42
* KLocale provides support for country specific stuff like
43
* the national language.
45
* KLocale supports translating, as well as specifying the format
46
* for numbers, currency, time, and date.
48
* Use KGlobal::locale() to get pointer to the global KLocale object,
49
* containing the applications current locale settings.
51
* For example, to format the date May 17, 1995 in the current locale, use:
54
* QString date = KGlobal::locale()->formatDate(QDate(1995,5,17));
57
* @author Stephan Kulow <coolo@kde.org>, Preston Brown <pbrown@kde.org>,
58
* Hans Petter Bieker <bieker@kde.org>, Lukas Tinkl <lukas.tinkl@suse.cz>
59
* @short class for supporting locale settings and national language
61
class Locale : public QObject
66
Q_ENUMS(BinarySizeUnits)
67
Q_ENUMS(BinaryUnitDialect)
68
Q_ENUMS(CalendarSystem)
70
Q_ENUMS(DateTimeComponent)
71
Q_ENUMS(DateTimeComponentFormat)
72
Q_ENUMS(DateTimeFormatOption )
74
Q_ENUMS(MeasureSystem)
75
Q_ENUMS(ReadDateFlags)
77
Q_ENUMS(TimeFormatOption)
78
Q_ENUMS(TimeProcessingOption)
79
Q_ENUMS(WeekNumberSystem)
82
Q_PROPERTY(BinaryUnitDialect binaryUnitDialect READ binaryUnitDialect WRITE setBinaryUnitDialect NOTIFY binaryUnitDialectChanged)
83
Q_PROPERTY(Locale::CalendarSystem calendarSystem READ calendarSystem WRITE setCalendarSystem NOTIFY calendarSystemChanged)
84
Q_PROPERTY(QString country READ country CONSTANT) //read-only
85
Q_PROPERTY(QString countryDivisionCode READ countryDivisionCode WRITE setCountryDivisionCode NOTIFY countryDivisionCodeChanged)
86
Q_PROPERTY(QString currencyCode READ currencyCode WRITE setCurrencyCode NOTIFY currencyCodeChanged)
87
Q_PROPERTY(QString currencySymbol READ currencySymbol WRITE setCurrencySymbol NOTIFY currencySymbolChanged)
88
Q_PROPERTY(QString dateFormat READ dateFormat WRITE setDateFormat NOTIFY dateFormatChanged)
89
Q_PROPERTY(QString dateFormatShort READ dateFormatShort WRITE setDateFormat NOTIFY dateFormatShortChanged)
90
Q_PROPERTY(bool dateMonthNamePossessive READ dateMonthNamePossessive WRITE setDateMonthNamePossessive NOTIFY dateMonthNamePossessiveChanged)
91
Q_PROPERTY(DigitSet dateTimeDigitSet READ dateTimeDigitSet WRITE setDateTimeDigitSet NOTIFY dateTimeDigitSetChanged)
92
Q_PROPERTY(int decimalPlaces READ decimalPlaces WRITE setDecimalPlaces NOTIFY decimalPlacesChanged)
93
Q_PROPERTY(QString decimalSymbol READ decimalSymbol WRITE setDecimalSymbol NOTIFY decimalSymbolChanged)
94
Q_PROPERTY(DigitSet digitSet READ digitSet WRITE setDigitSet NOTIFY digitSetChanged)
95
Q_PROPERTY(QString language READ language CONSTANT) //read-only
96
Q_PROPERTY(MeasureSystem measureSystem READ measureSystem WRITE setMeasureSystem NOTIFY measureSystemChanged)
97
Q_PROPERTY(int monetaryDecimalPlaces READ monetaryDecimalPlaces WRITE setMonetaryDecimalPlaces NOTIFY monetaryDecimalPlacesChanged)
98
Q_PROPERTY(QString monetaryDecimalSymbol READ monetaryDecimalSymbol WRITE setMonetaryDecimalSymbol NOTIFY monetaryDecimalSymbolChanged)
99
Q_PROPERTY(DigitSet monetaryDigitSet READ monetaryDigitSet WRITE setMonetaryDigitSet NOTIFY monetaryDigitSetChanged)
100
Q_PROPERTY(QString monetaryThousandsSeparator READ monetaryThousandsSeparator WRITE setMonetaryThousandsSeparator NOTIFY monetaryThousandsSeparatorChanged)
101
Q_PROPERTY(SignPosition negativeMonetarySignPosition READ negativeMonetarySignPosition WRITE setNegativeMonetarySignPosition NOTIFY negativeMonetarySignPositionChanged)
102
Q_PROPERTY(bool negativePrefixCurrencySymbol READ negativePrefixCurrencySymbol WRITE setNegativePrefixCurrencySymbol NOTIFY negativePrefixCurrencySymbolChanged)
103
Q_PROPERTY(QString negativeSign READ negativeSign WRITE setNegativeSign NOTIFY negativeSignChanged)
104
Q_PROPERTY(int pageSize READ pageSize WRITE setPageSize NOTIFY pageSizeChanged)
105
Q_PROPERTY(SignPosition positiveMonetarySignPosition READ positiveMonetarySignPosition WRITE setPositiveMonetarySignPosition NOTIFY positiveMonetarySignPositionChanged)
106
Q_PROPERTY(bool positivePrefixCurrencySymbol READ positivePrefixCurrencySymbol WRITE setPositivePrefixCurrencySymbol NOTIFY positivePrefixCurrencySymbolChanged)
107
Q_PROPERTY(QString positiveSign READ positiveSign WRITE setPositiveSign NOTIFY positiveSignChanged)
108
Q_PROPERTY(QString thousandsSeparator READ thousandsSeparator WRITE setThousandsSeparator NOTIFY thousandsSeparatorChanged)
109
Q_PROPERTY(int weekDayOfPray READ weekDayOfPray WRITE setWeekDayOfPray NOTIFY weekDayOfPrayChanged)
110
Q_PROPERTY(Locale::WeekNumberSystem weekNumberSystem READ weekNumberSystem WRITE setWeekNumberSystem NOTIFY WeekNumberSystemChanged)
111
Q_PROPERTY(int weekStartDay READ weekStartDay WRITE setWeekStartDay NOTIFY weekStartDayChanged)
112
Q_PROPERTY(int workingWeekEndDay READ workingWeekEndDay WRITE setWorkingWeekEndDay NOTIFY workingWeekEndDayChanged)
113
Q_PROPERTY(int workingWeekStartDay READ workingWeekStartDay WRITE setWorkingWeekStartDay NOTIFY workingWeekStartDayChanged)
114
Q_PROPERTY(bool use12Clock READ use12Clock CONSTANT)
115
Q_PROPERTY(QString defaultLanguage READ defaultLanguage CONSTANT)//read-only
116
Q_PROPERTY(QString defaultCountry READ defaultCountry CONSTANT)//read-only
117
Q_PROPERTY(QString defaultCurrencyCode READ defaultCurrencyCode CONSTANT)//read-only
118
Q_PROPERTY(bool useTranscript READ useTranscript CONSTANT) //read-only
119
Q_PROPERTY(int fileEncodingMib READ fileEncodingMib CONSTANT) //read-only
120
Q_PROPERTY(QStringList languageList READ languageList CONSTANT) //read-only
121
Q_PROPERTY(QStringList currencyCodeList READ currencyCodeList CONSTANT) //read-only
122
Q_PROPERTY(QStringList allLanguagesList READ allLanguagesList CONSTANT) //read-only
123
Q_PROPERTY(QStringList installedLanguages READ installedLanguages CONSTANT) //read-only
124
Q_PROPERTY(QStringList allCountriesList READ allCountriesList CONSTANT) //read-only
125
Q_PROPERTY(QList<int> allDigitSetsList READ allDigitSetsList CONSTANT) //read-only
131
Locale(QObject *parent = 0);
134
* Various positions for where to place the positive or negative
135
* sign when they are related to a monetary value.
139
* Put parantheses around the quantity, e.g. "$ (217)"
143
* Prefix the quantity with the sign, e.g. "$ -217"
145
BeforeQuantityMoney = 1,
147
* Suffix the quanitity with the sign, e.g. "$ 217-"
149
AfterQuantityMoney = 2,
151
* Prefix the currency symbol with the sign, e.g. "-$ 217"
155
* Suffix the currency symbol with the sign, e.g. "$- 217"
162
* The set of digit characters used to display and enter numbers.
165
ArabicDigits, /**< 0123456789 (European and some Asian
166
languages and western Arabic dialects) */
167
ArabicIndicDigits, /**< ٠١٢٣٤٥٦٧٨٩ (eastern Arabic dialects) */
168
EasternArabicIndicDigits, /**< ۰۱۲۳۴۵۶۷۸۹ (Persian and Urdu) */
169
DevenagariDigits, /**< ०१२३४५६७८९ (Hindi) */
170
BengaliDigits, /**< ০১২৩৪৫৬৭৮৯ (Bengali and Assamese) */
171
GujaratiDigits, /**< ૦૧૨૩૪૫૬૭૮૯ (Gujarati) */
172
GurmukhiDigits, /**< ੦੧੨੩੪੫੬੭੮੯ (Punjabi) */
173
KannadaDigits, /**< ೦೧೨೩೪೫೬೭೮೯ (Kannada) */
174
KhmerDigits, /**< ០១២៣៤៥៦៧៨៩ (Khmer) */
175
MalayalamDigits, /**< ൦൧൨൩൪൫൬൭൮൯ (Malayalam) */
176
OriyaDigits, /**< ୦୧୨୩୪୫୬୭୮୯ (Oriya) */
177
TamilDigits, /**< ௦௧௨௩௪௫௬௭௮ (Tamil) */
178
TeluguDigits, /**< ౦౧౨౩౪౫౬౭౯ (Telugu) */
179
ThaiDigits /**< ๐๑๒๓๔๕๖๗๘๙ (Thai) */
180
// The following Decimal Digit Sets are defined in Unicode but the associated
181
// languages are not yet translated in KDE, so are not yet enabled.
182
// The script names are taken from the Unicode standard, the associated
183
// languages from Wikipedia.
184
// BalineseDigits, /**< ᭐᭑᭒᭓᭔᭕᭖᭗᭘᭙ (Balinese) */
185
// ChamDigits, /**< ꩐꩑꩒꩓꩔꩕꩖꩗꩘꩙ (Cham) */
186
// JavaneseDigits, /**< ꧐꧑꧒꧓꧔꧕꧖꧗꧘꧙ (Javanese) */
187
// KayahLiDigits, /**< ꤀꤁꤂꤃꤄꤅꤆꤇꤈꤉ (Kayah) */
188
// LaoDigits, /**< ໐໑໒໓໔໕໖໗໘໙ (Lao) */
189
// LepchaDigits, /**< ᱀᱁᱂᱃᱄᱅᱆᱇᱈᱉ (Lepcha) */
190
// LimbuDigits, /**< ᥆᥇᥈᥉᥊᥋᥌᥍᥎᥏ (Limbu) */
191
// MeeteiMayekDigits, /**< ꯰꯱꯲꯳꯴꯵꯶꯷꯸꯹ (Meitei) */
192
// MongolianDigits, /**< ᠐᠑᠒᠓᠔᠕᠖᠗᠘᠙ (Mongolian) */
193
// MyanmarDigits, /**< ၀၁၂၃၄၅၆၇၈၉ (Myanmar/Burmese ) */
194
// MyanmarShanDigits, /**< ႐႑႒႓႔႕႖႗႘႙ (Shan) */
195
// NewTaiLueDigits, /**< ᧐᧑᧒᧓᧔᧕᧖᧗᧘᧙ (Tai Lü) */
196
// NKoDigits, /**< ߀߁߂߃߄߅߆߇߈߉ (Mande and N'Ko) */
197
// OlChikiDigits, /**< ᱐᱑᱒᱓᱔᱕᱖᱗᱘᱙ (Santali) */
198
// OsmanyaDigits, /**< ҠҡҢңҤҥҦҧҨҩ (Somali) */
199
// SaurashtraDigits, /**< ꣐꣑꣒꣓꣔꣕꣖꣗꣘꣙ (Saurashtra) */
200
// SundaneseDigits, /**< ᮰᮱᮲᮳᮴᮵᮶᮷᮸᮹ (Sundanese) */
201
// TaiThamDigits, /**< ᪐᪑᪒᪓᪔᪕᪖᪗᪘᪙ (Tai Lü) */
202
// TibetanDigits, /**< ༠༡༢༣༤༥༦༧༨༩ (Tibetan) */
203
// VaiDigits, /**< ꘠꘡꘢꘣꘤꘥꘦꘧꘨꘩ (Vai) */
208
* Convert a digit set identifier to a human readable, localized name.
210
* @param digitSet the digit set identifier
211
* @param withDigits whether to add the digits themselves to the name
213
* @return the human readable and localized name of the digit set
217
QString digitSetToName(DigitSet digitSet, bool withDigits = false) const;
221
* Provides list of all known digit set identifiers.
223
* @return list of all digit set identifiers
225
* @see digitSetToName
227
QList<int> allDigitSetsList() const;
230
* Returns what a decimal point should look like ("." or "," etc.)
231
* according to the current locale or user settings.
233
* @return The decimal symbol used by locale.
235
QString decimalSymbol() const;
238
* Returns what the thousands separator should look
239
* like ("," or "." etc.)
240
* according to the current locale or user settings.
242
* @return The thousands separator used by locale.
244
QString thousandsSeparator() const;
248
* Returns the identifier of the digit set used to display numbers.
250
* @return the digit set identifier
252
* @see digitSetToName
254
DigitSet digitSet() const;
258
* Returns the ISO 4217 Currency Code for the current locale
260
* @return The default ISO Currency Code used by locale.
262
QString currencyCode() const;
265
* Returns what the symbol denoting currency in the current locale
266
* as as defined by user settings should look like.
268
* @return The default currency symbol used by locale.
270
QString currencySymbol() const;
273
* Returns what a decimal point should look like ("." or "," etc.)
274
* for monetary values, according to the current locale or user
277
* @return The monetary decimal symbol used by locale.
279
QString monetaryDecimalSymbol() const;
282
* Returns what a thousands separator for monetary values should
283
* look like ("," or " " etc.) according to the current locale or
286
* @return The monetary thousands separator used by locale.
288
QString monetaryThousandsSeparator() const;
291
* Returns what a positive sign should look like ("+", " ", etc.)
292
* according to the current locale or user settings.
294
* @return The positive sign used by locale.
296
QString positiveSign() const;
299
* Returns what a negative sign should look like ("-", etc.)
300
* according to the current locale or user settings.
302
* @return The negative sign used by locale.
304
QString negativeSign() const;
308
* The number of decimal places to include in numeric values (usually 2).
310
* @return Default number of numeric decimal places used by locale.
312
int decimalPlaces() const;
316
* The number of decimal places to include in monetary values (usually 2).
318
* @return Default number of monetary decimal places used by locale.
320
int monetaryDecimalPlaces() const;
323
* If and only if the currency symbol precedes a positive value,
326
* @return Where to print the currency symbol for positive numbers.
328
bool positivePrefixCurrencySymbol() const;
331
* If and only if the currency symbol precedes a negative value,
334
* @return True if the currency symbol precedes negative numbers.
336
bool negativePrefixCurrencySymbol() const;
339
* Returns the position of a positive sign in relation to a
342
* @return Where/how to print the positive sign.
345
SignPosition positiveMonetarySignPosition() const;
348
* Denotes where to place a negative sign in relation to a
351
* @return Where/how to print the negative sign.
354
SignPosition negativeMonetarySignPosition() const;
358
* Retuns the digit set used to display monetary values.
360
* @return the digit set identifier
362
* @see digitSetToName
364
DigitSet monetaryDigitSet() const;
367
* Given a double, converts that to a numeric string containing
368
* the localized monetary equivalent.
370
* e.g. given 123456, return "$ 123,456.00".
372
* If precision isn't specified or is < 0, then the default monetaryDecimalPlaces() is used.
374
* @param num The number we want to format
375
* @param currency The currency symbol you want.
376
* @param precision Number of decimal places displayed
378
* @return The number of money as a localized string
379
* @see monetaryDecimalPlaces()
381
Q_INVOKABLE QString formatMoney(double num, const QString ¤cy = QString(), int precision = -1) const;
384
* Given a string representing a number, converts that to a numeric
385
* string containing the localized numeric equivalent.
387
* e.g. given 123456.78F, return "123,456.78" (for some European country).
389
* If precision isn't specified or is < 0, then the default decimalPlaces() is used.
391
* @param numStr The number to format, as a string.
392
* @param round Round fractional digits. (default true)
393
* @param precision Number of fractional digits used for rounding. Unused if round=false.
395
* @return The number as a localized string
397
Q_INVOKABLE QString formatNumber(const QString &numStr, bool round = true, int precision = -1) const;
400
* Given an integer, converts that to a numeric string containing
401
* the localized numeric equivalent.
403
* e.g. given 123456L, return "123,456" (for some European country).
405
* @param num The number to convert
407
* @return The number as a localized string
409
Q_INVOKABLE QString formatLong(long num) const;
412
* These binary units are used in KDE by the formatByteSize()
415
* NOTE: There are several different units standards:
416
* 1) SI (i.e. metric), powers-of-10.
417
* 2) IEC, powers-of-2, with specific units KiB, MiB, etc.
418
* 3) JEDEC, powers-of-2, used for solid state memory sizing which
419
* is why you see flash cards labels as e.g. 4GB. These (ab)use
420
* the metric units. Although JEDEC only defines KB, MB, GB, if
421
* JEDEC is selected all units will be powers-of-2 with metric
422
* prefixes for clarity in the event of sizes larger than 1024 GB.
424
* Although 3 different dialects are possible this enum only uses
425
* metric names since adding all 3 different names of essentially the same
426
* unit would be pointless. Use BinaryUnitDialect to control the exact
429
* @see binaryUnitDialect
431
enum BinarySizeUnits {
432
/// Auto-choose a unit such that the result is in the range [0, 1000 or 1024)
433
DefaultBinaryUnits = 1000,
435
// The first real unit must be 0 for the current implementation!
436
UnitByte = 0, ///< B 1 byte
437
UnitKiloByte, ///< KiB/KB/kB 1024/1000 bytes.
438
UnitMegaByte, ///< MiB/MB/MB 2^20/10^06 bytes.
439
UnitGigaByte, ///< GiB/GB/GB 2^30/10^09 bytes.
440
UnitTeraByte, ///< TiB/TB/TB 2^40/10^12 bytes.
441
UnitPetaByte, ///< PiB/PB/PB 2^50/10^15 bytes.
442
UnitExaByte, ///< EiB/EB/EB 2^60/10^18 bytes.
443
UnitZettaByte, ///< ZiB/ZB/ZB 2^70/10^21 bytes.
444
UnitYottaByte, ///< YiB/YB/YB 2^80/10^24 bytes.
445
UnitLastUnit = UnitYottaByte
449
* This enum chooses what dialect is used for binary units.
451
* Note: Although JEDEC abuses the metric prefixes and can therefore be
452
* confusing, it has been used to describe *memory* sizes for quite some time
453
* and programs should therefore use either Default, JEDEC, or IEC 60027-2
456
* On the other hand network transmission rates are typically in metric so
457
* Default, Metric, or IEC (which is unambiguous) should be chosen.
459
* Normally choosing DefaultBinaryUnits is the best option as that uses
460
* the user's selection for units.
462
* @see binaryUnitDialect
463
* @see setBinaryUnitDialect
465
enum BinaryUnitDialect {
466
DefaultBinaryDialect = 1000, ///< Used if no specific preference
467
IECBinaryDialect = 0, ///< KDE Default, KiB, MiB, etc. 2^(10*n)
468
JEDECBinaryDialect, ///< KDE 3.5 default, KB, MB, etc. 2^(10*n)
469
MetricBinaryDialect, ///< SI Units, kB, MB, etc. 10^(3*n)
470
LastBinaryDialect = MetricBinaryDialect
474
* Converts @p size from bytes to the string representation using the
475
* user's default binary unit dialect. The default unit dialect is
479
* formatByteSize(1024) returns "1.0 KiB" by default.
481
* @param size size in bytes
482
* @return converted size as a string - e.g. 123.4 KiB , 12.0 MiB
483
* @see BinaryUnitDialect
484
* @todo KDE 5: Remove in favor of overload added in KDE 4.4.
486
Q_INVOKABLE QString formatByteSize(double size) const;
490
* Converts @p size from bytes to the appropriate string representation
491
* using the binary unit dialect @p dialect and the specific units @p specificUnit.
494
* formatByteSize(1000, unit, Locale::BinaryUnitKilo) returns:
495
* for Locale::MetricBinaryUnits, "1.0 kB",
496
* for Locale::IECBinaryUnits, "0.9 KiB",
497
* for Locale::JEDECBinaryUnits, "0.9 KB".
499
* @param size size in bytes
500
* @param precision number of places after the decimal point to use. KDE uses
501
* 1 by default so when in doubt use 1.
502
* @param dialect binary unit standard to use. Use DefaultBinaryUnits to
503
* use the localized user selection unless you need to use a specific
504
* unit type (such as displaying a flash memory size in JEDEC).
505
* @param specificUnit specific unit size to use in result. Use
506
* DefaultBinarySize to automatically select a unit that will return
507
* a sanely-sized number.
508
* @return converted size as a translated string including the units.
509
* E.g. "1.23 KiB", "2 GB" (JEDEC), "4.2 kB" (Metric).
510
* @see BinaryUnitDialect
512
QString formatByteSize(double size, int precision,
513
BinaryUnitDialect dialect = Locale::DefaultBinaryDialect,
514
BinarySizeUnits specificUnit = Locale::DefaultBinaryUnits) const;
517
* Returns the user's configured binary unit dialect.
518
* e.g. if MetricBinaryDialect is returned then the values
519
* configured for how much a set of bytes are worth would
520
* be 10^(3*n) and KB (1000 bytes == 1 KB), in this case.
522
* Will never return DefaultBinaryDialect.
524
* @return User's configured binary unit dialect
525
* @see BinaryUnitDialect
527
BinaryUnitDialect binaryUnitDialect() const;
530
* Sets @p newDialect to be the default dialect for this locale (and only
531
* this locale). Newly created KLocale objects will continue to default
532
* to the user's choice.
534
* @param newDialect the new dialect to set as default for this locale object.
536
void setBinaryUnitDialect(BinaryUnitDialect newDialect);
539
* Given a number of milliseconds, converts that to a string containing
540
* the localized equivalent
542
* e.g. given formatDuration(60000), returns "1.0 minutes"
544
* @param mSec Time duration in milliseconds
545
* @return converted duration as a string - e.g. "5.5 seconds" "23.0 minutes"
547
Q_INVOKABLE QString formatDuration(unsigned long mSec) const;
550
* Given a number of milliseconds, converts that to a pretty string containing
551
* the localized equivalent.
553
* e.g. given prettyFormatDuration(60001) returns "1 minute"
554
* given prettyFormatDuration(62005) returns "1 minute and 2 seconds"
555
* given prettyFormatDuration(90060000) returns "1 day and 1 hour"
557
* @param mSec Time duration in milliseconds
558
* @return converted duration as a string.
559
* Units not interesting to the user, for example seconds or minutes when the first
560
* unit is day, are not returned because they are irrelevant. The same applies for
561
* seconds when the first unit is hour.
563
Q_INVOKABLE QString prettyFormatDuration(unsigned long mSec) const;
567
* Available Calendar Systems
569
* @see setCalendarSystem()
570
* @see calendarSystem()
572
enum CalendarSystem {
573
QDateCalendar = 1, /**< KDE Default, hybrid of Gregorian and Julian as used by QDate */
574
//BahaiCalendar = 2, /**< Baha'i Calendar */
575
//BuddhistLunarCalendar = 3, /**< Buddhist Lunar Calendar*/
576
//ChineseCalendar = 4, /**< Chinese Calendar */
577
CopticCalendar = 5, /**< Coptic Calendar as used Coptic Church and some parts of Egypt */
578
EthiopianCalendar = 6, /**< Ethiopian Calendar, aka Ethiopic Calendar */
579
//EthiopianAmeteAlemCalendar = 7, /**< Ethiopian Amete Alem version, aka Ethiopic Amete Alem */
580
GregorianCalendar = 8, /**< Gregorian Calendar, pure proleptic implementation */
581
HebrewCalendar = 9, /**< Hebrew Calendar, aka Jewish Calendar */
582
//HinduCalendar = 10, /**< Hindu Lunar Calendar */
583
//IslamicLunarCalendar = 11, /**< Islamic Lunar Calendar */
584
IslamicCivilCalendar = 12, /**< Islamic Civil Calendar, aka Hijri, not the Lunar Calendar */
585
//IslamicUmAlQuraCalendar = 13, /**< Islamic Lunar Calendar, Um Al Qura varient used in Saudi Arabia */
586
IndianNationalCalendar = 14, /**< Indian National Calendar, not the Lunar Calendar */
587
//Iso8601Calendar = 15, /**< ISO 8601 Standard Calendar */
588
JalaliCalendar = 16, /**< Jalali Calendar, aka Persian or Iranian, also used in Afghanistan */
589
//JalaliBirashkCalendar = 17, /**< Jalali Calendar, Birashk Algorythm variant */
590
//Jalali33YearCalendar = 18, /**< Jalali Calendar, 33 Year cycle variant */
591
JapaneseCalendar= 19, /**< Japanese Calendar, Gregorian calculation using Japanese Era (Nengô) */
592
//JucheCalendar = 20, /**< Juche Calendar, used in North Korea */
593
JulianCalendar = 21, /**< Julian Calendar, as used in Orthodox Churches */
594
MinguoCalendar= 22, /**< Minguo Calendar, aka ROC, Republic of China or Taiwanese */
595
ThaiCalendar = 23 /**< Thai Calendar, aka Buddhist or Thai Buddhist */
600
* System used for Week Numbers
602
* @see setWeekNumberSystem()
603
* @see weekNumberSystem()
605
enum WeekNumberSystem {
606
DefaultWeekNumber = 1000, /**< The system locale default */
607
IsoWeekNumber = 0, /**< ISO Week Number */
608
FirstFullWeek = 1, /**< Week 1 starts on the first Week Start Day in year ends after 7 days */
609
FirstPartialWeek = 2, /**< Week 1 starts Jan 1st ends day before first Week Start Day in year */
610
SimpleWeek = 3 /**< Week 1 starts Jan 1st ends after 7 days */
615
* The various Components that make up a Date / Time
616
* In the future the Components may be combined as flags for dynamic
617
* generation of Date Formats.
619
* @see CalendarSystem
620
* @see KLocalizedDate
621
* @see DateTimeComponentFormat
623
enum DateTimeComponent {
624
Year = 0x1, /**< The Year portion of a date, may be number or name */
625
YearName = 0x2, /**< The Year Name portion of a date */
626
Month = 0x4, /**< The Month portion of a date, may be number or name */
627
MonthName = 0x8, /**< The Month Name portion of a date */
628
Day = 0x10, /**< The Day portion of a date, may be number or name */
629
DayName = 0x20, /**< The Day Name portion of a date */
630
JulianDay = 0x40, /**< The Julian Day of a date */
631
EraName = 0x80, /**< The Era Name portion of a date */
632
EraYear = 0x100, /**< The Era and Year portion of a date */
633
YearInEra = 0x200, /**< The Year In Era portion of a date */
634
DayOfYear = 0x400, /**< The Day Of Year portion of a date, may be number or name */
635
DayOfYearName = 0x800, /**< The Day Of Year Name portion of a date */
636
DayOfWeek = 0x1000, /**< The Day Of Week / Weekday portion of a date, may be number or name */
637
DayOfWeekName = 0x2000, /**< The Day Of Week Name / Weekday Name portion of a date */
638
Week = 0x4000, /**< The Week Number portion of a date */
639
WeekYear = 0x8000, /**< The Week Year portion of a date */
640
MonthsInYear = 0x10000, /**< The Months In Year portion of a date */
641
WeeksInYear = 0x20000, /**< The Weeks In Year portion of a date */
642
DaysInYear = 0x40000, /**< The Days In Year portion of a date */
643
DaysInMonth = 0x80000, /**< The Days In Month portion of a date */
644
DaysInWeek = 0x100000, /**< The Days In Week portion of a date */
645
Hour = 0x200000, /**< The Hours portion of a date */
646
Minute = 0x400000, /**< The Minutes portion of a date */
647
Second = 0x800000, /**< The Seconds portion of a date */
648
Millisecond = 0x1000000, /**< The Milliseconds portion of a date */
649
DayPeriod = 0x2000000, /**< The Day Period portion of a date, e.g. AM/PM */
650
DayPeriodHour = 0x4000000, /**< The Day Period Hour portion of a date */
651
Timezone = 0x8000000, /**< The Time Zone portion of a date, may be offset or name */
652
TimezoneName = 0x10000000, /**< The Time Zone Name portion of a date */
653
UnixTime = 0x20000000 /**< The UNIX Time portion of a date */
658
* Format used for individual Date/Time Components when converted to/from a string
659
* Largely equivalent to the UNICODE CLDR format width definitions 1..5
661
* @see DateTimeComponentFormat
663
enum DateTimeComponentFormat {
664
DefaultComponentFormat = 1000, /**< The system locale default for the componant */
665
ShortNumber = 0, /**< Number at its natural width, e.g. 2 for the 2nd*/
666
LongNumber, /**< Number padded to a required width, e.g. 02 for the 2nd*/
667
//OrdinalNumber /**< Ordinal number format, e.g. "2nd" for the 2nd */
668
NarrowName = 3, /**< Narrow text format, may not be unique, e.g. M for Monday */
669
ShortName, /**< Short text format, e.g. Mon for Monday */
670
LongName /**< Long text format, e.g. Monday for Monday */
673
Q_DECLARE_FLAGS(DateTimeComponents, DateTimeComponent)
676
* Format for date string.
679
ShortDate, /**< Locale Short date format, e.g. 08-04-2007 */
680
LongDate, /**< Locale Long date format, e.g. Sunday 08 April 2007 */
681
FancyShortDate, /**< Same as ShortDate for dates a week or more ago. For more
682
recent dates, it is represented as Today, Yesterday, or
684
FancyLongDate, /**< Same as LongDate for dates a week or more ago. For more
685
recent dates, it is represented as Today, Yesterday, or
687
IsoDate, /**< ISO-8601 Date format YYYY-MM-DD, e.g. 2009-12-31 */
688
IsoWeekDate, /**< ISO-8601 Week Date format YYYY-Www-D, e.g. 2009-W01-1 */
689
IsoOrdinalDate /**< ISO-8601 Ordinal Date format YYYY-DDD, e.g. 2009-001 */
693
* Returns a string formatted to the current locale's conventions
696
* @param date the date to be formatted
697
* @param format category of date format to use
699
* @return the date as a string
701
Q_INVOKABLE QString formatDate(const QDate &date, DateFormat format = LongDate) const;
704
* Options for formatting date-time values.
706
enum DateTimeFormatOption {
707
TimeZone = 0x01, /**< Include a time zone string */
708
Seconds = 0x02 /**< Include the seconds value */
711
Q_DECLARE_FLAGS(DateTimeFormatOptions, DateTimeFormatOption)
714
* Returns a string formatted to the current locale's conventions
715
* regarding both date and time.
717
* @param dateTime the date and time to be formatted
718
* @param format category of date format to use
719
* @param options additional output options
721
* @return The date and time as a string
723
Q_INVOKABLE QString formatDateTime(const QDateTime &dateTime, DateFormat format = ShortDate,
724
DateTimeFormatOptions options = 0) const;
727
* Use this to determine whether in dates a possessive form of month
728
* name is preferred ("of January" rather than "January")
730
* @return If possessive form should be used
732
bool dateMonthNamePossessive() const;
736
* Format flags for readLocaleTime() and formatLocaleTime()
738
enum TimeFormatOption {
739
TimeDefault = 0x0, ///< Default formatting using seconds and the format
740
///< as specified by the locale.
741
TimeWithoutSeconds = 0x1, ///< Exclude the seconds part of the time from display
742
TimeWithoutAmPm = 0x2, ///< Read/format time string without am/pm suffix but
743
///< keep the 12/24h format as specified by locale time
744
///< format, eg. "07.33.05" instead of "07.33.05 pm" for
745
///< time format "%I.%M.%S %p".
746
TimeDuration = 0x6, ///< Read/format time string as duration. This will strip
747
///< the am/pm suffix and read/format times with an hour
748
///< value of 0-23 hours, eg. "19.33.05" instead of
749
///< "07.33.05 pm" for time format "%I.%M.%S %p".
750
///< This automatically implies @c TimeWithoutAmPm.
751
TimeFoldHours = 0xE ///< Read/format time string as duration. This will not
752
///< not output the hours part of the duration but will
753
///< add the hours (times sixty) to the number of minutes,
754
///< eg. "70.23" instead of "01.10.23" for time format
758
Q_DECLARE_FLAGS(TimeFormatOptions, TimeFormatOption)
762
* Returns a string formatted to the current locale's conventions
765
* @param pTime the time to be formatted
766
* @param options format option to use when formatting the time
767
* @return The time as a string
769
Q_INVOKABLE QString formatLocaleTime(const QTime &pTime,
770
TimeFormatOptions options = Locale::TimeDefault) const;
774
* Returns the identifier of the digit set used to display dates and time.
776
* @return the digit set identifier
778
* @see digitSetToName
780
DigitSet dateTimeDigitSet() const;
783
* Use this to determine if the user wants a 12 hour clock.
785
* @return If the user wants 12h clock
787
bool use12Clock() const;
791
* Returns the Day Period matching the time given
793
* @param time the time to return the day period for
794
* @param format the format to return teh day period in
795
* @return the Day Period for the given time
797
Q_INVOKABLE QString dayPeriodText(const QTime &time, DateTimeComponentFormat format = DefaultComponentFormat) const;
800
* Use this to determine which day is the first day of the week.
802
* @return an integer (Monday=1..Sunday=7)
804
int weekStartDay() const;
807
* Use this to determine which day is the first working day of the week.
809
* @return an integer (Monday=1..Sunday=7)
811
int workingWeekStartDay() const;
814
* Use this to determine which day is the last working day of the week.
816
* @return an integer (Monday=1..Sunday=7)
818
int workingWeekEndDay() const;
821
* Use this to determine which day is reserved for religious observance
823
* @return day number (None = 0, Monday = 1, ..., Sunday = 7)
825
int weekDayOfPray() const;
829
* Returns the type of Calendar System used in this Locale
831
* @see Locale::CalendarSystem
832
* @see CalendarSystem
833
* @return the type of Calendar System
835
Locale::CalendarSystem calendarSystem() const;
839
* Sets the type of Calendar System to use in this Locale
841
* @see Locale::CalendarSystem
842
* @see CalendarSystem
843
* @param calendarSystem the Calendar System to use
845
void setCalendarSystem(Locale::CalendarSystem calendarSystem);
849
* Sets the type of Week Number System to use in this Locale
851
* @see Klocale::WeekNumberSystem
852
* @see weekNumberSystem()
853
* @param weekNumberSystem the Week Number System to use
855
void setWeekNumberSystem(Locale::WeekNumberSystem weekNumberSystem);
859
* Returns the type of Week Number System used in this Locale
861
* @see Klocale::WeekNumberSystem
862
* @see setWeekNumberSystem()
863
* @returns the Week Number System used
865
Locale::WeekNumberSystem weekNumberSystem() const;
868
* Converts a localized monetary string to a double.
870
* @param numStr the string we want to convert.
871
* @param ok the boolean that is set to false if it's not a number.
872
* If @p ok is 0, it will be ignored
874
* @return The string converted to a double
876
Q_INVOKABLE double readMoney(const QString &numStr) const;
879
* Converts a localized numeric string to a double.
881
* @param numStr the string we want to convert.
882
* @return The string converted to a double
884
Q_INVOKABLE double readNumber(const QString &numStr) const;
887
* Flags for readDate()
890
NormalFormat = 1, /**< Only accept a date string in
891
the locale LongDate format */
892
ShortFormat = 2, /**< Only accept a date string in
893
the locale ShortDate format */
894
IsoFormat = 4, /**< Only accept a date string in
895
ISO date format (YYYY-MM-DD) */
896
IsoWeekFormat = 8, /**< Only accept a date string in
897
ISO Week date format (YYYY-Www-D) */
898
IsoOrdinalFormat = 16 /**< Only accept a date string in
899
ISO Week date format (YYYY-DDD) */
903
* Converts a localized date string to a QDate.
904
* This method is stricter than readDate(str,&ok): it will only accept
905
* a date in a specific format, depending on @p flags.
907
* @param str the string we want to convert.
908
* @param flags what format the the date string will be in
909
* @return The string converted to a QDate
910
* @see CalendarSystem::readDate()
912
Q_INVOKABLE QDate readDate(const QString &str, ReadDateFlags flags) const;
915
* Converts a localized time string to a QTime.
916
* This method will try to parse it with seconds, then without seconds.
918
* @param str the string we want to convert.
920
* @return The string converted to a QTime
922
Q_INVOKABLE QTime readTime(const QString &str) const;
925
* Additional processing options for readLocaleTime().
927
* @remarks This is currently used as an enum but declared as a flag
930
enum TimeProcessingOption {
931
ProcessStrict = 0x1, ///< Process time in a strict manner, ie.
932
///< a read time string has to exactly match
933
///< the defined time format.
934
ProcessNonStrict = 0x2 ///< Process time in a lax manner, ie.
935
///< allow spaces in the time-format to be
936
///< left out when entering a time string.
939
Q_DECLARE_FLAGS(TimeProcessingOptions, TimeProcessingOption)
943
* Converts a localized time string to a QTime.
944
* This method is stricter than readTime(str, &ok) in that it will either
945
* accept a time with seconds or a time without seconds.
947
* @param str the string we want to convert
948
* @param ok the boolean that is set to false if it's not a valid time.
949
* If @p ok is 0, it will be ignored.
950
* @param options format option to apply when formatting the time
951
* @param processing if set to @c ProcessStrict, checking will be strict
952
* and the read time string has to have the exact time format
953
* specified. If set to @c ProcessNonStrict processing the time
954
* is lax and spaces in the time string can be left out.
956
* @return The string converted to a QTime
959
Q_INVOKABLE QTime readLocaleTime(const QString &str,
960
TimeFormatOptions options = Locale::TimeDefault,
961
TimeProcessingOptions processing = ProcessNonStrict) const;
964
* Returns the language code used by this object. The domain AND the
965
* library translation must be available in this language.
966
* defaultLanguage() is returned by default, if no other available.
968
* Use languageCodeToName(language) to get human readable, localized
971
* @return the currently used language code
973
* @see languageCodeToName
975
QString language() const;
978
* Returns the country code of the country where the user lives.
980
* The returned code complies with the ISO 3166-1 alpha-2 standard,
981
* except by KDE convention it is returned in lowercase whereas the
982
* official standard is uppercase.
983
* See http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 for details.
985
* defaultCountry() is returned by default, if no other available,
986
* this will always be uppercase 'C'.
988
* Use countryCodeToName(country) to get human readable, localized
991
* @return the country code for the user
993
* @see countryCodeToName
995
QString country() const;
999
* Returns the Country Division Code of the Country where the user lives.
1000
* When no value is set, then the Country Code will be returned.
1002
* The returned code complies with the ISO 3166-2 standard.
1003
* See http://en.wikipedia.org/wiki/ISO_3166-2 for details.
1005
* Note that unlike country() this method will return the correct case,
1006
* i.e. normally uppercase..
1008
* In KDE 4.6 it is the apps responsibility to obtain a translation for the
1009
* code, translation and other services will be priovided in KDE 4.7.
1011
* @return the Country Division Code for the user
1012
* @see setCountryDivisionCode
1014
QString countryDivisionCode() const;
1017
* Returns the language codes selected by user, ordered by decreasing
1020
* Use languageCodeToName(language) to get human readable, localized
1023
* @return list of language codes
1025
* @see languageCodeToName
1027
QStringList languageList() const;
1031
* Returns the ISO Currency Codes used in the locale, ordered by decreasing
1034
* Use KCurrency::currencyCodeToName(currencyCode) to get human readable,
1035
* localized language name.
1037
* @return list of ISO Currency Codes
1039
* @see currencyCodeToName
1041
QStringList currencyCodeList() const;
1044
* Returns the file encoding.
1046
* @return The Mib of the file encoding
1048
* @see QFile::encodeName
1049
* @see QFile::decodeName
1051
int fileEncodingMib() const;
1054
* Changes the current date format.
1056
* The format of the date is a string which contains variables that will
1058
* @li %Y with the whole year (e.g. "2004" for "2004")
1059
* @li %y with the lower 2 digits of the year (e.g. "04" for "2004")
1060
* @li %n with the month (January="1", December="12")
1061
* @li %m with the month with two digits (January="01", December="12")
1062
* @li %e with the day of the month (e.g. "1" on the first of march)
1063
* @li %d with the day of the month with two digits (e.g. "01" on the first of march)
1064
* @li %b with the short form of the month (e.g. "Jan" for January)
1065
* @li %B with the long form of the month (e.g. "January")
1066
* @li %a with the short form of the weekday (e.g. "Wed" for Wednesday)
1067
* @li %A with the long form of the weekday (e.g. "Wednesday" for Wednesday)
1069
* Everything else in the format string will be taken as is.
1070
* For example, March 20th 1989 with the format "%y:%m:%d" results
1073
* @param format The new date format
1075
void setDateFormat(const QString & format);
1078
* Changes the current short date format.
1080
* The format of the date is a string which contains variables that will
1082
* @li %Y with the whole year (e.g. "1984" for "1984")
1083
* @li %y with the lower 2 digits of the year (e.g. "84" for "1984")
1084
* @li %n with the month (January="1", December="12")
1085
* @li %m with the month with two digits (January="01", December="12")
1086
* @li %e with the day of the month (e.g. "1" on the first of march)
1087
* @li %d with the day of the month with two digits(e.g. "01" on the first of march)
1088
* @li %b with the short form of the month (e.g. "Jan" for January)
1089
* @li %B with the long form of the month (e.g. "January")
1090
* @li %a with the short form of the weekday (e.g. "Wed" for Wednesday)
1091
* @li %A with the long form of the weekday (e.g. "Wednesday" for Wednesday)
1093
* Everything else in the format string will be taken as is.
1094
* For example, March 20th 1989 with the format "%y:%m:%d" results
1097
* @param format The new short date format
1099
void setDateFormatShort(const QString & format);
1102
* Changes the form of month name used in dates.
1104
* @param possessive True if possessive forms should be used
1106
void setDateMonthNamePossessive(bool possessive);
1109
* Changes the current time format.
1111
* The format of the time is string a which contains variables that will
1113
* @li %H with the hour in 24h format and 2 digits (e.g. 5pm is "17", 5am is "05")
1114
* @li %k with the hour in 24h format and one digits (e.g. 5pm is "17", 5am is "5")
1115
* @li %I with the hour in 12h format and 2 digits (e.g. 5pm is "05", 5am is "05")
1116
* @li %l with the hour in 12h format and one digits (e.g. 5pm is "5", 5am is "5")
1117
* @li %M with the minute with 2 digits (e.g. the minute of 07:02:09 is "02")
1118
* @li %S with the seconds with 2 digits (e.g. the minute of 07:02:09 is "09")
1119
* @li %p with pm or am (e.g. 17.00 is "pm", 05.00 is "am")
1121
* Everything else in the format string will be taken as is.
1122
* For example, 5.23pm with the format "%H:%M" results
1125
* @param format The new time format
1127
void setTimeFormat(const QString & format);
1131
* Set digit characters used to display dates and time.
1133
* @param digitSet the digit set identifier
1136
void setDateTimeDigitSet(DigitSet digitSet);
1139
* Changes how KLocale defines the first day in week.
1141
* @param day first day of the week (Monday=1..Sunday=7) as integer
1143
void setWeekStartDay(int day);
1146
* Changes how KLocale defines the first working day in week.
1148
* @param day first working day of the week (Monday=1..Sunday=7) as integer
1150
void setWorkingWeekStartDay(int day);
1153
* Changes how KLocale defines the last working day in week.
1155
* @param day last working day of the week (Monday=1..Sunday=7) as integer
1157
void setWorkingWeekEndDay(int day);
1160
* Changes how KLocale defines the day reserved for religious observance.
1162
* @param day day of the week for religious observance (None=0,Monday=1..Sunday=7) as integer
1164
void setWeekDayOfPray(int day);
1167
* Returns the currently selected date format.
1169
* @return Current date format.
1170
* @see setDateFormat()
1172
QString dateFormat() const;
1175
* Returns the currently selected short date format.
1177
* @return Current short date format.
1178
* @see setDateFormatShort()
1180
QString dateFormatShort() const;
1183
* Returns the currently selected time format.
1185
* @return Current time format.
1186
* @see setTimeFormat()
1188
QString timeFormat() const;
1191
* Changes the symbol used to identify the decimal pointer.
1193
* @param symbol The new decimal symbol.
1195
void setDecimalSymbol(const QString & symbol);
1198
* Changes the separator used to group digits when formating numbers.
1200
* @param separator The new thousands separator.
1202
void setThousandsSeparator(const QString & separator);
1205
* Changes the sign used to identify a positive number. Normally this is
1208
* @param sign Sign used for positive numbers.
1210
void setPositiveSign(const QString & sign);
1213
* Changes the sign used to identify a negative number.
1215
* @param sign Sign used for negative numbers.
1217
void setNegativeSign(const QString & sign);
1221
* Changes the set of digit characters used to display numbers.
1223
* @param digitSet the digit set identifier
1226
void setDigitSet(DigitSet digitSet);
1229
* Changes the sign position used for positive monetary values.
1231
* @param signpos The new sign position
1233
void setPositiveMonetarySignPosition(SignPosition signpos);
1236
* Changes the sign position used for negative monetary values.
1238
* @param signpos The new sign position
1240
void setNegativeMonetarySignPosition(SignPosition signpos);
1243
* Changes the position where the currency symbol should be printed for
1244
* positive monetary values.
1246
* @param prefix True if the currency symbol should be prefixed instead of
1249
void setPositivePrefixCurrencySymbol(bool prefix);
1252
* Changes the position where the currency symbol should be printed for
1253
* negative monetary values.
1255
* @param prefix True if the currency symbol should be prefixed instead of
1258
void setNegativePrefixCurrencySymbol(bool prefix);
1262
* Changes the number of decimal places used when formating numbers.
1264
* @param digits The default number of digits to use.
1266
void setDecimalPlaces(int digits);
1270
* Changes the number of decimal places used when formating money.
1272
* @param digits The default number of digits to use.
1274
void setMonetaryDecimalPlaces(int digits);
1277
* Changes the separator used to group digits when formating monetary values.
1279
* @param separator The new thousands separator.
1281
void setMonetaryThousandsSeparator(const QString & separator);
1284
* Changes the symbol used to identify the decimal pointer for monetary
1287
* @param symbol The new decimal symbol.
1289
void setMonetaryDecimalSymbol(const QString & symbol);
1293
* Changes the current ISO Currency Code.
1295
* @param newCurrencyCode The new Currency Code
1297
void setCurrencyCode(const QString &newCurrencyCode);
1300
* Changes the current currency symbol.
1302
* This symbol should be consistant with the selected Currency Code
1304
* @param symbol The new currency symbol
1305
* @see currencyCode, KCurrency::currencySymbols
1307
void setCurrencySymbol(const QString & symbol);
1311
* Set digit characters used to display monetary values.
1313
* @param digitSet the digit set identifier
1316
void setMonetaryDigitSet(DigitSet digitSet);
1319
* Returns the preferred page size for printing.
1321
* @return The preferred page size, cast it to QPrinter::PageSize
1323
int pageSize() const;
1326
* Changes the preferred page size when printing.
1328
* @param paperFormat the new preferred page size in the format QPrinter::PageSize
1330
void setPageSize(int paperFormat);
1333
* The Metric system will give you information in mm, while the
1334
* Imperial system will give you information in inches.
1336
enum MeasureSystem {
1337
Metric, ///< Metric system (used e.g. in Europe)
1338
Imperial ///< Imperial system (used e.g. in the United States)
1342
* Returns which measuring system we use.
1344
* @return The preferred measuring system
1346
MeasureSystem measureSystem() const;
1349
* Changes the preferred measuring system.
1351
* @return value The preferred measuring system
1353
void setMeasureSystem(MeasureSystem value);
1356
* Translates a message as a QTranslator is supposed to.
1357
* The parameters are similar to i18n(), but the result
1358
* value has other semantics (it can be QString())
1360
Q_INVOKABLE QString translateQt(const char *context, const char *sourceText, const char *comment) const;
1363
* Provides list of all known language codes.
1365
* Use languageCodeToName(language) to get human readable, localized
1368
* @return list of all language codes
1370
* @see languageCodeToName
1371
* @see installedLanguages
1373
QStringList allLanguagesList() const;
1377
* Provides list of all installed KDE Language Translations.
1379
* Use languageCodeToName(language) to get human readable, localized
1382
* @return list of all installed language codes
1384
* @see languageCodeToName
1386
QStringList installedLanguages() const;
1389
* Convert a known language code to a human readable, localized form.
1390
* If an unknown language code is supplied, empty string is returned;
1391
* this will never happen if the code has been obtained by one of the
1394
* @param language the language code
1396
* @return the human readable and localized form if the code is known,
1401
* @see allLanguagesList
1402
* @see installedLanguages
1404
Q_INVOKABLE QString languageCodeToName(const QString &language) const;
1407
* Provides list of all known country codes.
1409
* Use countryCodeToName(country) to get human readable, localized
1412
* @return a list of all country codes
1414
* @see countryCodeToName
1416
QStringList allCountriesList() const;
1419
* Convert a known country code to a human readable, localized form.
1421
* If an unknown country code is supplied, empty string is returned;
1422
* this will never happen if the code has been obtained by one of the
1425
* @param country the country code
1427
* @return the human readable and localized form of the country name
1430
* @see allCountriesList
1432
Q_INVOKABLE QString countryCodeToName(const QString &country) const;
1435
* Parses locale string into distinct parts.
1436
* The format of locale is language_COUNTRY@modifier.CHARSET
1438
* @param locale the locale string to split
1439
* @param language set to the language part of the locale
1440
* @param country set to the country part of the locale
1441
* @param modifier set to the modifer part of the locale
1442
* @param charset set to the charset part of the locale
1444
Q_INVOKABLE void splitLocale(const QString &locale, QString &language, QString &country,
1445
QString &modifier, QString &charset);
1448
* Returns the name of the internal language.
1450
* @return Name of the default language
1452
QString defaultLanguage();
1455
* Returns the code of the default country, i.e. "C"
1457
* This function will not provide a sensible value to use in your app,
1458
* please use country() instead.
1462
* @return Name of the default country
1464
QString defaultCountry();
1468
* Returns the ISO Code of the default currency.
1470
* @return ISO Currency Code of the default currency
1472
QString defaultCurrencyCode();
1475
* Reports whether evaluation of translation scripts is enabled.
1477
* @return true if script evaluation is enabled, false otherwise.
1479
bool useTranscript() const;
1482
* Checks whether or not the active catalog is found for the given language.
1484
* @param language language to check
1486
Q_INVOKABLE bool isApplicationTranslatedInto(const QString & language);
1490
* Sets the Country Division Code of the Country where the user lives.
1492
* The code must comply with the ISO 3166-2 standard.
1493
* See http://en.wikipedia.org/wiki/ISO_3166-2 for details.
1495
* In KDE 4.6 it is the apps responsibility to validate the input,
1496
* full validation and other services will be provided in KDE 4.7.
1498
* @param countryDivision the Country Division Code for the user
1499
* @return @c true on success, @c false on failure
1500
* @see countryDivisionCode
1502
bool setCountryDivisionCode(const QString & countryDivision);
1506
* Removes accelerator marker from a UI text label.
1508
* Accelerator marker is not always a plain ampersand (&),
1509
* so it is not enough to just remove it by @c QString::remove().
1510
* The label may contain escaped markers ("&&") which must be resolved
1511
* and skipped, as well as CJK-style markers ("Foo (&F)") where
1512
* the whole parenthesis construct should be removed.
1513
* Therefore always use this function to remove accelerator marker
1516
* @param label UI label which may contain an accelerator marker
1517
* @return label without the accelerator marker
1519
Q_INVOKABLE QString removeAcceleratorMarker(const QString &label) const;
1523
* Convert all digits in the string to the given digit set.
1525
* Conversion is normally not performed if the given digit set
1526
* is not appropriate in the current locale and language context.
1527
* Unconditional conversion may be requested by setting
1528
* @p ignoreContext to @c true.
1530
* @param str the string to convert
1531
* @param digitSet the digit set identifier
1532
* @param ignoreContext unconditional conversion if @c true
1534
* @return string with converted digits
1538
Q_INVOKABLE QString convertDigits(const QString &str, DigitSet digitSet,
1539
bool ignoreContext = false) const;
1543
* Reparse locale configuration files for the current selected
1546
Q_INVOKABLE void reparseConfiguration();
1552
void binaryUnitDialectChanged();
1553
void calendarSystemChanged();
1554
void countryDivisionCodeChanged();
1555
void currencyCodeChanged();
1556
void decimalSymbolChanged();
1557
void currencySymbolChanged();
1558
void dateFormatChanged();
1559
void dateFormatShortChanged();
1560
void dateMonthNamePossessiveChanged();
1561
void dateTimeDigitSetChanged();
1562
void decimalPlacesChanged();
1563
void digitSetChanged();
1564
void measureSystemChanged();
1565
void monetaryDecimalPlacesChanged();
1566
void monetaryDecimalSymbolChanged();
1567
void monetaryDigitSetChanged();
1568
void monetaryThousandsSeparatorChanged();
1569
void negativeMonetarySignPositionChanged();
1570
void negativePrefixCurrencySymbolChanged();
1571
void negativeSignChanged();
1572
void pageSizeChanged();
1573
void positiveMonetarySignPositionChanged();
1574
void positivePrefixCurrencySymbolChanged();
1575
void positiveSignChanged();
1576
void thousandsSeparatorChanged();
1577
void timeFormatChanged();
1578
void weekDayOfPrayChanged();
1579
void WeekNumberSystemChanged();
1580
void weekStartDayChanged();
1581
void workingWeekEndDayChanged();
1582
void workingWeekStartDayChanged();