Warning: That file was not part of the compilation database. It may have many parsing errors.

1/* This file is part of the KDE libraries
2 Copyright (C) 1997 Stephan Kulow <coolo@kde.org>
3 Copyright (C) 1999-2003 Hans Petter Bieker <bieker@kde.org>
4 Copyright (c) 2002 Lukas Tinkl <lukas@kde.org>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20*/
21#ifndef KLOCALE_H
22#define KLOCALE_H
23
24#include <kdecore_export.h>
25#include <klocalizedstring.h>
26#include <ksharedconfig.h>
27
28#include <QtCore/QString>
29#include <QtCore/QList>
30
31class QStringList;
32class QTextCodec;
33class QDate;
34class QTime;
35class QDateTime;
36
37class KDateTime;
38class KCalendarSystem;
39class KCurrencyCode;
40class KDayPeriod;
41
42class KLocalePrivate;
43
44/**
45 * \file klocale.h
46 */
47
48/**
49 *
50 * KLocale provides support for country specific stuff like
51 * the national language.
52 *
53 * KLocale supports translating, as well as specifying the format
54 * for numbers, currency, time, and date.
55 *
56 * Use KGlobal::locale() to get pointer to the global KLocale object,
57 * containing the applications current locale settings.
58 *
59 * For example, to format the date May 17, 1995 in the current locale, use:
60 *
61 * \code
62 * QString date = KGlobal::locale()->formatDate(QDate(1995,5,17));
63 * \endcode
64 *
65 * @author Stephan Kulow <coolo@kde.org>, Preston Brown <pbrown@kde.org>,
66 * Hans Petter Bieker <bieker@kde.org>, Lukas Tinkl <lukas.tinkl@suse.cz>
67 * @short class for supporting locale settings and national language
68 */
69class KDECORE_EXPORT KLocale
70{
71public:
72 /**
73 * Constructs a KLocale with the given catalog name
74 *
75 * The constructor looks for an entry Language in the group Locale in the
76 * configuration file.
77 *
78 * If no configuration file is specified, it will also look for languages
79 * using the environment variables (KDE_LANG, LC_MESSAGES, LC_ALL, LANG),
80 * as well as the global configuration file. If KLocale is not able to use
81 * any of the specified languages, the default language (en_US) will be
82 * used.
83 *
84 * If you specify a configuration file, it has to be valid until the KLocale
85 * object is destroyed. Note that a setLocale() will be performed on the
86 * config using the current locale language, which may cause a sync()
87 * and reparseConfiguration() which will save any changes you have made and
88 * load any changes other shared copies have made.
89 *
90 * @param catalog the name of the main language file
91 * @param config a configuration file with a Locale group detailing
92 * locale-related preferences (such as language and
93 * formatting options).
94 */
95 explicit KLocale(const QString& catalog, KSharedConfig::Ptr config = KSharedConfig::Ptr());
96
97 /**
98 * Constructs a KLocale with the given catalog name
99 *
100 * Allows you to override the language and, optionally, the
101 * country of this locale.
102 *
103 * If you specify a configuration file, a setLocale() will be performed on
104 * the config using the current locale language, which may cause a sync()
105 * and reparseConfiguration() which will save any changes you have made.
106 *
107 * @param catalog the name of the main language file
108 * @param language the ISO Language Code for the locale, e.g. "en" for English
109 * @param country the ISO Country Code for the locale, e.g. "us" for USA
110 * @param config a configuration file with a Locale group detailing
111 * locale-related preferences (such as language and
112 * formatting options).
113 */
114 KLocale(const QString& catalog, const QString &language, const QString &country = QString(),
115 KConfig *config = 0);
116
117 /**
118 * Copy constructor
119 */
120 KLocale(const KLocale & rhs);
121
122 /**
123 * Assignment operator
124 */
125 KLocale& operator= (const KLocale & rhs);
126
127 /**
128 * Destructor
129 */
130 virtual ~KLocale();
131
132 /**
133 * @since 4.5
134 *
135 * Raw translation from a message catalog.
136 * If catalog name is null or empty,
137 * all loaded catalogs are searched for the translation.
138 *
139 * Never use this directly to get message translations. See the i18n and ki18n
140 * family of calls related to KLocalizedString.
141 *
142 * @param catname the catalog name. Must be UTF-8 encoded.
143 * @param msg the message. Must not be null or empty. Must be UTF-8 encoded.
144 * @param lang language in which the translation was found. If no translation
145 * was found, KLocale::defaultLanguage() is reported. If null,
146 * the language is not reported.
147 * @param trans raw translation, or original if not found. If no translation
148 * was found, original message is reported. If null, the
149 * translation is not reported.
150 *
151 * @see KLocalizedString
152 */
153 void translateRawFrom(const char* catname, const char* msg, QString *lang, QString *trans) const;
154
155 /**
156 * Like translateRawFrom, with implicit lookup through all loaded catalogs.
157 *
158 * @deprecated Use translateRawFrom with null or empty catalog name.
159 */
160 void translateRaw(const char* msg, QString *lang, QString *trans) const;
161
162 /**
163 * @since 4.5
164 *
165 * Raw translation from a message catalog, with given context.
166 * Context + message are used as the lookup key in the catalog.
167 * If catalog name is null or empty,
168 * all loaded catalogs are searched for the translation.
169 *
170 * Never use this directly to get message translations. See i18n* and ki18n*
171 * calls related to KLocalizedString.
172 *
173 * @param catname the catalog name. Must be UTF-8 encoded.
174 * @param ctxt the context. Must not be null. Must be UTF-8 encoded.
175 * @param msg the message. Must not be null or empty. Must be UTF-8 encoded.
176 * @param lang language in which the translation was found. If no translation
177 * was found, KLocale::defaultLanguage() is reported. If null,
178 * the language is not reported.
179 * @param trans raw translation, or original if not found. If no translation
180 * was found, original message is reported. If null, the
181 * translation is not reported.
182 *
183 * @see KLocalizedString
184 */
185 void translateRawFrom(const char *catname, const char *ctxt, const char *msg, QString *lang, QString *trans) const;
186
187 /**
188 * Like translateRawFrom, with implicit lookup through all loaded catalogs.
189 *
190 * @deprecated Use translateRawFrom with null or empty catalog name.
191 */
192 void translateRaw(const char *ctxt, const char *msg, QString *lang, QString *trans) const;
193
194 /**
195 * @since 4.5
196 *
197 * Raw translation from a message catalog, with given singular/plural form.
198 * Singular form is used as the lookup key in the catalog.
199 * If catalog name is null or empty,
200 * all loaded catalogs are searched for the translation.
201 *
202 * Never use this directly to get message translations. See i18n* and ki18n*
203 * calls related to KLocalizedString.
204 *
205 * @param catname the catalog name. Must be UTF-8 encoded.
206 * @param singular the singular form. Must not be null or empty. Must be UTF-8 encoded.
207 * @param plural the plural form. Must not be null. Must be UTF-8 encoded.
208 * @param n number on which the forms are decided.
209 * @param lang language in which the translation was found. If no translation
210 * was found, KLocale::defaultLanguage() is reported. If null,
211 * the language is not reported.
212 * @param trans raw translation, or original if not found. If no translation
213 * was found, original message is reported (either plural or
214 * singular, as determined by @p n ). If null, the
215 * translation is not reported.
216 *
217 * @see KLocalizedString
218 */
219 void translateRawFrom(const char *catname, const char *singular, const char *plural, unsigned long n,
220 QString *lang, QString *trans) const;
221
222 /**
223 * Like translateRawFrom, with implicit lookup through all loaded catalogs.
224 *
225 * @deprecated Use translateRawFrom with null or empty catalog name.
226 */
227 void translateRaw(const char *singular, const char *plural, unsigned long n, QString *lang,
228 QString *trans) const;
229
230 /**
231 * @since 4.5
232 *
233 * Raw translation from a message catalog, with given context and
234 * singular/plural form.
235 * Context + singular form is used as the lookup key in the catalog.
236 * If catalog name is null or empty,
237 * all loaded catalogs are searched for the translation.
238 *
239 * Never use this directly to get message translations. See i18n* and ki18n*
240 * calls related to KLocalizedString.
241 *
242 * @param catname the catalog name. Must be UTF-8 encoded.
243 * @param ctxt the context. Must not be null. Must be UTF-8 encoded.
244 * @param singular the singular form. Must not be null or empty. Must be UTF-8 encoded.
245 * @param plural the plural form. Must not be null. Must be UTF-8 encoded.
246 * @param n number on which the forms are decided.
247 * @param lang language in which the translation was found. If no translation
248 * was found, KLocale::defaultLanguage() is reported. If null,
249 * the language is not reported.
250 * @param trans raw translation, or original if not found. If no translation
251 * was found, original message is reported (either plural or
252 * singular, as determined by @p n ). If null, the
253 * translation is not reported.
254 *
255 * @see KLocalizedString
256 */
257 void translateRawFrom(const char *catname, const char *ctxt, const char *singular, const char *plural,
258 unsigned long n, QString *lang, QString *trans) const;
259
260 /**
261 * Like translateRawFrom, with implicit lookup through all loaded catalogs.
262 *
263 * @deprecated Use translateRawFrom with null or empty catalog name.
264 */
265 void translateRaw(const char *ctxt, const char *singular, const char *plural, unsigned long n,
266 QString *lang, QString *trans) const;
267
268 /**
269 * Changes the current encoding.
270 *
271 * @param mibEnum The mib of the preferred codec
272 *
273 * @return True on success.
274 */
275 bool setEncoding(int mibEnum);
276
277 /**
278 * Various positions for where to place the positive or negative
279 * sign when they are related to a monetary value.
280 */
281 enum SignPosition {
282 /**
283 * Put parantheses around the quantity, e.g. "$ (217)"
284 */
285 ParensAround = 0,
286 /**
287 * Prefix the quantity with the sign, e.g. "$ -217"
288 */
289 BeforeQuantityMoney = 1,
290 /**
291 * Suffix the quanitity with the sign, e.g. "$ 217-"
292 */
293 AfterQuantityMoney = 2,
294 /**
295 * Prefix the currency symbol with the sign, e.g. "-$ 217"
296 */
297 BeforeMoney = 3,
298 /**
299 * Suffix the currency symbol with the sign, e.g. "$- 217"
300 */
301 AfterMoney = 4
302 };
303
304 /**
305 * @since 4.3
306 *
307 * The set of digit characters used to display and enter numbers.
308 */
309 enum DigitSet {
310 ArabicDigits, /**< 0123456789 (European and some Asian
311 languages and western Arabic dialects) */
312 ArabicIndicDigits, /**< ٠١٢٣٤٥٦٧٨٩ (eastern Arabic dialects) */
313 EasternArabicIndicDigits, /**< ۰۱۲۳۴۵۶۷۸۹ (Persian and Urdu) */
314 DevenagariDigits, /**< ०१२३४५६७८९ (Hindi) */
315 BengaliDigits, /**< ০১২৩৪৫৬৭৮৯ (Bengali and Assamese) */
316 GujaratiDigits, /**< ૦૧૨૩૪૫૬૭૮૯ (Gujarati) */
317 GurmukhiDigits, /**< ੦੧੨੩੪੫੬੭੮੯ (Punjabi) */
318 KannadaDigits, /**< ೦೧೨೩೪೫೬೭೮೯ (Kannada) */
319 KhmerDigits, /**< ០១២៣៤៥៦៧៨៩ (Khmer) */
320 MalayalamDigits, /**< ൦൧൨൩൪൫൬൭൮൯ (Malayalam) */
321 OriyaDigits, /**< ୦୧୨୩୪୫୬୭୮୯ (Oriya) */
322 TamilDigits, /**< ௦௧௨௩௪௫௬௭௮ (Tamil) */
323 TeluguDigits, /**< ౦౧౨౩౪౫౬౭౯ (Telugu) */
324 ThaiDigits /**< ๐๑๒๓๔๕๖๗๘๙ (Thai) */
325 // The following Decimal Digit Sets are defined in Unicode but the associated
326 // languages are not yet translated in KDE, so are not yet enabled.
327 // The script names are taken from the Unicode standard, the associated
328 // languages from Wikipedia.
329 // BalineseDigits, /**< ᭐᭑᭒᭓᭔᭕᭖᭗᭘᭙ (Balinese) */
330 // ChamDigits, /**< ꩐꩑꩒꩓꩔꩕꩖꩗꩘꩙ (Cham) */
331 // JavaneseDigits, /**< ꧐꧑꧒꧓꧔꧕꧖꧗꧘꧙ (Javanese) */
332 // KayahLiDigits, /**< ꤀꤁꤂꤃꤄꤅꤆꤇꤈꤉ (Kayah) */
333 // LaoDigits, /**< ໐໑໒໓໔໕໖໗໘໙ (Lao) */
334 // LepchaDigits, /**< ᱀᱁᱂᱃᱄᱅᱆᱇᱈᱉ (Lepcha) */
335 // LimbuDigits, /**< ᥆᥇᥈᥉᥊᥋᥌᥍᥎᥏ (Limbu) */
336 // MeeteiMayekDigits, /**< ꯰꯱꯲꯳꯴꯵꯶꯷꯸꯹ (Meitei) */
337 // MongolianDigits, /**< ᠐᠑᠒᠓᠔᠕᠖᠗᠘᠙ (Mongolian) */
338 // MyanmarDigits, /**< ၀၁၂၃၄၅၆၇၈၉ (Myanmar/Burmese ) */
339 // MyanmarShanDigits, /**< ႐႑႒႓႔႕႖႗႘႙ (Shan) */
340 // NewTaiLueDigits, /**< ᧐᧑᧒᧓᧔᧕᧖᧗᧘᧙ (Tai Lü) */
341 // NKoDigits, /**< ߀߁߂߃߄߅߆߇߈߉ (Mande and N'Ko) */
342 // OlChikiDigits, /**< ᱐᱑᱒᱓᱔᱕᱖᱗᱘᱙ (Santali) */
343 // OsmanyaDigits, /**< ҠҡҢңҤҥҦҧҨҩ (Somali) */
344 // SaurashtraDigits, /**< ꣐꣑꣒꣓꣔꣕꣖꣗꣘꣙ (Saurashtra) */
345 // SundaneseDigits, /**< ᮰᮱᮲᮳᮴᮵᮶᮷᮸᮹ (Sundanese) */
346 // TaiThamDigits, /**< ᪐᪑᪒᪓᪔᪕᪖᪗᪘᪙ (Tai Lü) */
347 // TibetanDigits, /**< ༠༡༢༣༤༥༦༧༨༩ (Tibetan) */
348 // VaiDigits, /**< ꘠꘡꘢꘣꘤꘥꘦꘧꘨꘩ (Vai) */
349 };
350
351 /**
352 * @since 4.3
353 *
354 * Convert a digit set identifier to a human readable, localized name.
355 *
356 * @param digitSet the digit set identifier
357 * @param withDigits whether to add the digits themselves to the name
358 *
359 * @return the human readable and localized name of the digit set
360 *
361 * @see DigitSet
362 */
363 QString digitSetToName(DigitSet digitSet, bool withDigits = false) const;
364
365 /**
366 * @since 4.3
367 *
368 * Provides list of all known digit set identifiers.
369 *
370 * @return list of all digit set identifiers
371 * @see DigitSet
372 * @see digitSetToName
373 */
374 QList<DigitSet> allDigitSetsList() const;
375
376 /**
377 * Returns what a decimal point should look like ("." or "," etc.)
378 * according to the current locale or user settings.
379 *
380 * @return The decimal symbol used by locale.
381 */
382 QString decimalSymbol() const;
383
384 /**
385 * Returns what the thousands separator should look
386 * like ("," or "." etc.)
387 * according to the current locale or user settings.
388 *
389 * @return The thousands separator used by locale.
390 */
391 QString thousandsSeparator() const;
392
393 /**
394 * @since 4.3
395 *
396 * Returns the identifier of the digit set used to display numbers.
397 *
398 * @return the digit set identifier
399 * @see DigitSet
400 * @see digitSetToName
401 */
402 DigitSet digitSet() const;
403
404 /**
405 * @since 4.4
406 *
407 * Returns the ISO 4217 Currency Code for the current locale
408 *
409 * @return The default ISO Currency Code used by locale.
410 */
411 QString currencyCode() const;
412
413 /**
414 * @since 4.4
415 *
416 * Returns the Currency Code object for the current locale
417 *
418 * @return The default Currency Code object used by locale.
419 */
420 KCurrencyCode *currency() const;
421
422 /**
423 * Returns what the symbol denoting currency in the current locale
424 * as as defined by user settings should look like.
425 *
426 * @return The default currency symbol used by locale.
427 */
428 QString currencySymbol() const;
429
430 /**
431 * Returns what a decimal point should look like ("." or "," etc.)
432 * for monetary values, according to the current locale or user
433 * settings.
434 *
435 * @return The monetary decimal symbol used by locale.
436 */
437 QString monetaryDecimalSymbol() const;
438
439 /**
440 * Returns what a thousands separator for monetary values should
441 * look like ("," or " " etc.) according to the current locale or
442 * user settings.
443 *
444 * @return The monetary thousands separator used by locale.
445 */
446 QString monetaryThousandsSeparator() const;
447
448 /**
449 * Returns what a positive sign should look like ("+", " ", etc.)
450 * according to the current locale or user settings.
451 *
452 * @return The positive sign used by locale.
453 */
454 QString positiveSign() const;
455
456 /**
457 * Returns what a negative sign should look like ("-", etc.)
458 * according to the current locale or user settings.
459 *
460 * @return The negative sign used by locale.
461 */
462 QString negativeSign() const;
463
464 /**
465 * @deprecated use decimalPlaces() or monetaryDecimalPlaces()
466 *
467 * The number of fractional digits to include in monetary values (usually 2).
468 *
469 * @return Default number of fractional digits used by locale.
470 */
471 KDE_DEPRECATED int fracDigits() const;
472
473 /**
474 * @since 4.4
475 *
476 * The number of decimal places to include in numeric values (usually 2).
477 *
478 * @return Default number of numeric decimal places used by locale.
479 */
480 int decimalPlaces() const;
481
482 /**
483 * @since 4.4
484 *
485 * The number of decimal places to include in monetary values (usually 2).
486 *
487 * @return Default number of monetary decimal places used by locale.
488 */
489 int monetaryDecimalPlaces() const;
490
491 /**
492 * If and only if the currency symbol precedes a positive value,
493 * this will be true.
494 *
495 * @return Where to print the currency symbol for positive numbers.
496 */
497 bool positivePrefixCurrencySymbol() const;
498
499 /**
500 * If and only if the currency symbol precedes a negative value,
501 * this will be true.
502 *
503 * @return True if the currency symbol precedes negative numbers.
504 */
505 bool negativePrefixCurrencySymbol() const;
506
507 /**
508 * Returns the position of a positive sign in relation to a
509 * monetary value.
510 *
511 * @return Where/how to print the positive sign.
512 * @see SignPosition
513 */
514 SignPosition positiveMonetarySignPosition() const;
515
516 /**
517 * Denotes where to place a negative sign in relation to a
518 * monetary value.
519 *
520 * @return Where/how to print the negative sign.
521 * @see SignPosition
522 */
523 SignPosition negativeMonetarySignPosition() const;
524
525 /**
526 * @since 4.3
527 *
528 * Retuns the digit set used to display monetary values.
529 *
530 * @return the digit set identifier
531 * @see DigitSet
532 * @see digitSetToName
533 */
534 DigitSet monetaryDigitSet() const;
535
536 /**
537 * Given a double, converts that to a numeric string containing
538 * the localized monetary equivalent.
539 *
540 * e.g. given 123456, return "$ 123,456.00".
541 *
542 * If precision isn't specified or is < 0, then the default monetaryDecimalPlaces() is used.
543 *
544 * @param num The number we want to format
545 * @param currency The currency symbol you want.
546 * @param precision Number of decimal places displayed
547 *
548 * @return The number of money as a localized string
549 * @see monetaryDecimalPlaces()
550 */
551 QString formatMoney(double num, const QString &currency = QString(), int precision = -1) const;
552
553 /**
554 * Given a double, converts that to a numeric string containing
555 * the localized numeric equivalent.
556 *
557 * e.g. given 123456.78F, return "123,456.78" (for some European country).
558 *
559 * If precision isn't specified or is < 0, then the default decimalPlaces() is used.
560 *
561 * This function is a wrapper that is provided for convenience.
562 *
563 * @param num The number to convert
564 * @param precision Number of decimal places used.
565 *
566 * @return The number as a localized string
567 * @see formatNumber(const QString, bool, int)
568 * @see decimalPlaces()
569 */
570 QString formatNumber(double num, int precision = -1) const;
571
572 /**
573 * Given a string representing a number, converts that to a numeric
574 * string containing the localized numeric equivalent.
575 *
576 * e.g. given 123456.78F, return "123,456.78" (for some European country).
577 *
578 * If precision isn't specified or is < 0, then the default decimalPlaces() is used.
579 *
580 * @param numStr The number to format, as a string.
581 * @param round Round fractional digits. (default true)
582 * @param precision Number of fractional digits used for rounding. Unused if round=false.
583 *
584 * @return The number as a localized string
585 */
586 QString formatNumber(const QString &numStr, bool round = true, int precision = -1) const;
587
588 /**
589 * Given an integer, converts that to a numeric string containing
590 * the localized numeric equivalent.
591 *
592 * e.g. given 123456L, return "123,456" (for some European country).
593 *
594 * @param num The number to convert
595 *
596 * @return The number as a localized string
597 */
598 QString formatLong(long num) const;
599
600 /**
601 * These binary units are used in KDE by the formatByteSize()
602 * functions.
603 *
604 * NOTE: There are several different units standards:
605 * 1) SI (i.e. metric), powers-of-10.
606 * 2) IEC, powers-of-2, with specific units KiB, MiB, etc.
607 * 3) JEDEC, powers-of-2, used for solid state memory sizing which
608 * is why you see flash cards labels as e.g. 4GB. These (ab)use
609 * the metric units. Although JEDEC only defines KB, MB, GB, if
610 * JEDEC is selected all units will be powers-of-2 with metric
611 * prefixes for clarity in the event of sizes larger than 1024 GB.
612 *
613 * Although 3 different dialects are possible this enum only uses
614 * metric names since adding all 3 different names of essentially the same
615 * unit would be pointless. Use BinaryUnitDialect to control the exact
616 * units returned.
617 *
618 * @since 4.4
619 * @see binaryUnitDialect
620 */
621 enum BinarySizeUnits {
622 /// Auto-choose a unit such that the result is in the range [0, 1000 or 1024)
623 DefaultBinaryUnits = -1,
624
625 // The first real unit must be 0 for the current implementation!
626 UnitByte, ///< B 1 byte
627 UnitKiloByte, ///< KiB/KB/kB 1024/1000 bytes.
628 UnitMegaByte, ///< MiB/MB/MB 2^20/10^06 bytes.
629 UnitGigaByte, ///< GiB/GB/GB 2^30/10^09 bytes.
630 UnitTeraByte, ///< TiB/TB/TB 2^40/10^12 bytes.
631 UnitPetaByte, ///< PiB/PB/PB 2^50/10^15 bytes.
632 UnitExaByte, ///< EiB/EB/EB 2^60/10^18 bytes.
633 UnitZettaByte, ///< ZiB/ZB/ZB 2^70/10^21 bytes.
634 UnitYottaByte, ///< YiB/YB/YB 2^80/10^24 bytes.
635 UnitLastUnit = UnitYottaByte
636 };
637
638 /**
639 * This enum chooses what dialect is used for binary units.
640 *
641 * Note: Although JEDEC abuses the metric prefixes and can therefore be
642 * confusing, it has been used to describe *memory* sizes for quite some time
643 * and programs should therefore use either Default, JEDEC, or IEC 60027-2
644 * for memory sizes.
645 *
646 * On the other hand network transmission rates are typically in metric so
647 * Default, Metric, or IEC (which is unambiguous) should be chosen.
648 *
649 * Normally choosing DefaultBinaryDialect is the best option as that uses
650 * the user's selection for units.
651 *
652 * @since 4.4
653 * @see binaryUnitDialect
654 * @see setBinaryUnitDialect
655 */
656 enum BinaryUnitDialect {
657 DefaultBinaryDialect = -1, ///< Used if no specific preference
658 IECBinaryDialect, ///< KDE Default, KiB, MiB, etc. 2^(10*n)
659 JEDECBinaryDialect, ///< KDE 3.5 default, KB, MB, etc. 2^(10*n)
660 MetricBinaryDialect, ///< SI Units, kB, MB, etc. 10^(3*n)
661 LastBinaryDialect = MetricBinaryDialect
662 };
663
664 /**
665 * Converts @p size from bytes to the string representation using the
666 * user's default binary unit dialect. The default unit dialect is
667 * IEC 60027-2.
668 *
669 * Example:
670 * formatByteSize(1024) returns "1.0 KiB" by default.
671 *
672 * @param size size in bytes
673 * @return converted size as a string - e.g. 123.4 KiB , 12.0 MiB
674 * @see BinaryUnitDialect
675 * @todo KDE 5: Remove in favor of overload added in KDE 4.4.
676 */
677 QString formatByteSize(double size) const;
678
679 /**
680 * @since 4.4
681 *
682 * Converts @p size from bytes to the appropriate string representation
683 * using the binary unit dialect @p dialect and the specific units @p specificUnit.
684 *
685 * Example:
686 * formatByteSize(1000, unit, KLocale::UnitKiloByte) returns:
687 * for KLocale::MetricBinaryDialect, "1.0 kB",
688 * for KLocale::IECBinaryDialect, "0.9 KiB",
689 * for KLocale::JEDECBinaryDialect, "0.9 KB".
690 *
691 * @param size size in bytes
692 * @param precision number of places after the decimal point to use. KDE uses
693 * 1 by default so when in doubt use 1.
694 * @param dialect binary unit standard to use. Use DefaultBinaryDialect to
695 * use the localized user selection unless you need to use a specific
696 * unit type (such as displaying a flash memory size in JEDEC).
697 * @param specificUnit specific unit size to use in result. Use
698 * DefaultBinaryUnits to automatically select a unit that will return
699 * a sanely-sized number.
700 * @return converted size as a translated string including the units.
701 * E.g. "1.23 KiB", "2 GB" (JEDEC), "4.2 kB" (Metric).
702 * @see BinaryUnitDialect
703 */
704 QString formatByteSize(double size, int precision,
705 BinaryUnitDialect dialect = KLocale::DefaultBinaryDialect,
706 BinarySizeUnits specificUnit = KLocale::DefaultBinaryUnits) const;
707
708 /**
709 * Returns the user's configured binary unit dialect.
710 * e.g. if MetricBinaryDialect is returned then the values
711 * configured for how much a set of bytes are worth would
712 * be 10^(3*n) and KB (1000 bytes == 1 KB), in this case.
713 *
714 * Will never return DefaultBinaryDialect.
715 *
716 * @since 4.4
717 * @return User's configured binary unit dialect
718 * @see BinaryUnitDialect
719 */
720 BinaryUnitDialect binaryUnitDialect() const;
721
722 /**
723 * Sets @p newDialect to be the default dialect for this locale (and only
724 * this locale). Newly created KLocale objects will continue to default
725 * to the user's choice.
726 *
727 * @param newDialect the new dialect to set as default for this locale object.
728 * @since 4.4
729 */
730 void setBinaryUnitDialect(BinaryUnitDialect newDialect);
731
732 /**
733 * Given a number of milliseconds, converts that to a string containing
734 * the localized equivalent
735 *
736 * e.g. given formatDuration(60000), returns "1.0 minutes"
737 *
738 * @param mSec Time duration in milliseconds
739 * @return converted duration as a string - e.g. "5.5 seconds" "23.0 minutes"
740 */
741 QString formatDuration(unsigned long mSec) const;
742
743 /**
744 * Given a number of milliseconds, converts that to a pretty string containing
745 * the localized equivalent.
746 *
747 * e.g. given prettyFormatDuration(60001) returns "1 minute"
748 * given prettyFormatDuration(62005) returns "1 minute and 2 seconds"
749 * given prettyFormatDuration(90060000) returns "1 day and 1 hour"
750 *
751 * @param mSec Time duration in milliseconds
752 * @return converted duration as a string.
753 * Units not interesting to the user, for example seconds or minutes when the first
754 * unit is day, are not returned because they are irrelevant. The same applies for
755 * seconds when the first unit is hour.
756 * @since 4.2
757 */
758 QString prettyFormatDuration(unsigned long mSec) const;
759
760 /**
761 * @deprecated
762 *
763 * Use this to determine whether nouns are declined in
764 * locale's language. This property should remain
765 * read-only (no setter function)
766 *
767 * @return If nouns are declined
768 */
769 KDE_DEPRECATED bool nounDeclension() const;
770
771 //KDE5 move to KDateTime namespace
772 /**
773 * @since 4.6
774 *
775 * Available Calendar Systems
776 *
777 * @see setCalendarSystem()
778 * @see calendarSystem()
779 */
780 enum CalendarSystem {
781 QDateCalendar = 1, /**< KDE Default, hybrid of Gregorian and Julian as used by QDate */
782 //BahaiCalendar = 2, /**< Baha'i Calendar */
783 //BuddhistLunarCalendar = 3, /**< Buddhist Lunar Calendar*/
784 //ChineseCalendar = 4, /**< Chinese Calendar */
785 CopticCalendar = 5, /**< Coptic Calendar as used Coptic Church and some parts of Egypt */
786 EthiopianCalendar = 6, /**< Ethiopian Calendar, aka Ethiopic Calendar */
787 //EthiopianAmeteAlemCalendar = 7, /**< Ethiopian Amete Alem version, aka Ethiopic Amete Alem */
788 GregorianCalendar = 8, /**< Gregorian Calendar, pure proleptic implementation */
789 HebrewCalendar = 9, /**< Hebrew Calendar, aka Jewish Calendar */
790 //HinduCalendar = 10, /**< Hindu Lunar Calendar */
791 //IslamicLunarCalendar = 11, /**< Islamic Lunar Calendar */
792 IslamicCivilCalendar = 12, /**< Islamic Civil Calendar, aka Hijri, not the Lunar Calendar */
793 //IslamicUmAlQuraCalendar = 13, /**< Islamic Lunar Calendar, Um Al Qura varient used in Saudi Arabia */
794 IndianNationalCalendar = 14, /**< Indian National Calendar, not the Lunar Calendar */
795 //Iso8601Calendar = 15, /**< ISO 8601 Standard Calendar */
796 JalaliCalendar = 16, /**< Jalali Calendar, aka Persian or Iranian, also used in Afghanistan */
797 //JalaliBirashkCalendar = 17, /**< Jalali Calendar, Birashk Algorythm variant */
798 //Jalali33YearCalendar = 18, /**< Jalali Calendar, 33 Year cycle variant */
799 JapaneseCalendar= 19, /**< Japanese Calendar, Gregorian calculation using Japanese Era (Nengô) */
800 //JucheCalendar = 20, /**< Juche Calendar, used in North Korea */
801 JulianCalendar = 21, /**< Julian Calendar, as used in Orthodox Churches */
802 MinguoCalendar= 22, /**< Minguo Calendar, aka ROC, Republic of China or Taiwanese */
803 ThaiCalendar = 23 /**< Thai Calendar, aka Buddhist or Thai Buddhist */
804 };
805
806 //KDE5 move to KDateTime namespace
807 /**
808 * @since 4.6
809 *
810 * System used for Week Numbers
811 *
812 * @see setWeekNumberSystem()
813 * @see weekNumberSystem()
814 */
815 enum WeekNumberSystem {
816 DefaultWeekNumber = -1, /**< The system locale default */
817 IsoWeekNumber = 0, /**< ISO Week Number */
818 FirstFullWeek = 1, /**< Week 1 starts on the first Week Start Day in year ends after 7 days */
819 FirstPartialWeek = 2, /**< Week 1 starts Jan 1st ends day before first Week Start Day in year */
820 SimpleWeek = 3 /**< Week 1 starts Jan 1st ends after 7 days */
821 };
822
823 //KDE5 move to KDateTime namespace
824 /**
825 * @since 4.4
826 *
827 * Standard used for Date Time Format String
828 */
829 enum DateTimeFormatStandard {
830 KdeFormat, /**< KDE Standard */
831 PosixFormat, /**< POSIX Standard */
832 UnicodeFormat /**< UNICODE Standard (Qt/Java/OSX/Windows) */
833 };
834
835 //KDE5 move to KDateTime namespace
836 /**
837 * @since 4.6
838 *
839 * Mode to use when parsing a Date Time input string
840 */
841 enum DateTimeParseMode {
842 LiberalParsing /**< Parse Date/Time liberally. So long as the
843 input string contains at least a reconizable
844 month and day the input will be accepted. */
845 //ModerateParsing, /**< Parse Date/Time with modeate tolerance.
846 // The date components in the format must all
847 // occur in the input and in the same order,
848 // but the spacing and the componants themselves
849 // may vary from the strict format. */
850 //StrictParsing /**< Parse Date/Time strictly to the format. */
851 };
852
853 //KDE5 move to KDateTime namespace
854 /**
855 * @since 4.6
856 *
857 * The various Components that make up a Date / Time
858 * In the future the Components may be combined as flags for dynamic
859 * generation of Date Formats.
860 *
861 * @see KCalendarSystem
862 * @see KLocalizedDate
863 * @see DateTimeComponentFormat
864 */
865 enum DateTimeComponent {
866 Year = 0x1, /**< The Year portion of a date, may be number or name */
867 YearName = 0x2, /**< The Year Name portion of a date */
868 Month = 0x4, /**< The Month portion of a date, may be number or name */
869 MonthName = 0x8, /**< The Month Name portion of a date */
870 Day = 0x10, /**< The Day portion of a date, may be number or name */
871 DayName = 0x20, /**< The Day Name portion of a date */
872 JulianDay = 0x40, /**< The Julian Day of a date */
873 EraName = 0x80, /**< The Era Name portion of a date */
874 EraYear = 0x100, /**< The Era and Year portion of a date */
875 YearInEra = 0x200, /**< The Year In Era portion of a date */
876 DayOfYear = 0x400, /**< The Day Of Year portion of a date, may be number or name */
877 DayOfYearName = 0x800, /**< The Day Of Year Name portion of a date */
878 DayOfWeek = 0x1000, /**< The Day Of Week / Weekday portion of a date, may be number or name */
879 DayOfWeekName = 0x2000, /**< The Day Of Week Name / Weekday Name portion of a date */
880 Week = 0x4000, /**< The Week Number portion of a date */
881 WeekYear = 0x8000, /**< The Week Year portion of a date */
882 MonthsInYear = 0x10000, /**< The Months In Year portion of a date */
883 WeeksInYear = 0x20000, /**< The Weeks In Year portion of a date */
884 DaysInYear = 0x40000, /**< The Days In Year portion of a date */
885 DaysInMonth = 0x80000, /**< The Days In Month portion of a date */
886 DaysInWeek = 0x100000, /**< The Days In Week portion of a date */
887 Hour = 0x200000, /**< The Hours portion of a date */
888 Minute = 0x400000, /**< The Minutes portion of a date */
889 Second = 0x800000, /**< The Seconds portion of a date */
890 Millisecond = 0x1000000, /**< The Milliseconds portion of a date */
891 DayPeriod = 0x2000000, /**< The Day Period portion of a date, e.g. AM/PM */
892 DayPeriodHour = 0x4000000, /**< The Day Period Hour portion of a date */
893 Timezone = 0x8000000, /**< The Time Zone portion of a date, may be offset or name */
894 TimezoneName = 0x10000000, /**< The Time Zone Name portion of a date */
895 UnixTime = 0x20000000 /**< The UNIX Time portion of a date */
896 };
897 Q_DECLARE_FLAGS(DateTimeComponents, DateTimeComponent)
898
899 //KDE5 move to KDateTime namespace
900 /**
901 * @since 4.6
902 *
903 * Format used for individual Date/Time Components when converted to/from a string
904 * Largely equivalent to the UNICODE CLDR format width definitions 1..5
905 *
906 * @see DateTimeComponentFormat
907 */
908 enum DateTimeComponentFormat {
909 DefaultComponentFormat = -1, /**< The system locale default for the componant */
910 ShortNumber = 0, /**< Number at its natural width, e.g. 2 for the 2nd*/
911 LongNumber, /**< Number padded to a required width, e.g. 02 for the 2nd*/
912 //OrdinalNumber /**< Ordinal number format, e.g. "2nd" for the 2nd */
913 NarrowName = 3, /**< Narrow text format, may not be unique, e.g. M for Monday */
914 ShortName, /**< Short text format, e.g. Mon for Monday */
915 LongName /**< Long text format, e.g. Monday for Monday */
916 };
917
918 //KDE5 move to KDateTime namespace
919 /**
920 * Format for date string.
921 */
922 enum DateFormat {
923 ShortDate, /**< Locale Short date format, e.g. 08-04-2007 */
924 LongDate, /**< Locale Long date format, e.g. Sunday 08 April 2007 */
925 FancyShortDate, /**< Same as ShortDate for dates a week or more ago. For more
926 recent dates, it is represented as Today, Yesterday, or
927 the weekday name. */
928 FancyLongDate, /**< Same as LongDate for dates a week or more ago. For more
929 recent dates, it is represented as Today, Yesterday, or
930 the weekday name. */
931 IsoDate, /**< ISO-8601 Date format YYYY-MM-DD, e.g. 2009-12-31 */
932 IsoWeekDate, /**< ISO-8601 Week Date format YYYY-Www-D, e.g. 2009-W01-1 */
933 IsoOrdinalDate /**< ISO-8601 Ordinal Date format YYYY-DDD, e.g. 2009-001 */
934 };
935
936 //KDE5 move to KDateTime namespace
937 /**
938 * Returns a string formatted to the current locale's conventions
939 * regarding dates.
940 *
941 * @param date the date to be formatted
942 * @param format category of date format to use
943 *
944 * @return the date as a string
945 */
946 QString formatDate(const QDate &date, DateFormat format = LongDate) const;
947
948 //KDE5 move to KDateTime namespace
949 /**
950 * Returns a string formatted to the current locale's conventions
951 * regarding both date and time.
952 *
953 * @param dateTime the date and time to be formatted
954 * @param format category of date format to use
955 * @param includeSecs if @c true, the string will include the seconds part
956 * of the time; otherwise, the seconds will be omitted
957 *
958 * @return the date and time as a string
959 */
960 QString formatDateTime(const QDateTime &dateTime, DateFormat format = ShortDate,
961 bool includeSecs = false) const;
962
963 //KDE5 move to KDateTime namespace
964 /**
965 * Options for formatting date-time values.
966 */
967 enum DateTimeFormatOption {
968 TimeZone = 0x01, /**< Include a time zone string */
969 Seconds = 0x02 /**< Include the seconds value */
970 };
971 Q_DECLARE_FLAGS(DateTimeFormatOptions, DateTimeFormatOption)
972
973 //KDE5 move to KDateTime namespace
974 /**
975 * Returns a string formatted to the current locale's conventions
976 * regarding both date and time.
977 *
978 * @param dateTime the date and time to be formatted
979 * @param format category of date format to use
980 * @param options additional output options
981 *
982 * @return The date and time as a string
983 */
984 QString formatDateTime(const KDateTime &dateTime, DateFormat format = ShortDate,
985 DateTimeFormatOptions options = 0) const;
986
987 /**
988 * Use this to determine whether in dates a possessive form of month
989 * name is preferred ("of January" rather than "January")
990 *
991 * @return If possessive form should be used
992 */
993 bool dateMonthNamePossessive() const;
994
995 /**
996 * @deprecated replaced by formatLocaleTime()
997 *
998 * Returns a string formatted to the current locale's conventions
999 * regarding times.
1000 *
1001 * @param pTime The time to be formatted.
1002 * @param includeSecs if true, seconds are included in the output,
1003 * otherwise only hours and minutes are formatted.
1004 * @param isDuration if true, the given time is a duration, not a clock time.
1005 * This means "am/pm" shouldn't be displayed.
1006 *
1007 * @return The time as a string
1008 */
1009 QString formatTime(const QTime &pTime, bool includeSecs = false, bool isDuration = false) const;
1010
1011 //KDE5 move to KDateTime namespace
1012 /**
1013 * @since 4.4
1014 *
1015 * Format flags for readLocaleTime() and formatLocaleTime()
1016 */
1017 enum TimeFormatOption {
1018 TimeDefault = 0x0, ///< Default formatting using seconds and the format
1019 ///< as specified by the locale.
1020 TimeWithoutSeconds = 0x1, ///< Exclude the seconds part of the time from display
1021 TimeWithoutAmPm = 0x2, ///< Read/format time string without am/pm suffix but
1022 ///< keep the 12/24h format as specified by locale time
1023 ///< format, eg. "07.33.05" instead of "07.33.05 pm" for
1024 ///< time format "%I.%M.%S %p".
1025 TimeDuration = 0x6, ///< Read/format time string as duration. This will strip
1026 ///< the am/pm suffix and read/format times with an hour
1027 ///< value of 0-23 hours, eg. "19.33.05" instead of
1028 ///< "07.33.05 pm" for time format "%I.%M.%S %p".
1029 ///< This automatically implies @c TimeWithoutAmPm.
1030 TimeFoldHours = 0xE ///< Read/format time string as duration. This will not
1031 ///< not output the hours part of the duration but will
1032 ///< add the hours (times sixty) to the number of minutes,
1033 ///< eg. "70.23" instead of "01.10.23" for time format
1034 ///< "%I.%M.%S %p".
1035 };
1036 Q_DECLARE_FLAGS(TimeFormatOptions, TimeFormatOption)
1037
1038 //KDE5 move to KDateTime namespace
1039 /**
1040 * @since 4.4
1041 *
1042 * Returns a string formatted to the current locale's conventions
1043 * regarding times.
1044 *
1045 * @param pTime the time to be formatted
1046 * @param options format option to use when formatting the time
1047 * @return The time as a string
1048 */
1049 QString formatLocaleTime(const QTime &pTime,
1050 TimeFormatOptions options = KLocale::TimeDefault) const;
1051
1052 /**
1053 * @since 4.3
1054 *
1055 * Returns the identifier of the digit set used to display dates and time.
1056 *
1057 * @return the digit set identifier
1058 * @see DigitSet
1059 * @see digitSetToName
1060 */
1061 DigitSet dateTimeDigitSet() const;
1062
1063 /**
1064 * Use this to determine if the user wants a 12 hour clock.
1065 *
1066 * @return If the user wants 12h clock
1067 */
1068 bool use12Clock() const;
1069
1070 /**
1071 * @since 4.6
1072 *
1073 * Returns the Day Period matching the time given
1074 *
1075 * @param time the time to return the day period for
1076 * @param format the format to return teh day period in
1077 * @return the Day Period for the given time
1078 */
1079 QString dayPeriodText(const QTime &time, DateTimeComponentFormat format = DefaultComponentFormat) const;
1080
1081 /**
1082 * Use this to determine which day is the first day of the week.
1083 *
1084 * @return an integer (Monday=1..Sunday=7)
1085 */
1086 int weekStartDay() const;
1087
1088 /**
1089 * Use this to determine which day is the first working day of the week.
1090 *
1091 * @since 4.2
1092 * @return an integer (Monday=1..Sunday=7)
1093 */
1094 int workingWeekStartDay() const;
1095
1096 /**
1097 * Use this to determine which day is the last working day of the week.
1098 *
1099 * @since 4.2
1100 * @return an integer (Monday=1..Sunday=7)
1101 */
1102 int workingWeekEndDay() const;
1103
1104 /**
1105 * Use this to determine which day is reserved for religious observance
1106 *
1107 * @since 4.2
1108 * @return day number (None = 0, Monday = 1, ..., Sunday = 7)
1109 */
1110 int weekDayOfPray() const;
1111
1112 /**
1113 * Returns a pointer to the calendar system object.
1114 *
1115 * @return the current calendar system instance
1116 */
1117 const KCalendarSystem * calendar() const;
1118
1119 //KDE5 remove
1120 /**
1121 * @deprecated use calendarSystem() instead
1122 *
1123 * Returns the name of the calendar system that is currently being
1124 * used by the system.
1125 *
1126 * @see calendarSystem()
1127 * @return the name of the calendar system
1128 */
1129 KDE_DEPRECATED QString calendarType() const;
1130
1131 /**
1132 * @since 4.6
1133 *
1134 * Returns the type of Calendar System used in this Locale
1135 *
1136 * @see KLocale::CalendarSystem
1137 * @see KCalendarSystem
1138 * @return the type of Calendar System
1139 */
1140 KLocale::CalendarSystem calendarSystem() const;
1141
1142 //KDE5 remove
1143 /**
1144 * @deprecated use setCalendarSystem() instead
1145 *
1146 * Changes the current calendar system to the calendar specified.
1147 * If the calendar system specified is not found, gregorian will be used.
1148 *
1149 * @see setCalendarSystem()
1150 * @param calendarType the name of the calendar type
1151 */
1152 KDE_DEPRECATED void setCalendar(const QString & calendarType);
1153
1154 /**
1155 * @since 4.6
1156 *
1157 * Sets the type of Calendar System to use in this Locale
1158 *
1159 * @see KLocale::CalendarSystem
1160 * @see KCalendarSystem
1161 * @param calendarSystem the Calendar System to use
1162 */
1163 void setCalendarSystem(KLocale::CalendarSystem calendarSystem);
1164
1165 /**
1166 * @since 4.6
1167 *
1168 * Sets the type of Week Number System to use in this Locale
1169 *
1170 * @see Klocale::WeekNumberSystem
1171 * @see weekNumberSystem()
1172 * @param weekNumberSystem the Week Number System to use
1173 */
1174 void setWeekNumberSystem(KLocale::WeekNumberSystem weekNumberSystem);
1175
1176 //KDE5 remove in favour of const version
1177 /**
1178 * @since 4.6
1179 *
1180 * Returns the type of Week Number System used in this Locale
1181 *
1182 * @see Klocale::WeekNumberSystem
1183 * @see setWeekNumberSystem()
1184 * @returns the Week Number System used
1185 */
1186 KLocale::WeekNumberSystem weekNumberSystem();
1187
1188 /**
1189 * @since 4.7
1190 *
1191 * Returns the type of Week Number System used in this Locale
1192 *
1193 * @see Klocale::WeekNumberSystem
1194 * @see setWeekNumberSystem()
1195 * @returns the Week Number System used
1196 */
1197 KLocale::WeekNumberSystem weekNumberSystem() const;
1198
1199 /**
1200 * Converts a localized monetary string to a double.
1201 *
1202 * @param numStr the string we want to convert.
1203 * @param ok the boolean that is set to false if it's not a number.
1204 * If @p ok is 0, it will be ignored
1205 *
1206 * @return The string converted to a double
1207 */
1208 double readMoney(const QString &numStr, bool * ok = 0) const;
1209
1210 /**
1211 * Converts a localized numeric string to a double.
1212 *
1213 * @param numStr the string we want to convert.
1214 * @param ok the boolean that is set to false if it's not a number.
1215 * If @p ok is 0, it will be ignored
1216 *
1217 * @return The string converted to a double
1218 */
1219 double readNumber(const QString &numStr, bool * ok = 0) const;
1220
1221 //KDE5 move to KDateTime namespace
1222 /**
1223 * Converts a localized date string to a QDate. This method will try all
1224 * ReadDateFlag formats in preferred order to read a valid date.
1225 *
1226 * The bool pointed by ok will be invalid if the date entered was not valid.
1227 *
1228 * @param str the string we want to convert.
1229 * @param ok the boolean that is set to false if it's not a valid date.
1230 * If @p ok is 0, it will be ignored
1231 *
1232 * @return The string converted to a QDate
1233 * @see KCalendarSystem::readDate()
1234 */
1235 QDate readDate(const QString &str, bool* ok = 0) const;
1236
1237 //KDE5 move to KDateTime namespace
1238 /**
1239 * Converts a localized date string to a QDate, using the specified format.
1240 * You will usually not want to use this method.
1241 * @see KCalendarSystem::readDate()
1242 */
1243 QDate readDate(const QString &intstr, const QString &fmt, bool* ok = 0) const;
1244
1245 //KDE5 move to KDateTime namespace
1246 /**
1247 * Flags for readDate()
1248 */
1249 enum ReadDateFlags {
1250 NormalFormat = 1, /**< Only accept a date string in
1251 the locale LongDate format */
1252 ShortFormat = 2, /**< Only accept a date string in
1253 the locale ShortDate format */
1254 IsoFormat = 4, /**< Only accept a date string in
1255 ISO date format (YYYY-MM-DD) */
1256 IsoWeekFormat = 8, /**< Only accept a date string in
1257 ISO Week date format (YYYY-Www-D) */
1258 IsoOrdinalFormat = 16 /**< Only accept a date string in
1259 ISO Week date format (YYYY-DDD) */
1260 };
1261
1262 //KDE5 move to KDateTime namespace
1263 /**
1264 * Converts a localized date string to a QDate.
1265 * This method is stricter than readDate(str,&ok): it will only accept
1266 * a date in a specific format, depending on @p flags.
1267 *
1268 * @param str the string we want to convert.
1269 * @param flags what format the the date string will be in
1270 * @param ok the boolean that is set to false if it's not a valid date.
1271 * If @p ok is 0, it will be ignored
1272 *
1273 * @return The string converted to a QDate
1274 * @see KCalendarSystem::readDate()
1275 */
1276 QDate readDate(const QString &str, ReadDateFlags flags, bool *ok = 0) const;
1277
1278 /**
1279 * Converts a localized time string to a QTime.
1280 * This method will try to parse it with seconds, then without seconds.
1281 * The bool pointed to by @p ok will be set to false if the time entered was
1282 * not valid.
1283 *
1284 * @param str the string we want to convert.
1285 * @param ok the boolean that is set to false if it's not a valid time.
1286 * If @p ok is 0, it will be ignored
1287 *
1288 * @return The string converted to a QTime
1289 */
1290 QTime readTime(const QString &str, bool* ok = 0) const;
1291
1292 /**
1293 * Flags for the old version of readTime()
1294 *
1295 * @deprecated replaced by TimeFormatOptions
1296 */
1297 enum ReadTimeFlags {
1298 WithSeconds = 0, ///< Only accept a time string with seconds. Default (no flag set)
1299 WithoutSeconds = 1 ///< Only accept a time string without seconds.
1300 }; // (maybe use this enum as a bitfield, if adding independent features?)
1301
1302 /**
1303 * @deprecated replaced readLocaleTime()
1304 *
1305 * Converts a localized time string to a QTime.
1306 * This method is stricter than readTime(str,&ok): it will either accept
1307 * a time with seconds or a time without seconds.
1308 * Use this method when the format is known by the application.
1309 *
1310 * @param str the string we want to convert.
1311 * @param flags whether the time string is expected to contain seconds or not.
1312 * @param ok the boolean that is set to false if it's not a valid time.
1313 * If @p ok is 0, it will be ignored
1314 *
1315 * @return The string converted to a QTime
1316 */
1317 QTime readTime(const QString &str, ReadTimeFlags flags, bool *ok = 0) const;
1318
1319 /**
1320 * Additional processing options for readLocaleTime().
1321 *
1322 * @remarks This is currently used as an enum but declared as a flag
1323 * to be extensible
1324 */
1325 enum TimeProcessingOption {
1326 ProcessStrict = 0x1, ///< Process time in a strict manner, ie.
1327 ///< a read time string has to exactly match
1328 ///< the defined time format.
1329 ProcessNonStrict = 0x2 ///< Process time in a lax manner, ie.
1330 ///< allow spaces in the time-format to be
1331 ///< left out when entering a time string.
1332 };
1333 Q_DECLARE_FLAGS(TimeProcessingOptions, TimeProcessingOption)
1334
1335 /**
1336 * @since 4.4
1337 *
1338 * Converts a localized time string to a QTime.
1339 * This method is stricter than readTime(str, &ok) in that it will either
1340 * accept a time with seconds or a time without seconds.
1341 *
1342 * @param str the string we want to convert
1343 * @param ok the boolean that is set to false if it's not a valid time.
1344 * If @p ok is 0, it will be ignored.
1345 * @param options format option to apply when formatting the time
1346 * @param processing if set to @c ProcessStrict, checking will be strict
1347 * and the read time string has to have the exact time format
1348 * specified. If set to @c ProcessNonStrict processing the time
1349 * is lax and spaces in the time string can be left out.
1350 *
1351 * @return The string converted to a QTime
1352 */
1353 QTime readLocaleTime(const QString &str, bool *ok = 0,
1354 TimeFormatOptions options = KLocale::TimeDefault,
1355 TimeProcessingOptions processing = ProcessNonStrict) const;
1356
1357 /**
1358 * Returns the language code used by this object. The domain AND the
1359 * library translation must be available in this language.
1360 * defaultLanguage() is returned by default, if no other available.
1361 *
1362 * Use languageCodeToName(language) to get human readable, localized
1363 * language name.
1364 *
1365 * @return the currently used language code
1366 *
1367 * @see languageCodeToName
1368 */
1369 QString language() const;
1370
1371 /**
1372 * Returns the country code of the country where the user lives.
1373 *
1374 * The returned code complies with the ISO 3166-1 alpha-2 standard,
1375 * except by KDE convention it is returned in lowercase whereas the
1376 * official standard is uppercase.
1377 * See http://en.wikipedia.org/wiki/ISO_3166-1_alpha-2 for details.
1378 *
1379 * defaultCountry() is returned by default, if no other available,
1380 * this will always be uppercase 'C'.
1381 *
1382 * Use countryCodeToName(country) to get human readable, localized
1383 * country names.
1384 *
1385 * @return the country code for the user
1386 *
1387 * @see countryCodeToName
1388 */
1389 QString country() const;
1390
1391 /**
1392 * @since 4.6
1393 *
1394 * Returns the Country Division Code of the Country where the user lives.
1395 * When no value is set, then the Country Code will be returned.
1396 *
1397 * The returned code complies with the ISO 3166-2 standard.
1398 * See http://en.wikipedia.org/wiki/ISO_3166-2 for details.
1399 *
1400 * Note that unlike country() this method will return the correct case,
1401 * i.e. normally uppercase..
1402 *
1403 * In KDE 4.6 it is the apps responsibility to obtain a translation for the
1404 * code, translation and other services will be priovided in KDE 4.7.
1405 *
1406 * @return the Country Division Code for the user
1407 * @see setCountryDivisionCode
1408 */
1409 QString countryDivisionCode() const;
1410
1411 /**
1412 * Returns the language codes selected by user, ordered by decreasing
1413 * priority.
1414 *
1415 * Use languageCodeToName(language) to get human readable, localized
1416 * language name.
1417 *
1418 * @return list of language codes
1419 *
1420 * @see languageCodeToName
1421 */
1422 QStringList languageList() const;
1423
1424 /**
1425 * @since 4.4
1426 *
1427 * Returns the ISO Currency Codes used in the locale, ordered by decreasing
1428 * priority.
1429 *
1430 * Use KCurrency::currencyCodeToName(currencyCode) to get human readable,
1431 * localized language name.
1432 *
1433 * @return list of ISO Currency Codes
1434 *
1435 * @see currencyCodeToName
1436 */
1437 QStringList currencyCodeList() const;
1438
1439 /**
1440 * Returns the user's preferred encoding.
1441 *
1442 * @return The name of the preferred encoding
1443 *
1444 * @see codecForEncoding
1445 * @see encodingMib
1446 */
1447 const QByteArray encoding() const;
1448
1449 /**
1450 * Returns the user's preferred encoding.
1451 *
1452 * @return The Mib of the preferred encoding
1453 *
1454 * @see encoding
1455 * @see codecForEncoding
1456 */
1457 int encodingMib() const;
1458
1459 /**
1460 * Returns the user's preferred encoding. Should never be NULL.
1461 *
1462 * @return The codec for the preferred encoding
1463 *
1464 * @see encoding
1465 * @see encodingMib
1466 */
1467 QTextCodec * codecForEncoding() const;
1468
1469 /**
1470 * Returns the file encoding.
1471 *
1472 * @return The Mib of the file encoding
1473 *
1474 * @see QFile::encodeName
1475 * @see QFile::decodeName
1476 */
1477 int fileEncodingMib() const;
1478
1479 /**
1480 * Changes the current date format.
1481 *
1482 * The format of the date is a string which contains variables that will
1483 * be replaced:
1484 * @li %Y with the whole year (e.g. "2004" for "2004")
1485 * @li %y with the lower 2 digits of the year (e.g. "04" for "2004")
1486 * @li %n with the month (January="1", December="12")
1487 * @li %m with the month with two digits (January="01", December="12")
1488 * @li %e with the day of the month (e.g. "1" on the first of march)
1489 * @li %d with the day of the month with two digits (e.g. "01" on the first of march)
1490 * @li %b with the short form of the month (e.g. "Jan" for January)
1491 * @li %B with the long form of the month (e.g. "January")
1492 * @li %a with the short form of the weekday (e.g. "Wed" for Wednesday)
1493 * @li %A with the long form of the weekday (e.g. "Wednesday" for Wednesday)
1494 *
1495 * Everything else in the format string will be taken as is.
1496 * For example, March 20th 1989 with the format "%y:%m:%d" results
1497 * in "89:03:20".
1498 *
1499 * @param format The new date format
1500 */
1501 void setDateFormat(const QString & format);
1502
1503 /**
1504 * Changes the current short date format.
1505 *
1506 * The format of the date is a string which contains variables that will
1507 * be replaced:
1508 * @li %Y with the whole year (e.g. "1984" for "1984")
1509 * @li %y with the lower 2 digits of the year (e.g. "84" for "1984")
1510 * @li %n with the month (January="1", December="12")
1511 * @li %m with the month with two digits (January="01", December="12")
1512 * @li %e with the day of the month (e.g. "1" on the first of march)
1513 * @li %d with the day of the month with two digits(e.g. "01" on the first of march)
1514 * @li %b with the short form of the month (e.g. "Jan" for January)
1515 * @li %B with the long form of the month (e.g. "January")
1516 * @li %a with the short form of the weekday (e.g. "Wed" for Wednesday)
1517 * @li %A with the long form of the weekday (e.g. "Wednesday" for Wednesday)
1518 *
1519 * Everything else in the format string will be taken as is.
1520 * For example, March 20th 1989 with the format "%y:%m:%d" results
1521 * in "89:03:20".
1522 *
1523 * @param format The new short date format
1524 */
1525 void setDateFormatShort(const QString & format);
1526
1527 /**
1528 * Changes the form of month name used in dates.
1529 *
1530 * @param possessive True if possessive forms should be used
1531 */
1532 void setDateMonthNamePossessive(bool possessive);
1533
1534 /**
1535 * Changes the current time format.
1536 *
1537 * The format of the time is string a which contains variables that will
1538 * be replaced:
1539 * @li %H with the hour in 24h format and 2 digits (e.g. 5pm is "17", 5am is "05")
1540 * @li %k with the hour in 24h format and one digits (e.g. 5pm is "17", 5am is "5")
1541 * @li %I with the hour in 12h format and 2 digits (e.g. 5pm is "05", 5am is "05")
1542 * @li %l with the hour in 12h format and one digits (e.g. 5pm is "5", 5am is "5")
1543 * @li %M with the minute with 2 digits (e.g. the minute of 07:02:09 is "02")
1544 * @li %S with the seconds with 2 digits (e.g. the minute of 07:02:09 is "09")
1545 * @li %p with pm or am (e.g. 17.00 is "pm", 05.00 is "am")
1546 *
1547 * Everything else in the format string will be taken as is.
1548 * For example, 5.23pm with the format "%H:%M" results
1549 * in "17:23".
1550 *
1551 * @param format The new time format
1552 */
1553 void setTimeFormat(const QString & format);
1554
1555 /**
1556 * @since 4.3
1557 *
1558 * Set digit characters used to display dates and time.
1559 *
1560 * @param digitSet the digit set identifier
1561 * @see DigitSet
1562 */
1563 void setDateTimeDigitSet(DigitSet digitSet);
1564
1565 /**
1566 * Changes how KLocale defines the first day in week.
1567 *
1568 * @param day first day of the week (Monday=1..Sunday=7) as integer
1569 */
1570 void setWeekStartDay(int day);
1571
1572 /**
1573 * Changes how KLocale defines the first working day in week.
1574 *
1575 * @since 4.2
1576 * @param day first working day of the week (Monday=1..Sunday=7) as integer
1577 */
1578 void setWorkingWeekStartDay(int day);
1579
1580 /**
1581 * Changes how KLocale defines the last working day in week.
1582 *
1583 * @since 4.2
1584 * @param day last working day of the week (Monday=1..Sunday=7) as integer
1585 */
1586 void setWorkingWeekEndDay(int day);
1587
1588 /**
1589 * Changes how KLocale defines the day reserved for religious observance.
1590 *
1591 * @since 4.2
1592 * @param day day of the week for religious observance (None=0,Monday=1..Sunday=7) as integer
1593 */
1594 void setWeekDayOfPray(int day);
1595
1596 /**
1597 * Returns the currently selected date format.
1598 *
1599 * @return Current date format.
1600 * @see setDateFormat()
1601 */
1602 QString dateFormat() const;
1603
1604 /**
1605 * Returns the currently selected short date format.
1606 *
1607 * @return Current short date format.
1608 * @see setDateFormatShort()
1609 */
1610 QString dateFormatShort() const;
1611
1612 /**
1613 * Returns the currently selected time format.
1614 *
1615 * @return Current time format.
1616 * @see setTimeFormat()
1617 */
1618 QString timeFormat() const;
1619
1620 /**
1621 * Changes the symbol used to identify the decimal pointer.
1622 *
1623 * @param symbol The new decimal symbol.
1624 */
1625 void setDecimalSymbol(const QString & symbol);
1626
1627 /**
1628 * Changes the separator used to group digits when formating numbers.
1629 *
1630 * @param separator The new thousands separator.
1631 */
1632 void setThousandsSeparator(const QString & separator);
1633
1634 /**
1635 * Changes the sign used to identify a positive number. Normally this is
1636 * left blank.
1637 *
1638 * @param sign Sign used for positive numbers.
1639 */
1640 void setPositiveSign(const QString & sign);
1641
1642 /**
1643 * Changes the sign used to identify a negative number.
1644 *
1645 * @param sign Sign used for negative numbers.
1646 */
1647 void setNegativeSign(const QString & sign);
1648
1649 /**
1650 * @since 4.3
1651 *
1652 * Changes the set of digit characters used to display numbers.
1653 *
1654 * @param digitSet the digit set identifier
1655 * @see DigitSet
1656 */
1657 void setDigitSet(DigitSet digitSet);
1658
1659 /**
1660 * Changes the sign position used for positive monetary values.
1661 *
1662 * @param signpos The new sign position
1663 */
1664 void setPositiveMonetarySignPosition(SignPosition signpos);
1665
1666 /**
1667 * Changes the sign position used for negative monetary values.
1668 *
1669 * @param signpos The new sign position
1670 */
1671 void setNegativeMonetarySignPosition(SignPosition signpos);
1672
1673 /**
1674 * Changes the position where the currency symbol should be printed for
1675 * positive monetary values.
1676 *
1677 * @param prefix True if the currency symbol should be prefixed instead of
1678 * postfixed
1679 */
1680 void setPositivePrefixCurrencySymbol(bool prefix);
1681
1682 /**
1683 * Changes the position where the currency symbol should be printed for
1684 * negative monetary values.
1685 *
1686 * @param prefix True if the currency symbol should be prefixed instead of
1687 * postfixed
1688 */
1689 void setNegativePrefixCurrencySymbol(bool prefix);
1690
1691 /**
1692 * @deprecated use setDecimalPlaces() or setMonetaryDecimalPlaces()
1693 *
1694 * Changes the number of digits used when formating numbers.
1695 *
1696 * @param digits The default number of digits to use.
1697 */
1698 KDE_DEPRECATED void setFracDigits(int digits);
1699
1700 /**
1701 * @since 4.4
1702 *
1703 * Changes the number of decimal places used when formating numbers.
1704 *
1705 * @param digits The default number of digits to use.
1706 */
1707 void setDecimalPlaces(int digits);
1708
1709 /**
1710 * @since 4.4
1711 *
1712 * Changes the number of decimal places used when formating money.
1713 *
1714 * @param digits The default number of digits to use.
1715 */
1716 void setMonetaryDecimalPlaces(int digits);
1717
1718 /**
1719 * Changes the separator used to group digits when formating monetary values.
1720 *
1721 * @param separator The new thousands separator.
1722 */
1723 void setMonetaryThousandsSeparator(const QString & separator);
1724
1725 /**
1726 * Changes the symbol used to identify the decimal pointer for monetary
1727 * values.
1728 *
1729 * @param symbol The new decimal symbol.
1730 */
1731 void setMonetaryDecimalSymbol(const QString & symbol);
1732
1733 /**
1734 * @since 4.4
1735 *
1736 * Changes the current ISO Currency Code.
1737 *
1738 * @param newCurrencyCode The new Currency Code
1739 */
1740 void setCurrencyCode(const QString &newCurrencyCode);
1741
1742 /**
1743 * Changes the current currency symbol.
1744 *
1745 * This symbol should be consistant with the selected Currency Code
1746 *
1747 * @param symbol The new currency symbol
1748 * @see currencyCode, KCurrency::currencySymbols
1749 */
1750 void setCurrencySymbol(const QString & symbol);
1751
1752 /**
1753 * @since 4.3
1754 *
1755 * Set digit characters used to display monetary values.
1756 *
1757 * @param digitSet the digit set identifier
1758 * @see DigitSet
1759 */
1760 void setMonetaryDigitSet(DigitSet digitSet);
1761
1762 /**
1763 * Returns the preferred page size for printing.
1764 *
1765 * @return The preferred page size, cast it to QPrinter::PaperSize
1766 */
1767 int pageSize() const;
1768
1769 /**
1770 * Changes the preferred page size when printing.
1771 *
1772 * @param paperFormat the new preferred page size in the format QPrinter::PaperSize
1773 */
1774 void setPageSize(int paperFormat);
1775
1776 /**
1777 * The Metric system will give you information in mm, while the
1778 * Imperial system will give you information in inches.
1779 */
1780 enum MeasureSystem {
1781 Metric, ///< Metric system (used e.g. in Europe)
1782 Imperial ///< Imperial system (used e.g. in the United States)
1783 };
1784
1785 /**
1786 * Returns which measuring system we use.
1787 *
1788 * @return The preferred measuring system
1789 */
1790 MeasureSystem measureSystem() const;
1791
1792 /**
1793 * Changes the preferred measuring system.
1794 *
1795 * @return value The preferred measuring system
1796 */
1797 void setMeasureSystem(MeasureSystem value);
1798
1799 /**
1800 * Adds another catalog to search for translation lookup.
1801 * This function is useful for extern libraries and/or code,
1802 * that provide their own messages.
1803 *
1804 * If the catalog does not exist for the chosen language,
1805 * it will be ignored and en_US will be used.
1806 *
1807 * @param catalog The catalog to add.
1808 */
1809 void insertCatalog(const QString& catalog);
1810
1811 /**
1812 * Removes a catalog for translation lookup.
1813 * @param catalog The catalog to remove.
1814 * @see insertCatalog()
1815 */
1816 void removeCatalog(const QString &catalog);
1817
1818 /**
1819 * Sets the active catalog for translation lookup.
1820 * @param catalog The catalog to activate.
1821 */
1822 void setActiveCatalog(const QString &catalog);
1823
1824 /**
1825 * Translates a message as a QTranslator is supposed to.
1826 * The parameters are similar to i18n(), but the result
1827 * value has other semantics (it can be QString())
1828 */
1829 QString translateQt(const char *context, const char *sourceText, const char *comment) const;
1830
1831 /**
1832 * Provides list of all known language codes.
1833 *
1834 * Use languageCodeToName(language) to get human readable, localized
1835 * language names.
1836 *
1837 * @return list of all language codes
1838 *
1839 * @see languageCodeToName
1840 * @see installedLanguages
1841 */
1842 QStringList allLanguagesList() const;
1843
1844 /**
1845 * @since 4.6
1846 *
1847 * Provides list of all installed KDE Language Translations.
1848 *
1849 * Use languageCodeToName(language) to get human readable, localized
1850 * language names.
1851 *
1852 * @return list of all installed language codes
1853 *
1854 * @see languageCodeToName
1855 */
1856 QStringList installedLanguages() const;
1857
1858 /**
1859 * Convert a known language code to a human readable, localized form.
1860 * If an unknown language code is supplied, empty string is returned;
1861 * this will never happen if the code has been obtained by one of the
1862 * KLocale methods.
1863 *
1864 * @param language the language code
1865 *
1866 * @return the human readable and localized form if the code is known,
1867 * empty otherwise
1868 *
1869 * @see language
1870 * @see languageList
1871 * @see allLanguagesList
1872 * @see installedLanguages
1873 */
1874 QString languageCodeToName(const QString &language) const;
1875
1876 /**
1877 * Provides list of all known country codes.
1878 *
1879 * Use countryCodeToName(country) to get human readable, localized
1880 * country names.
1881 *
1882 * @return a list of all country codes
1883 *
1884 * @see countryCodeToName
1885 */
1886 QStringList allCountriesList() const;
1887
1888 /**
1889 * Convert a known country code to a human readable, localized form.
1890 *
1891 * If an unknown country code is supplied, empty string is returned;
1892 * this will never happen if the code has been obtained by one of the
1893 * KLocale methods.
1894 *
1895 * @param country the country code
1896 *
1897 * @return the human readable and localized form of the country name
1898 *
1899 * @see country
1900 * @see allCountriesList
1901 */
1902 QString countryCodeToName(const QString &country) const;
1903
1904 /**
1905 * Parses locale string into distinct parts.
1906 * The format of locale is language_COUNTRY@modifier.CHARSET
1907 *
1908 * @param locale the locale string to split
1909 * @param language set to the language part of the locale
1910 * @param country set to the country part of the locale
1911 * @param modifier set to the modifer part of the locale
1912 * @param charset set to the charset part of the locale
1913 */
1914 static void splitLocale(const QString &locale, QString &language, QString &country,
1915 QString &modifier, QString &charset);
1916
1917 /**
1918 * Use this as main catalog for *all* KLocales, if not the appname
1919 * will be used. This function is best to be the very first instruction
1920 * in your program's main function as it only has an effect before the
1921 * first KLocale object is created.
1922 *
1923 * @param catalog Catalog to override all other main Catalogs.
1924 */
1925 static void setMainCatalog(const char *catalog);
1926
1927 /**
1928 * @deprecated
1929 *
1930 * Finds localized resource in resourceDir( rtype ) + \<lang> + fname.
1931 *
1932 * Since KDE 4.1, this service is provided in a slightly different form,
1933 * automatically by e.g. KStandardDirs::locate() and other KDE core classes
1934 * dealing with paths. For manual use, it is replaced by localizedFilePath().
1935 *
1936 * @param fname relative path to find
1937 * @param rtype resource type to use
1938 *
1939 * @return path to localized resource
1940 *
1941 * @see localizedFilePath
1942 */
1943 static QString langLookup(const QString &fname, const char *rtype = "html");
1944
1945 /**
1946 * Returns the name of the internal language.
1947 *
1948 * @return Name of the default language
1949 */
1950 static QString defaultLanguage();
1951
1952 /**
1953 * Returns the code of the default country, i.e. "C"
1954 *
1955 * This function will not provide a sensible value to use in your app,
1956 * please use country() instead.
1957 *
1958 * @see country
1959 *
1960 * @return Name of the default country
1961 */
1962 static QString defaultCountry();
1963
1964 /**
1965 * @since 4.4
1966 *
1967 * Returns the ISO Code of the default currency.
1968 *
1969 * @return ISO Currency Code of the default currency
1970 */
1971 static QString defaultCurrencyCode();
1972
1973 /**
1974 * Reports whether evaluation of translation scripts is enabled.
1975 *
1976 * @return true if script evaluation is enabled, false otherwise.
1977 */
1978 bool useTranscript() const;
1979
1980 /**
1981 * Checks whether or not the active catalog is found for the given language.
1982 *
1983 * @param language language to check
1984 */
1985 bool isApplicationTranslatedInto(const QString & language);
1986
1987 /**
1988 * Copies the catalogs of this object to an other KLocale object.
1989 *
1990 * @param locale the destination KLocale object
1991 */
1992 void copyCatalogsTo(KLocale *locale);
1993
1994 /**
1995 * Changes the current country. The current country will be left
1996 * unchanged if failed. It will force a reload of the country specific
1997 * configuration.
1998 *
1999 * An empty country value will set the country to the system default.
2000 *
2001 * If you specify a configuration file, a setLocale() will be performed on
2002 * the config using the current locale language, which may cause a sync()
2003 * and reparseConfiguration() which will save any changes you have made.
2004 *
2005 * @param country the ISO 3166 country code
2006 * @param config a configuration file with a Locale group detailing
2007 * locale-related preferences (such as language and
2008 * formatting options).
2009 *
2010 * @return @c true on success, @c false on failure
2011 */
2012 bool setCountry(const QString & country, KConfig *config);
2013
2014 /**
2015 * @since 4.6
2016 *
2017 * Sets the Country Division Code of the Country where the user lives.
2018 *
2019 * The code must comply with the ISO 3166-2 standard.
2020 * See http://en.wikipedia.org/wiki/ISO_3166-2 for details.
2021 *
2022 * In KDE 4.6 it is the apps responsibility to validate the input,
2023 * full validation and other services will be provided in KDE 4.7.
2024 *
2025 * @param countryDivision the Country Division Code for the user
2026 * @return @c true on success, @c false on failure
2027 * @see countryDivisionCode
2028 */
2029 bool setCountryDivisionCode(const QString & countryDivision);
2030
2031 /**
2032 * Changes the current language. The current language will be left
2033 * unchanged if failed. It will force a reload of the country specific
2034 * configuration as well.
2035 *
2036 * If you specify a configuration file, a setLocale() will be performed on
2037 * the config using the current locale language, which may cause a sync()
2038 * and reparseConfiguration() which will save any changes you have made.
2039 *
2040 * @param language the language code
2041 * @param config a configuration file with a Locale group detailing
2042 * locale-related preferences (such as language and
2043 * formatting options).
2044 *
2045 * @return true on success
2046 */
2047 bool setLanguage(const QString &language, KConfig *config);
2048
2049 /**
2050 * Changes the list of preferred languages for the locale. The first valid
2051 * language in the list will be used, or the default language (en_US)
2052 * if none of the specified languages were available.
2053 *
2054 * @param languages the list of language codes
2055 *
2056 * @return true if one of the specified languages were used
2057 */
2058 bool setLanguage(const QStringList &languages);
2059
2060 /**
2061 * @since 4.1
2062 *
2063 * Tries to find a path to the localized file for the given original path.
2064 * This is intended mainly for non-text resources (images, sounds, etc.),
2065 * whereas text resources should be handled in more specific ways.
2066 *
2067 * The possible localized paths are checked in turn by priority of set
2068 * languages, in form of dirname/l10n/ll/basename, where dirname and
2069 * basename are those of the original path, and ll is the language code.
2070 *
2071 * KDE core classes which resolve paths internally (e.g. KStandardDirs)
2072 * will usually perform this lookup behind the scene.
2073 * In general, you should pipe resource paths through this method only
2074 * on explicit translators' request, or when a resource is an obvious
2075 * candidate for localization (e.g. a splash screen or a custom icon
2076 * with some text drawn on it).
2077 *
2078 * @param filePath path to the original file
2079 *
2080 * @return path to the localized file if found, original path otherwise
2081 */
2082 QString localizedFilePath(const QString &filePath) const;
2083
2084 /**
2085 * @since 4.2
2086 *
2087 * Removes accelerator marker from a UI text label.
2088 *
2089 * Accelerator marker is not always a plain ampersand (&),
2090 * so it is not enough to just remove it by @c QString::remove().
2091 * The label may contain escaped markers ("&&") which must be resolved
2092 * and skipped, as well as CJK-style markers ("Foo (&F)") where
2093 * the whole parenthesis construct should be removed.
2094 * Therefore always use this function to remove accelerator marker
2095 * from UI labels.
2096 *
2097 * @param label UI label which may contain an accelerator marker
2098 * @return label without the accelerator marker
2099 */
2100 QString removeAcceleratorMarker(const QString &label) const;
2101
2102 /**
2103 * @since 4.3
2104 *
2105 * Convert all digits in the string to the given digit set.
2106 *
2107 * Conversion is normally not performed if the given digit set
2108 * is not appropriate in the current locale and language context.
2109 * Unconditional conversion may be requested by setting
2110 * @p ignoreContext to @c true.
2111 *
2112 * @param str the string to convert
2113 * @param digitSet the digit set identifier
2114 * @param ignoreContext unconditional conversion if @c true
2115 *
2116 * @return string with converted digits
2117 *
2118 * @see DigitSet
2119 */
2120 QString convertDigits(const QString &str, DigitSet digitSet,
2121 bool ignoreContext = false) const;
2122
2123 /**
2124 * @since 4.8
2125 *
2126 * Reparse locale configuration files for the current selected
2127 * language.
2128 */
2129 void reparseConfiguration();
2130
2131private:
2132 friend class KLocalePrivate;
2133 friend class KLocaleTest;
2134 friend class KDateTimeFormatter;
2135 KLocalePrivate * const d;
2136};
2137
2138Q_DECLARE_OPERATORS_FOR_FLAGS(KLocale::DateTimeFormatOptions)
2139Q_DECLARE_OPERATORS_FOR_FLAGS(KLocale::DateTimeComponents)
2140Q_DECLARE_OPERATORS_FOR_FLAGS(KLocale::TimeFormatOptions)
2141Q_DECLARE_OPERATORS_FOR_FLAGS(KLocale::TimeProcessingOptions)
2142
2143#endif
2144

Warning: That file was not part of the compilation database. It may have many parsing errors.