klocale.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef _KLOCALE_H
00023 #define _KLOCALE_H
00024
00025 #include <qstring.h>
00026 #include "kdemacros.h"
00027
00028 class QStringList;
00029 class QTextCodec;
00030 class QDate;
00031 class QTime;
00032 class QDateTime;
00033
00034 class KGlobal;
00035 class KConfig;
00036 class KConfigBase;
00037 class KLocalePrivate;
00038 class KCatalogue;
00039 class KCalendarSystem;
00040
00041 #ifndef I18N_NOOP
00042
00047 #define I18N_NOOP(x) x
00048 #endif
00049
00062 QString i18n(const char *text);
00063
00071 QString i18n(const char *comment, const char *text);
00072
00079 QString i18n(const char *singular, const char *plural, unsigned long n);
00080
00087 inline QString tr2i18n(const char* message, const char* =0) {
00088 return i18n(message);
00089 }
00090
00103 class KLocale
00104 {
00105 friend class KGlobal;
00106 public:
00123 KLocale( const QString& catalog, KConfig *config = 0 );
00124
00128 KLocale( const KLocale & rhs );
00129
00133 KLocale& operator= ( const KLocale & rhs );
00134
00138 ~KLocale();
00139
00158 QString translate( const char *index ) const;
00159
00185 QString translate( const char *comment, const char *fallback) const;
00186
00197 QString translate( const char *singular, const char *plural,
00198 unsigned long n) const;
00199
00207 bool setEncoding(int mibEnum);
00208
00218 bool setLanguage(const QString & language);
00219
00229 bool setLanguage(const QStringList & languages);
00230
00240 bool setCountry(const QString & country);
00241
00246 enum SignPosition { ParensAround = 0, BeforeQuantityMoney = 1,
00247 AfterQuantityMoney = 2,
00248 BeforeMoney = 3, AfterMoney = 4 };
00249
00256 QString decimalSymbol() const;
00257
00265 QString thousandsSeparator() const;
00266
00273 QString currencySymbol() const;
00274
00282 QString monetaryDecimalSymbol() const;
00283
00291 QString monetaryThousandsSeparator() const;
00292
00299 QString positiveSign() const;
00300
00307 QString negativeSign() const;
00308
00315 int fracDigits() const;
00316
00323 bool positivePrefixCurrencySymbol() const;
00324
00331 bool negativePrefixCurrencySymbol() const;
00332
00340 SignPosition positiveMonetarySignPosition() const;
00341
00349 SignPosition negativeMonetarySignPosition() const;
00350
00365 QString formatMoney(double num,
00366 const QString & currency = QString::null,
00367 int digits = -1) const;
00368
00381 QString formatNumber(double num, int precision = -1) const;
00382
00394 QString formatLong(long num) const;
00395
00404 bool nounDeclension() const;
00405
00415 QString formatDate(const QDate &pDate, bool shortFormat = false) const;
00416
00424 bool dateMonthNamePossessive() const;
00425
00436 QString formatTime(const QTime &pTime, bool includeSecs = false) const;
00437
00443 bool use12Clock() const;
00444
00454 bool weekStartsMonday() const KDE_DEPRECATED;
00455
00462 int weekStartDay() const;
00463
00474 QString monthName(int i, bool shortName = false) const KDE_DEPRECATED;
00475
00489 QString monthNamePossessive(int i, bool shortName = false) const KDE_DEPRECATED;
00490
00501 QString weekDayName(int i, bool shortName = false) const KDE_DEPRECATED;
00502
00509 const KCalendarSystem * calendar() const;
00510
00518 QString calendarType() const;
00519
00528 void setCalendar(const QString & calendarType);
00529
00540 QString formatDateTime(const QDateTime &pDateTime,
00541 bool shortFormat = true,
00542 bool includeSecs = false) const;
00543
00553 double readMoney(const QString &numStr, bool * ok = 0) const;
00554
00564 double readNumber(const QString &numStr, bool * ok = 0) const;
00565
00576 QDate readDate(const QString &str, bool* ok = 0) const;
00577
00582 QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const;
00583
00584 enum ReadDateFlags {
00585 NormalFormat = 1,
00586 ShortFormat = 2
00587 };
00588
00602 QDate readDate(const QString &str, ReadDateFlags flags, bool *ok = 0) const;
00603
00615 QTime readTime(const QString &str, bool* ok = 0) const;
00616
00617 enum ReadTimeFlags {
00618 WithSeconds = 0,
00619 WithoutSeconds = 1
00620 };
00635 QTime readTime(const QString &str, ReadTimeFlags flags, bool *ok = 0) const;
00636
00644 QString language() const;
00645
00652 QString country() const;
00653
00667 QStringList languagesTwoAlpha() const;
00668
00677 QStringList languageList() const;
00678
00687 const char * encoding() const;
00688
00697 int encodingMib() const;
00706 QTextCodec * codecForEncoding() const;
00707
00716 int fileEncodingMib() const;
00717
00738 void setDateFormat(const QString & format);
00759 void setDateFormatShort(const QString & format);
00766 void setDateMonthNamePossessive(bool possessive);
00785 void setTimeFormat(const QString & format);
00786
00796 void setWeekStartsMonday(bool start) KDE_DEPRECATED;
00797
00804 void setWeekStartDay(int day);
00811 QString dateFormat() const;
00818 QString dateFormatShort() const;
00825 QString timeFormat() const;
00826
00832 void setDecimalSymbol(const QString & symbol);
00838 void setThousandsSeparator(const QString & separator);
00845 void setPositiveSign(const QString & sign);
00851 void setNegativeSign(const QString & sign);
00857 void setPositiveMonetarySignPosition(SignPosition signpos);
00863 void setNegativeMonetarySignPosition(SignPosition signpos);
00871 void setPositivePrefixCurrencySymbol(bool prefix);
00879 void setNegativePrefixCurrencySymbol(bool prefix);
00885 void setFracDigits(int digits);
00891 void setMonetaryThousandsSeparator(const QString & separator);
00898 void setMonetaryDecimalSymbol(const QString & symbol);
00904 void setCurrencySymbol(const QString & symbol);
00905
00911 int pageSize() const;
00912
00918 void setPageSize(int paperFormat);
00919
00924 enum MeasureSystem { Metric, Imperial };
00925
00931 MeasureSystem measureSystem() const;
00932
00938 void setMeasureSystem(MeasureSystem value);
00939
00950 void insertCatalogue(const QString& catalog);
00951
00957 void removeCatalogue(const QString &catalog);
00958
00963 void setActiveCatalogue(const QString &catalog);
00964
00971 QString translateQt(const char *context,
00972 const char *sourceText,
00973 const char *message) const;
00974
00980 QStringList allLanguagesTwoAlpha() const;
00981
00988 QString twoAlphaToLanguageName(const QString &code) const;
00989
00995 QStringList allCountriesTwoAlpha() const;
00996
01003 QString twoAlphaToCountryName(const QString &code) const;
01004
01014 static void splitLocale(const QString & str,
01015 QString & language,
01016 QString & country,
01017 QString & charset);
01018
01027 static void setMainCatalogue(const char *catalog);
01028
01035 static QString langLookup(const QString &fname, const char *rtype = "html");
01036
01042 static QString defaultLanguage();
01043
01049 static QString defaultCountry();
01050
01051
01055 static QString _initLanguage(KConfigBase *config);
01056
01057 #ifdef KDE_NO_COMPAT
01058 private:
01059 #endif
01060
01064 QString formatMoney(const QString &numStr) const KDE_DEPRECATED;
01065
01070 QString formatNumber(const QString &numStr) const KDE_DEPRECATED;
01071
01078 QString languages() const KDE_DEPRECATED;
01079
01084 bool setCharset(const QString & charset) KDE_DEPRECATED;
01085
01090 QString charset() const KDE_DEPRECATED;
01091
01092 protected:
01097 static void initInstance();
01098
01099 private:
01106 void initFormat(KConfig *config);
01107
01115 void initLanguage(KConfig * config, bool useEnv);
01116
01122 void initEncoding(KConfig * config);
01123
01129 void initCatalogue(const QString & catalog);
01130
01135 void initFileNameEncoding(KConfig *config);
01136
01140 static QCString encodeFileNameUTF8( const QString & fileName );
01141
01145 static QString decodeFileNameUTF8( const QCString & localFileName );
01146
01151 void initCatalogue( KCatalogue & catalog );
01152
01156 void doBindInit();
01157
01161 void doFormatInit() const;
01162
01166 void initFormat();
01167
01171 QString translate_priv(const char *index,
01172 const char *text,
01173 const char ** original = 0) const;
01174
01178 bool useDefaultLanguage() const;
01179
01183 bool isLanguageInstalled(const QString & language) const;
01184
01189 static QString catalogueFileName(const QString & language,
01190 const KCatalogue & catalog);
01191
01192 private:
01193
01194 QString m_decimalSymbol;
01195 QString m_thousandsSeparator;
01196 QString m_currencySymbol;
01197 QString m_monetaryDecimalSymbol;
01198 QString m_monetaryThousandsSeparator;
01199 QString m_positiveSign;
01200 QString m_negativeSign;
01201 int m_fracDigits;
01202 SignPosition m_positiveMonetarySignPosition;
01203 SignPosition m_negativeMonetarySignPosition;
01204
01205
01206 QString m_timeFormat;
01207 QString m_dateFormat;
01208 QString m_dateFormatShort;
01209
01210 QString m_language;
01211 QString m_country;
01212
01213 bool m_weekStartsMonday;
01214 bool m_positivePrefixCurrencySymbol;
01215 bool m_negativePrefixCurrencySymbol;
01216
01217 KLocalePrivate *d;
01218 };
01219
01220 #endif
This file is part of the documentation for kdecore Library Version 3.2.1.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Thu Mar 4 22:43:31 2004 by
doxygen 1.3.6-20040222 written by
Dimitri van Heesch, © 1997-2003