File indexing completed on 2025-03-23 09:51:01
0001 /* This file is part of the KDE libraries 0002 * Copyright 2009 David Faure <faure@kde.org> 0003 * Copyright 2010 John Layt <john@layt.net> 0004 * 0005 * This library is free software; you can redistribute it and/or 0006 * modify it under the terms of the GNU Library General Public 0007 * License as published by the Free Software Foundation; either 0008 * version 2 of the License, or (at your option) any later version. 0009 * 0010 * This library is distributed in the hope that it will be useful, 0011 * but WITHOUT ANY WARRANTY; without even the implied warranty of 0012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 0013 * Library General Public License for more details. 0014 * 0015 * You should have received a copy of the GNU Library General Public License 0016 * along with this library; see the file COPYING.LIB. If not, write to 0017 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 0018 * Boston, MA 02110-1301, USA. 0019 */ 0020 0021 #ifndef KLOCALE_P_H 0022 #define KLOCALE_P_H 0023 0024 #include "klocale.h" 0025 #include "klocalizedstring.h" 0026 0027 class KCatalog; 0028 class KDayPeriod; 0029 0030 class KDELIBS4SUPPORT_EXPORT KLocalePrivate 0031 { 0032 public: 0033 /** 0034 * Constructors 0035 * 0036 * This class should not be instantited directly, it is intended as a base class for each 0037 * platform to provide a common KDE fallback implementation. Instead use the relevant 0038 * derived system class for Unix, Win, or Mac which will prefer the local platform settings 0039 * where possible. 0040 */ 0041 KLocalePrivate(KLocale *q_ptr); 0042 0043 /** 0044 * Copy constructor 0045 */ 0046 KLocalePrivate(const KLocalePrivate &rhs); 0047 0048 /** 0049 * Assignment operator 0050 */ 0051 KLocalePrivate &operator=(const KLocalePrivate &rhs); 0052 0053 /** 0054 * Destructor 0055 */ 0056 virtual ~KLocalePrivate(); 0057 0058 /************************** 0059 ** Initialization ** 0060 **************************/ 0061 0062 /** 0063 * Reads the format configuration from disk. 0064 */ 0065 virtual void initFormat(); 0066 0067 protected: 0068 0069 /** 0070 * @internal Returns config object 0071 */ 0072 KSharedConfigPtr config(); 0073 0074 /** 0075 * @internal Copies object members 0076 */ 0077 virtual void copy(const KLocalePrivate &rhs); 0078 0079 /** 0080 * @internal Main init function, needs to be called by appropriate child constructor. 0081 */ 0082 virtual void init(const QString &language, const QString &country, 0083 KSharedConfig::Ptr persistantconfig, KConfig *tempConfig); 0084 0085 /** 0086 * @internal Init config. 0087 */ 0088 virtual void initConfig(KConfig *config); 0089 0090 /************************** 0091 ** Country settings ** 0092 **************************/ 0093 0094 protected: 0095 0096 /** 0097 * @internal Initializes the country if not already explicitly set when calling the constructor 0098 * Will default to any value set in the config, otherwise will attempt to use the host system 0099 * country, or finally fall back to the default C. 0100 */ 0101 virtual void initCountry(const QString &country, const QString &configCountry); 0102 0103 /** 0104 * @internal Returns the host system country ISO code 0105 * If country could not be determined then may return an empty string or "C" 0106 */ 0107 virtual QString systemCountry() const; 0108 0109 public: 0110 0111 /** 0112 * @internal Sets the Locale Country 0113 * The worker of the same-name KLocale API function. 0114 */ 0115 virtual bool setCountry(const QString &country, KConfig *config); 0116 0117 /** 0118 * @internal Returns the Locale ISO Country Code 0119 * The worker of the same-name KLocale API function. 0120 */ 0121 virtual QString country() const; 0122 0123 /** 0124 * @internal Returns the name of the default country. 0125 * The worker of the same-name KLocale API function. 0126 */ 0127 static QString defaultCountry(); 0128 0129 /** 0130 * @internal Returns a list of all known country codes. 0131 * The worker of the same-name KLocale API function. 0132 */ 0133 virtual QStringList allCountriesList() const; 0134 0135 /** 0136 * @internal Convert a known country code to a human readable, localized form. 0137 * The worker of the same-name KLocale API function. 0138 */ 0139 virtual QString countryCodeToName(const QString &country) const; 0140 0141 /** 0142 * @internal Sets the Country Division Code 0143 * The worker of the same-name KLocale API function. 0144 */ 0145 bool setCountryDivisionCode(const QString &countryDivision); 0146 0147 /** 0148 * @internal Returns the Country Division Code 0149 * The worker of the same-name KLocale API function. 0150 */ 0151 QString countryDivisionCode() const; 0152 0153 /************************** 0154 ** Language settings ** 0155 **************************/ 0156 0157 protected: 0158 0159 /** 0160 * @internal Converts a language variable in a list of languages 0161 */ 0162 static void getLanguagesFromVariable(QStringList &list, const char *variable, bool isLanguageList = false); 0163 0164 /** 0165 * @internal Returns the list of host system languages 0166 */ 0167 virtual QStringList systemLanguageList() const; 0168 0169 /** 0170 * @internal Initializes the list of valid languages from the user's point of view. This is the 0171 * list of languages that the user picks in kcontrol. The config object should be valid and 0172 * contain the global entries. 0173 * 0174 * @param language The defualt language to use 0175 * @param configLanguages The "Language" setting from the current config 0176 * @param useEnv Whether to use the envvars 0177 */ 0178 virtual void initLanguageList(const QString &language, const QString &configLanguages, bool useEnv); 0179 0180 /** 0181 * @internal function used to determine if we are using the en_US translation 0182 */ 0183 virtual bool useDefaultLanguage() const; 0184 0185 public: 0186 0187 /** 0188 * @internal Sets the Locale Language 0189 * The worker of the same-name KLocale API function. 0190 */ 0191 virtual bool setLanguage(const QString &language, KConfig *config); 0192 0193 /** 0194 * @internal Sets the list of preferred languages for the locale. 0195 * The worker of the same-name KLocale API function. 0196 */ 0197 virtual bool setLanguage(const QStringList &languages); 0198 0199 /** 0200 * @internal Returns the Locale Language 0201 * The worker of the same-name KLocale API function. 0202 */ 0203 virtual QString language() const; 0204 0205 /** 0206 * @internal Returns the language codes selected by user 0207 * The worker of the same-name KLocale API function. 0208 */ 0209 virtual QStringList languageList() const; 0210 0211 /** 0212 * @internal Returns a list of all known language codes. 0213 * The worker of the same-name KLocale API function. 0214 */ 0215 virtual QStringList allLanguagesList(); 0216 0217 /** 0218 * @internal Returns a list of all installed KDE languages. 0219 * The worker of the same-name KLocale API function. 0220 */ 0221 virtual QStringList installedLanguages(); 0222 0223 /** 0224 * @internal Returns the name of the internal language. 0225 * The worker of the same-name KLocale API function. 0226 */ 0227 static QString defaultLanguage(); 0228 0229 /** 0230 * @internal Convert a known language code to a human readable, localized form. 0231 * The worker of the same-name KLocale API function. 0232 */ 0233 virtual QString languageCodeToName(const QString &language); 0234 0235 /** 0236 * @deprecated 0237 * @internal Returns if nouns are declined in the locale language. 0238 * The worker of the same-name KLocale API function. 0239 */ 0240 virtual bool nounDeclension() const; 0241 0242 /*************************** 0243 ** Calendar settings ** 0244 ***************************/ 0245 0246 protected: 0247 0248 /** 0249 * @internal Converts a CalendarType into a CalendarSystem 0250 */ 0251 virtual KLocale::CalendarSystem calendarTypeToCalendarSystem(const QString &calendarType) const; 0252 0253 /** 0254 * @internal Converts a CalendarSystem into a CalendarType 0255 */ 0256 virtual QString calendarSystemToCalendarType(KLocale::CalendarSystem) const; 0257 0258 public: 0259 0260 /** 0261 * @internal Sets the current calendar system to the calendar specified. 0262 * The worker of the same-name KLocale API function. 0263 */ 0264 virtual void setCalendar(const QString &calendarType); 0265 0266 /** 0267 * @internal Sets the current calendar system to the calendar specified. 0268 * The worker of the same-name KLocale API function. 0269 */ 0270 virtual void setCalendarSystem(KLocale::CalendarSystem); 0271 0272 /** 0273 * @internal Returns the name of the calendar system that is currently being used by the system. 0274 * The worker of the same-name KLocale API function. 0275 */ 0276 virtual QString calendarType() const; 0277 0278 /** 0279 * @internal Returns the type of the calendar system that is currently being used by the system. 0280 * The worker of the same-name KLocale API function. 0281 */ 0282 KLocale::CalendarSystem calendarSystem() const; 0283 0284 /** 0285 * @internal Returns a pointer to the calendar system object. 0286 * The worker of the same-name KLocale API function. 0287 */ 0288 virtual const KCalendarSystem *calendar(); 0289 0290 /** 0291 * @internal Sets the Week Number System to use 0292 * The worker of the same-name KLocale API function. 0293 */ 0294 void setWeekNumberSystem(KLocale::WeekNumberSystem weekNumberSystem); 0295 0296 /** 0297 * @internal Returns the Week Number System used 0298 * The worker of the same-name KLocale API function. 0299 */ 0300 KLocale::WeekNumberSystem weekNumberSystem(); 0301 0302 /** 0303 * @internal Changes how KLocale defines the first day in week. 0304 * The worker of the same-name KLocale API function. 0305 */ 0306 virtual void setWeekStartDay(int day); 0307 0308 /** 0309 * @internal Returns which day is the first day of the week. 0310 * The worker of the same-name KLocale API function. 0311 */ 0312 virtual int weekStartDay() const; 0313 0314 /** 0315 * @internal Changes how KLocale defines the first working day in week. 0316 * The worker of the same-name KLocale API function. 0317 */ 0318 virtual void setWorkingWeekStartDay(int day); 0319 0320 /** 0321 * @internal Returns which day is the first working day of the week. 0322 * The worker of the same-name KLocale API function. 0323 */ 0324 virtual int workingWeekStartDay() const; 0325 0326 /** 0327 * @internal Changes how KLocale defines the last working day in week. 0328 * The worker of the same-name KLocale API function. 0329 */ 0330 virtual void setWorkingWeekEndDay(int day); 0331 0332 /** 0333 * @internal Returns which day is the last working day of the week. 0334 * The worker of the same-name KLocale API function. 0335 */ 0336 virtual int workingWeekEndDay() const; 0337 0338 /** 0339 * @internal Changes how KLocale defines the day reserved for religious observance. 0340 * The worker of the same-name KLocale API function. 0341 */ 0342 virtual void setWeekDayOfPray(int day); 0343 0344 /** 0345 * @internal Returns which day is reserved for religious observance 0346 * The worker of the same-name KLocale API function. 0347 */ 0348 virtual int weekDayOfPray() const; 0349 0350 /*************************** 0351 ** Date/Time settings ** 0352 ***************************/ 0353 0354 protected: 0355 0356 /** 0357 * @internal initialises the Day Periods 0358 */ 0359 virtual void initDayPeriods(const KConfigGroup &cg); 0360 0361 public: 0362 0363 /** 0364 * @internal Sets the current date format. 0365 * The worker of the same-name KLocale API function. 0366 */ 0367 virtual void setDateFormat(const QString &format); 0368 0369 /** 0370 * @internal Returns the currently selected date format. 0371 * The worker of the same-name KLocale API function. 0372 */ 0373 virtual QString dateFormat() const; 0374 0375 /** 0376 * @internal Sets the current short date format. 0377 * The worker of the same-name KLocale API function. 0378 */ 0379 virtual void setDateFormatShort(const QString &format); 0380 0381 /** 0382 * @internal Returns the currently selected short date format. 0383 * The worker of the same-name KLocale API function. 0384 */ 0385 virtual QString dateFormatShort() const; 0386 0387 /** 0388 * @internal Changes the current time format. 0389 * The worker of the same-name KLocale API function. 0390 */ 0391 virtual void setTimeFormat(const QString &format); 0392 0393 /** 0394 * @internal Returns the currently selected time format. 0395 * The worker of the same-name KLocale API function. 0396 */ 0397 virtual QString timeFormat() const; 0398 0399 /** 0400 * @internal Set digit characters used to display dates and time. 0401 * The worker of the same-name KLocale API function. 0402 */ 0403 virtual void setDateTimeDigitSet(KLocale::DigitSet digitSet); 0404 0405 /** 0406 * @internal Returns the identifier of the digit set used to display dates and time. 0407 * The worker of the same-name KLocale API function. 0408 */ 0409 virtual KLocale::DigitSet dateTimeDigitSet() const; 0410 0411 /** 0412 * @internal Sets of the possessive form of month name should be used in dates. 0413 * The worker of the same-name KLocale API function. 0414 */ 0415 virtual void setDateMonthNamePossessive(bool possessive); 0416 0417 /** 0418 * @internal Returns if possessive form of month name should be used 0419 * The worker of the same-name KLocale API function. 0420 */ 0421 virtual bool dateMonthNamePossessive() const; 0422 0423 /** 0424 * @internal Returns if the user wants 12h clock 0425 * The worker of the same-name KLocale API function. 0426 */ 0427 virtual bool use12Clock() const; 0428 0429 /** 0430 * @internal 0431 * The worker of the same-name KLocale API function. 0432 */ 0433 virtual void setDayPeriods(const QList<KDayPeriod> &dayPeriods); 0434 0435 /** 0436 * @internal 0437 * The worker of the same-name KLocale API function. 0438 */ 0439 virtual QList<KDayPeriod> dayPeriods() const; 0440 0441 /** 0442 * @internal 0443 * The worker of the same-name KLocale API function. 0444 */ 0445 virtual KDayPeriod dayPeriodForTime(const QTime &time) const; 0446 0447 /** 0448 * @internal Returns a string formatted to the current locale's conventions 0449 * The worker of the same-name KLocale API function. 0450 */ 0451 virtual QString formatDate(const QDate &date, KLocale::DateFormat format = KLocale::LongDate); 0452 0453 /** 0454 * @internal Converts a localized date string to a QDate. 0455 * The worker of the same-name KLocale API function. 0456 */ 0457 virtual QDate readDate(const QString &str, bool *ok = nullptr); 0458 0459 /** 0460 * @internal Converts a localized date string to a QDate, using the specified format. 0461 * The worker of the same-name KLocale API function. 0462 */ 0463 virtual QDate readDate(const QString &intstr, const QString &fmt, bool *ok = nullptr); 0464 0465 /** 0466 * @internal Converts a localized date string to a QDate. 0467 * The worker of the same-name KLocale API function. 0468 */ 0469 virtual QDate readDate(const QString &str, KLocale::ReadDateFlags flags, bool *ok = nullptr); 0470 0471 /** 0472 * @deprecated replaced by formatLocaleTime() 0473 * @internal Returns a string formatted to the current locale's conventions regarding times. 0474 * The worker of the same-name KLocale API function. 0475 */ 0476 virtual QString formatTime(const QTime &pTime, bool includeSecs = false, bool isDuration = false) const; 0477 0478 /** 0479 * @internal Returns a string formatted to the current locale's conventions regarding times. 0480 * The worker of the same-name KLocale API function. 0481 */ 0482 virtual QString formatLocaleTime(const QTime &pTime, KLocale::TimeFormatOptions options = KLocale::TimeDefault) const; 0483 0484 /** 0485 * @internal Converts a localized time string to a QTime. 0486 * The worker of the same-name KLocale API function. 0487 */ 0488 virtual QTime readTime(const QString &str, bool *ok = nullptr) const; 0489 0490 /** 0491 * @deprecated replaced by readLocaleTime() 0492 * @internal Converts a localized time string to a QTime. 0493 * The worker of the same-name KLocale API function. 0494 */ 0495 virtual QTime readTime(const QString &str, KLocale::ReadTimeFlags flags, bool *ok = nullptr) const; 0496 0497 /** 0498 * @internal Converts a localized time string to a QTime. 0499 * The worker of the same-name KLocale API function. 0500 */ 0501 virtual QTime readLocaleTime(const QString &str, bool *ok = nullptr, 0502 KLocale::TimeFormatOptions options = KLocale::TimeDefault, 0503 KLocale::TimeProcessingOptions processing = KLocale::ProcessNonStrict) const; 0504 0505 /** 0506 * @internal Formats a date/time according to specified format. 0507 * The worker of the same-name KLocale API function. 0508 */ 0509 static QString formatDateTime(const KLocale *locale, const QDateTime &dateTime, KLocale::DateFormat, 0510 bool includeSeconds, int daysToNow, int secsToNow); 0511 0512 /** 0513 * @internal Return the date and time as a string 0514 * The worker of the same-name KLocale API function. 0515 */ 0516 virtual QString formatDateTime(const QDateTime &dateTime, KLocale::DateFormat format = KLocale::ShortDate, 0517 bool includeSecs = false) const; 0518 0519 /** 0520 * @internal Return the date and time as a string 0521 * The worker of the same-name KLocale API function. 0522 */ 0523 virtual QString formatDateTime(const KDateTime &dateTime, KLocale::DateFormat format = KLocale::ShortDate, 0524 KLocale::DateTimeFormatOptions options = {}); 0525 0526 /** 0527 * @internal Returns converted duration as a string 0528 * The worker of the same-name KLocale API function. 0529 */ 0530 virtual QString formatDuration(unsigned long mSec) const; 0531 0532 /** 0533 * @internal Returns converted duration as a string. 0534 * The worker of the same-name KLocale API function. 0535 */ 0536 virtual QString prettyFormatDuration(unsigned long mSec) const; 0537 0538 /*************************** 0539 ** Digit Set settings ** 0540 ***************************/ 0541 0542 protected: 0543 0544 /** 0545 * @internal Converts a number string in any digit set into Arabic digits 0546 */ 0547 static QString toArabicDigits(const QString &str); 0548 0549 /** 0550 * @internal Returns the digits for a digit set as a string, e.g. "0123456789" 0551 */ 0552 static QString digitSetString(KLocale::DigitSet digitSet); 0553 0554 public: 0555 0556 /** 0557 * @internal Provides list of all known digit set identifiers. 0558 * The worker of the same-name KLocale API function. 0559 */ 0560 virtual QList<KLocale::DigitSet> allDigitSetsList() const; 0561 0562 /** 0563 * @internal Convert a digit set identifier to a human readable, localized name. 0564 * The worker of the same-name KLocale API function. 0565 */ 0566 virtual QString digitSetToName(KLocale::DigitSet digitSet, bool withDigits = false) const; 0567 0568 /** 0569 * @internal Convert all digits in the string to the given digit set. 0570 * The worker of the same-name KLocale API function. 0571 */ 0572 virtual QString convertDigits(const QString &str, KLocale::DigitSet digitSet, bool ignoreContext = false) const; 0573 0574 /*************************** 0575 ** Number settings ** 0576 ***************************/ 0577 0578 public: 0579 0580 /** 0581 * @internal Sets the number of decimal places used when formating numbers. 0582 * The worker of the same-name KLocale API function. 0583 */ 0584 virtual void setDecimalPlaces(int digits); 0585 0586 /** 0587 * @internal Returns the number of numeric decimal places used by locale. 0588 * The worker of the same-name KLocale API function. 0589 */ 0590 virtual int decimalPlaces() const; 0591 0592 /** 0593 * @internal Sets the symbol used to identify the decimal pointer. 0594 * The worker of the same-name KLocale API function. 0595 */ 0596 virtual void setDecimalSymbol(const QString &symbol); 0597 0598 /** 0599 * @internal Returns the decimal symbol used by locale. 0600 * The worker of the same-name KLocale API function. 0601 */ 0602 virtual QString decimalSymbol() const; 0603 0604 /** 0605 * @internal Sets the separator used to group digits when formating numbers. 0606 * The worker of the same-name KLocale API function. 0607 * KDE5 Rename to setNumericDigitGroupSeparator() 0608 */ 0609 virtual void setThousandsSeparator(const QString &separator); 0610 0611 /** 0612 * @internal Returns the digit group separator used by locale. 0613 * The worker of the same-name KLocale API function. 0614 * KDE5 Rename to numericDigitGroupSeparator() 0615 */ 0616 virtual QString thousandsSeparator() const; 0617 0618 /** 0619 * @internal Sets the digit grouping to apply to numbers 0620 * For now internal only api designed for processing efficiency, if needed publicly then may 0621 * need to review if this is the best way. 0622 */ 0623 virtual void setNumericDigitGrouping(QList<int> groupList); 0624 0625 /** 0626 * @internal Returns the digit grouping to apply to numbers 0627 * For now internal only api designed for processing efficiency, if needed publicly then may 0628 * need to review if this is the best way. 0629 */ 0630 virtual QList<int> numericDigitGrouping() const; 0631 0632 /** 0633 * @internal Sets the sign used to identify a positive number. 0634 * The worker of the same-name KLocale API function. 0635 */ 0636 virtual void setPositiveSign(const QString &sign); 0637 0638 /** 0639 * @internal Returns the positive sign used by locale. 0640 * The worker of the same-name KLocale API function. 0641 */ 0642 virtual QString positiveSign() const; 0643 0644 /** 0645 * @internal Sets the sign used to identify a negative number. 0646 * The worker of the same-name KLocale API function. 0647 */ 0648 virtual void setNegativeSign(const QString &sign); 0649 0650 /** 0651 * @internal Returns the negative sign used by locale. 0652 * The worker of the same-name KLocale API function. 0653 */ 0654 virtual QString negativeSign() const; 0655 0656 /** 0657 * @internal Sets the set of digit characters used to display numbers. 0658 * The worker of the same-name KLocale API function. 0659 */ 0660 virtual void setDigitSet(KLocale::DigitSet digitSet); 0661 0662 /** 0663 * @internal Returns the identifier of the digit set used to display numbers. 0664 * The worker of the same-name KLocale API function. 0665 */ 0666 virtual KLocale::DigitSet digitSet() const; 0667 0668 /** 0669 * @internal Returns a number as a localized string 0670 * The worker of the same-name KLocale API function. 0671 */ 0672 virtual QString formatNumber(double num, int precision = -1) const; 0673 0674 /** 0675 * @internal Returns a number as a localized string 0676 * The worker of the same-name KLocale API function. 0677 */ 0678 virtual QString formatNumber(const QString &numStr, bool round = true, int precision = -1) const; 0679 0680 /** 0681 * @internal Returns a number as a localized string 0682 * The worker of the same-name KLocale API function. 0683 */ 0684 virtual QString formatLong(long num) const; 0685 0686 /** 0687 * @internal Converts a localized numeric string to a double. 0688 * The worker of the same-name KLocale API function. 0689 */ 0690 virtual double readNumber(const QString &numStr, bool *ok = nullptr) const; 0691 0692 /************************** 0693 ** Currency settings ** 0694 **************************/ 0695 0696 protected: 0697 0698 /** 0699 * @internal Initialises the Currency 0700 */ 0701 virtual void initCurrency(); 0702 0703 public: 0704 0705 /** 0706 * @internal Sets the Locale Currency Code 0707 * The worker of the same-name KLocale API function. 0708 */ 0709 virtual void setCurrencyCode(const QString &newCurrencyCode); 0710 0711 /** 0712 * @internal Returns the Locale ISO Currency Code 0713 * The worker of the same-name KLocale API function. 0714 */ 0715 virtual QString currencyCode() const; 0716 0717 /** 0718 * @internal Returns the Locale Currency object 0719 * The worker of the same-name KLocale API function. 0720 */ 0721 virtual KCurrencyCode *currency(); 0722 0723 /** 0724 * @internal Returns the ISO Code of the default currency. 0725 * The worker of the same-name KLocale API function. 0726 */ 0727 static QString defaultCurrencyCode(); 0728 0729 /** 0730 * @internal Returns the ISO Currency Codes used in the locale 0731 * The worker of the same-name KLocale API function. 0732 */ 0733 virtual QStringList currencyCodeList() const; 0734 0735 /*************************** 0736 ** Money settings ** 0737 ***************************/ 0738 0739 public: 0740 0741 /** 0742 * @internal Sets the current currency symbol. 0743 * The worker of the same-name KLocale API function. 0744 */ 0745 virtual void setCurrencySymbol(const QString &symbol); 0746 0747 /** 0748 * @internal Returns the default currency symbol used by locale. 0749 * The worker of the same-name KLocale API function. 0750 */ 0751 virtual QString currencySymbol() const; 0752 0753 /** 0754 * @internal Sets the symbol used to identify the decimal pointer for monetary values. 0755 * The worker of the same-name KLocale API function. 0756 */ 0757 virtual void setMonetaryDecimalSymbol(const QString &symbol); 0758 0759 /** 0760 * @internal Returns the monetary decimal symbol used by locale. 0761 * The worker of the same-name KLocale API function. 0762 */ 0763 virtual QString monetaryDecimalSymbol() const; 0764 0765 /** 0766 * @internal Sets the separator used to group digits when formating monetary values. 0767 * The worker of the same-name KLocale API function. 0768 * KDE5 Rename to setMonetaryDigitGroupSeparator() 0769 */ 0770 virtual void setMonetaryThousandsSeparator(const QString &separator); 0771 0772 /** 0773 * @internal Returns the monetary thousands separator used by locale. 0774 * The worker of the same-name KLocale API function. 0775 * KDE5 Rename to monetaryDigitGroupSeparator() 0776 */ 0777 virtual QString monetaryThousandsSeparator() const; 0778 0779 /** 0780 * @internal Sets the digit grouping to apply to numbers 0781 * For now internal only api designed for processing efficiency, if needed publicly then may 0782 * need to review if this is the best way. 0783 */ 0784 virtual void setMonetaryDigitGrouping(QList<int> groupList); 0785 0786 /** 0787 * @internal Returns the digit grouping to apply to numbers 0788 * For now internal only api designed for processing efficiency, if needed publicly then may 0789 * need to review if this is the best way. 0790 */ 0791 virtual QList<int> monetaryDigitGrouping() const; 0792 0793 /** 0794 * @internal Sets the number of decimal places used when formating money. 0795 * The worker of the same-name KLocale API function. 0796 */ 0797 virtual void setMonetaryDecimalPlaces(int digits); 0798 0799 /** 0800 * @internal Returns the number of monetary decimal places used by locale. 0801 * The worker of the same-name KLocale API function. 0802 */ 0803 virtual int monetaryDecimalPlaces() const; 0804 0805 /** 0806 * @internal Sets the position where the currency symbol should be printed for 0807 * positive monetary values. 0808 * The worker of the same-name KLocale API function. 0809 */ 0810 virtual void setPositivePrefixCurrencySymbol(bool prefix); 0811 0812 /** 0813 * @internal Returns where to print the currency symbol for positive numbers. 0814 * The worker of the same-name KLocale API function. 0815 */ 0816 virtual bool positivePrefixCurrencySymbol() const; 0817 0818 /** 0819 * @internal Sets the position where the currency symbol should be printed for 0820 * negative monetary values. 0821 * The worker of the same-name KLocale API function. 0822 */ 0823 virtual void setNegativePrefixCurrencySymbol(bool prefix); 0824 0825 /** 0826 * @internal Returns if the currency symbol precedes negative numbers. 0827 * The worker of the same-name KLocale API function. 0828 */ 0829 virtual bool negativePrefixCurrencySymbol() const; 0830 0831 /** 0832 * @internal Sets the sign position used for positive monetary values. 0833 * The worker of the same-name KLocale API function. 0834 */ 0835 virtual void setPositiveMonetarySignPosition(KLocale::SignPosition signpos); 0836 0837 /** 0838 * @internal Returns where/how to print the positive sign. 0839 * The worker of the same-name KLocale API function. 0840 */ 0841 virtual KLocale::SignPosition positiveMonetarySignPosition() const; 0842 0843 /** 0844 * @internal Sets the sign position used for negative monetary values. 0845 * The worker of the same-name KLocale API function. 0846 */ 0847 virtual void setNegativeMonetarySignPosition(KLocale::SignPosition signpos); 0848 0849 /** 0850 * @internal Returns where/how to print the negative sign. 0851 * The worker of the same-name KLocale API function. 0852 */ 0853 virtual KLocale::SignPosition negativeMonetarySignPosition() const; 0854 0855 /** 0856 * @internal Set digit characters used to display monetary values. 0857 * The worker of the same-name KLocale API function. 0858 */ 0859 virtual void setMonetaryDigitSet(KLocale::DigitSet digitSet); 0860 0861 /** 0862 * @internal Retuns the digit set used to display monetary values. 0863 * The worker of the same-name KLocale API function. 0864 */ 0865 virtual KLocale::DigitSet monetaryDigitSet() const; 0866 0867 /** 0868 * @internal Returns an amount of money as a localized string 0869 * The worker of the same-name KLocale API function. 0870 */ 0871 virtual QString formatMoney(double num, const QString ¤cy = QString(), int precision = -1) const; 0872 0873 /** 0874 * @internal Converts a localized monetary string to a double. 0875 * The worker of the same-name KLocale API function. 0876 */ 0877 virtual double readMoney(const QString &numStr, bool *ok = nullptr) const; 0878 0879 /*************************** 0880 ** Units settings ** 0881 ***************************/ 0882 0883 protected: 0884 0885 /** 0886 * @internal 0887 * @return list of translated binary unit for @p dialect. 0888 */ 0889 QList<QString> dialectUnitsList(KLocale::BinaryUnitDialect dialect); 0890 0891 enum DurationType { 0892 DaysDurationType = 0, 0893 HoursDurationType, 0894 MinutesDurationType, 0895 SecondsDurationType 0896 }; 0897 0898 /** 0899 * @internal Formats a duration according to the given type and number 0900 */ 0901 static QString formatSingleDuration(KLocalePrivate::DurationType durationType, int n); 0902 0903 public: 0904 0905 /** 0906 * @internal Returns the user's default binary unit dialect. 0907 * The worker of the same-name KLocale API function. 0908 */ 0909 virtual KLocale::BinaryUnitDialect binaryUnitDialect() const; 0910 0911 /** 0912 * @internal Sets the default dialect for this locale 0913 * The worker of the same-name KLocale API function. 0914 */ 0915 virtual void setBinaryUnitDialect(KLocale::BinaryUnitDialect newDialect); 0916 0917 /** 0918 * @internal Returns converted size as a string 0919 * The worker of the same-name KLocale API function. 0920 */ 0921 virtual QString formatByteSize(double size); 0922 0923 /** 0924 * @internal Returns converted size as a translated string including the units. 0925 * The worker of the same-name KLocale API function. 0926 */ 0927 virtual QString formatByteSize(double size, int precision, 0928 KLocale::BinaryUnitDialect dialect = KLocale::DefaultBinaryDialect, 0929 KLocale:: BinarySizeUnits specificUnit = KLocale::DefaultBinaryUnits); 0930 0931 /** 0932 * @internal Sets the preferred page size when printing. 0933 * The worker of the same-name KLocale API function. 0934 */ 0935 virtual void setPageSize(int paperFormat); 0936 0937 /** 0938 * @internal Returns the preferred page size for printing. 0939 * The worker of the same-name KLocale API function. 0940 */ 0941 virtual int pageSize() const; 0942 0943 /** 0944 * @internal Sets the preferred measuring system. 0945 * The worker of the same-name KLocale API function. 0946 */ 0947 virtual void setMeasureSystem(KLocale::MeasureSystem value); 0948 0949 /** 0950 * @internal Returns which measuring system we use. 0951 * The worker of the same-name KLocale API function. 0952 */ 0953 virtual KLocale::MeasureSystem measureSystem() const; 0954 0955 /*************************** 0956 ** Encoding settings ** 0957 ***************************/ 0958 0959 protected: 0960 0961 /** 0962 * @internal Figures out which encoding the user prefers. 0963 */ 0964 virtual void initEncoding(); 0965 0966 /** 0967 * @internal Returns the system codeset. 0968 */ 0969 virtual QByteArray systemCodeset() const; 0970 0971 /** 0972 * @internal A QFile filename encoding function (QFile::encodeFn). 0973 */ 0974 static QByteArray encodeFileNameUTF8(const QString &fileName); 0975 0976 /** 0977 * @internal QFile filename decoding function (QFile::decodeFn). 0978 */ 0979 static QString decodeFileNameUTF8(const QByteArray &localFileName); 0980 0981 public: 0982 0983 /** 0984 * @internal Sets the current encoding 0985 * The worker of the same-name KLocale API function. 0986 */ 0987 virtual bool setEncoding(int mibEnum); 0988 0989 /** 0990 * @internal Returns the user's preferred encoding. 0991 * The worker of the same-name KLocale API function. 0992 */ 0993 virtual const QByteArray encoding(); 0994 0995 /** 0996 * @internal Returns the user's preferred encoding. 0997 * The worker of the same-name KLocale API function. 0998 */ 0999 virtual int encodingMib() const; 1000 1001 /** 1002 * @internal Returns the file encoding. 1003 * The worker of the same-name KLocale API function. 1004 */ 1005 virtual int fileEncodingMib() const; 1006 1007 /** 1008 * @internal Returns the user's preferred encoding. 1009 * The worker of the same-name KLocale API function. 1010 */ 1011 virtual QTextCodec *codecForEncoding() const; 1012 1013 /*************************** 1014 ** Utilities ** 1015 ***************************/ 1016 1017 public: 1018 1019 /** 1020 * @internal Parses locale string into distinct parts. 1021 * The worker of the same-name KLocale API function. 1022 */ 1023 static void splitLocale(const QString &locale, QString &language, QString &country, 1024 QString &modifier, QString &charset); 1025 1026 private: 1027 1028 /** 1029 * @internal COnvert digit group format string to digit group list 1030 */ 1031 QList<int> digitGroupFormatToList(const QString &digitGroupFormat) const; 1032 1033 /** 1034 * @internal Insert digit group separator 1035 */ 1036 QString formatDigitGroup(const QString &number, const QString &groupSeparator, const QString &decimalSeperator, QList<int> groupList) const; 1037 1038 /** 1039 * @internal Remove digit group separator, return ok if valid format 1040 */ 1041 QString parseDigitGroup(const QString &number, const QString &groupSeparator, const QString &decimalSeperator, QList<int> groupList, bool *ok) const; 1042 1043 public: 1044 // Parent KLocale, public needed for copy ctor 1045 KLocale *q; 1046 1047 private: 1048 // Config file containing locale config 1049 KSharedConfig::Ptr m_config; 1050 1051 // Country settings 1052 QString m_country; 1053 QString m_countryDivisionCode; 1054 1055 // Language settings 1056 QString m_language; 1057 KConfig *m_languages; 1058 QStringList m_languageList; 1059 bool m_languageSensitiveDigits; // FIXME: Temporary until full language-sensitivity implemented. 1060 bool m_nounDeclension; 1061 1062 // Calendar settings 1063 KLocale::CalendarSystem m_calendarSystem; 1064 KCalendarSystem *m_calendar; 1065 KLocale::WeekNumberSystem m_weekNumberSystem; 1066 int m_weekStartDay; 1067 int m_workingWeekStartDay; 1068 int m_workingWeekEndDay; 1069 int m_weekDayOfPray; 1070 1071 // Date/Time settings 1072 QString m_dateFormat; 1073 QString m_dateFormatShort; 1074 QString m_timeFormat; 1075 KLocale::DigitSet m_dateTimeDigitSet; 1076 bool m_dateMonthNamePossessive; 1077 mutable QList<KDayPeriod> m_dayPeriods; 1078 1079 // Number settings 1080 int m_decimalPlaces; 1081 QString m_decimalSymbol; 1082 QString m_thousandsSeparator; 1083 QList<int> m_numericDigitGrouping; 1084 QString m_positiveSign; 1085 QString m_negativeSign; 1086 KLocale::DigitSet m_digitSet; 1087 1088 // Currency settings 1089 QString m_currencyCode; 1090 KCurrencyCode *m_currency; 1091 QStringList m_currencyCodeList; 1092 1093 // Money settings 1094 QString m_currencySymbol; 1095 QString m_monetaryDecimalSymbol; 1096 QString m_monetaryThousandsSeparator; 1097 QList<int> m_monetaryDigitGrouping; 1098 int m_monetaryDecimalPlaces; 1099 KLocale::SignPosition m_positiveMonetarySignPosition; 1100 KLocale::SignPosition m_negativeMonetarySignPosition; 1101 bool m_positivePrefixCurrencySymbol; 1102 bool m_negativePrefixCurrencySymbol; 1103 KLocale::DigitSet m_monetaryDigitSet; 1104 1105 // Units settings 1106 KLocale::BinaryUnitDialect m_binaryUnitDialect; 1107 QList<QString> m_byteSizeFmt; 1108 int m_pageSize; 1109 KLocale::MeasureSystem m_measureSystem; 1110 1111 // Encoding settings 1112 QString m_encoding; 1113 QTextCodec *m_codecForEncoding; 1114 bool m_utf8FileEncoding; 1115 }; 1116 1117 #endif /* KLOCALE_P_H */