| # kdecore Library API Documentation
Overview | Class Hierarchy | Classes | Classes (annotated) | Members | Source Files

# klocale.h

    00001 // -*- c-basic-offset: 2 -*-
    00002 /* This file is part of the KDE libraries
    00003     Copyright (C) 1997 Stephan Kulow <coolo@kde.org>
    00004     Copyright (C) 1999-2001 Hans Petter Bieker <bieker@kde.org>
    00005     Copyright (c) 2002 Lukas Tinkl <lukas@kde.org>
    00006
    00007     This library is free software; you can redistribute it and/or
    00008     modify it under the terms of the GNU Library General Public
    00009     License as published by the Free Software Foundation; either
    00010     version 2 of the License, or (at your option) any later version.
    00011
    00012     This library is distributed in the hope that it will be useful,
    00013     but WITHOUT ANY WARRANTY; without even the implied warranty of
    00014     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    00015     Library General Public License for more details.
    00016
    00017     You should have received a copy of the GNU Library General Public License
    00018     along with this library; see the file COPYING.LIB.  If not, write to
    00019     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    00020     Boston, MA 02111-1307, USA.
    00021 */
    00022 #ifndef _KLOCALE_H
    00023 #define _KLOCALE_H
    00024
    00025 #include <qstring.h>
    00026
    00027 class QStringList;
    00028 class QTextCodec;
    00029 class QDate;
    00030 class QTime;
    00031 class QDateTime;
    00032
    00033 class KGlobal;
    00034 class KConfig;
    00035 class KConfigBase;
    00036 class KLocalePrivate;
    00037 class KCatalogue;
    00038
    00039 #ifndef I18N_NOOP
    00040 #define I18N_NOOP(x) (x)
    00041 #endif
    00042
    00054 QString i18n(const char *text);
    00055
    00062 QString i18n(const char *index, const char *text);
    00063
    00069 QString i18n(const char *singular, const char *plural, unsigned long n);
    00070
    00076 inline QString tr2i18n(const char* message, const char* =0) {
    00077   return i18n(message);
    00078 }
    00079
    00092 class KLocale
    00093 {
    00094   friend class KGlobal; // for initInstance()
    00095 public:
    00112   KLocale( const QString& catalogue, KConfig *config = 0 );
    00113
    00117   KLocale( const KLocale & rhs );
    00118
    00122   KLocale& operator= ( const KLocale & rhs );
    00123
    00127   ~KLocale();
    00128
    00147   QString translate( const char *index ) const;
    00148
    00174   QString translate( const char *index, const char *fallback) const;
    00175
    00186   QString translate( const char *singular, const char *plural,
    00187                      unsigned long n) const;
    00188
    00196 #ifndef KDE_NO_COMPAT
    00197   bool setCharset(const QString & charset);
    00198 #endif
    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
    00377 #ifndef KDE_NO_COMPAT
    00378   QString formatMoney(const QString &numStr) const;
    00379 #endif
    00380
    00393   QString formatNumber(double num, int precision = -1) const;
    00394
    00403 #ifndef KDE_NO_COMPAT
    00404   QString formatNumber(const QString &numStr) const;
    00405 #endif
    00406
    00415    bool nounDeclension() const;
    00416
    00426   QString formatDate(const QDate &pDate, bool shortFormat = false) const;
    00427
    00435   bool dateMonthNamePossessive() const;
    00436
    00447   QString formatTime(const QTime &pTime, bool includeSecs = false) const;
    00448
    00454   bool use12Clock() const;
    00455
    00465   bool weekStartsMonday() const; //### remove for KDE 4.0
    00466
    00473   int weekStartDay() const;
    00474
    00483   QString monthName(int i, bool shortName = false) const;
    00484
    00496   QString monthNamePossessive(int i, bool shortName = false) const;
    00497
    00506   QString weekDayName(int i, bool shortName = false) const;
    00507
    00518   QString formatDateTime(const QDateTime &pDateTime,
    00519                          bool shortFormat = true,
    00520                          bool includeSecs = false) const;
    00521
    00531   double readMoney(const QString &numStr, bool * ok = 0) const;
    00532
    00542   double readNumber(const QString &numStr, bool * ok = 0) const;
    00543
    00554   QDate readDate(const QString &str, bool* ok = 0) const;
    00555
    00560   QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const;
    00561
    00572   QTime readTime(const QString &str, bool* ok = 0) const;
    00573
    00581   QString language() const;
    00582
    00589   QString country() const;
    00590
    00596 #ifndef KDE_NO_COMPAT
    00597   QString languages() const;
    00598 #endif
    00599
    00613   QStringList languagesTwoAlpha() const;
    00614
    00623   QStringList languageList() const;
    00624
    00635 #ifndef KDE_NO_COMPAT
    00636   QString charset() const;
    00637 #endif
    00638
    00647   const char * encoding() const;
    00648
    00657   int encodingMib() const;
    00666   QTextCodec * codecForEncoding() const;
    00667
    00688   void setDateFormat(const QString & format);
    00709   void setDateFormatShort(const QString & format);
    00716   void setDateMonthNamePossessive(bool possessive);
    00735   void setTimeFormat(const QString & format);
    00736
    00746   void setWeekStartsMonday(bool start); //### remove for KDE 4.0
    00753   void setWeekStartDay(int day);
    00760   QString dateFormat() const;
    00767   QString dateFormatShort() const;
    00774   QString timeFormat() const;
    00775
    00781   void setDecimalSymbol(const QString & symbol);
    00787   void setThousandsSeparator(const QString & separator);
    00794   void setPositiveSign(const QString & sign);
    00800   void setNegativeSign(const QString & sign);
    00806   void setPositiveMonetarySignPosition(SignPosition signpos);
    00812   void setNegativeMonetarySignPosition(SignPosition signpos);
    00820   void setPositivePrefixCurrencySymbol(bool prefix);
    00828   void setNegativePrefixCurrencySymbol(bool prefix);
    00834   void setFracDigits(int digits);
    00840   void setMonetaryThousandsSeparator(const QString & separator);
    00847   void setMonetaryDecimalSymbol(const QString & symbol);
    00853   void setCurrencySymbol(const QString & symbol);
    00854
    00860   int pageSize() const;
    00861
    00867   void setPageSize(int paperFormat);
    00868
    00873   enum MeasureSystem { Metric, Imperial };
    00874
    00880   MeasureSystem measureSystem() const;
    00881
    00887   void setMeasureSystem(MeasureSystem value);
    00888
    00899   void insertCatalogue(const QString& catalogue);
    00900
    00906   void removeCatalogue(const QString &catalogue);
    00907
    00912   void setActiveCatalogue(const QString &catalogue);
    00913
    00920   QString translateQt(const char *context,
    00921                       const char *sourceText,
    00922                       const char *message) const;
    00923
    00929   QStringList allLanguagesTwoAlpha() const;
    00930
    00937   QString twoAlphaToLanguageName(const QString &code) const;
    00938
    00944   QStringList allCountriesTwoAlpha() const;
    00945
    00952   QString twoAlphaToCountryName(const QString &code) const;
    00953
    00963   static void splitLocale(const QString & str,
    00964                           QString & language,
    00965                           QString & country,
    00966                           QString & charset);
    00967
    00977   static void setMainCatalogue(const char *catalogue);
    00978
    00985   static QString langLookup(const QString &fname, const char *rtype = "html");
    00986
    00992   static QString defaultLanguage();
    00993
    00999   static QString defaultCountry();
    01000
    01001
    01005   static QString _initLanguage(KConfigBase *config);
    01006
    01007 protected:
    01012   static void initInstance();
    01013
    01014 private:
    01021   void initFormat(KConfig *config);
    01022
    01030   void initLanguage(KConfig * config, bool useEnv);
    01031
    01037   void initEncoding(KConfig * config);
    01038
    01044   void initCatalogue(const QString & catalogue);
    01045
    01050   void initFileNameEncoding(KConfig *config);
    01051
    01055   static QCString encodeFileNameUTF8( const QString & fileName );
    01056
    01060   static QString decodeFileNameUTF8( const QCString & localFileName );
    01061
    01065   QTime readTime(const QString &str, bool seconds, bool *ok) const;
    01066
    01070   QDate readDate(const QString &str, bool shortFormat, bool *ok) const;
    01071
    01076   void initCatalogue( KCatalogue & catalogue );
    01077
    01081   void doBindInit();
    01082
    01086   void doFormatInit() const;
    01087
    01091   void initFormat();
    01092
    01096   QString translate_priv(const char *index,
    01097                          const char *text,
    01098                          const char ** original = 0) const;
    01099
    01103   bool useDefaultLanguage() const;
    01104
    01108   bool isLanguageInstalled(const QString & language) const;
    01109
    01114   static QString catalogueFileName(const QString & language,
    01115                                    const KCatalogue & catalogue);
    01116
    01117 private:
    01118   // Numbers and money
    01119   QString m_decimalSymbol;
    01120   QString m_thousandsSeparator;
    01121   QString m_currencySymbol;
    01122   QString m_monetaryDecimalSymbol;
    01123   QString m_monetaryThousandsSeparator;
    01124   QString m_positiveSign;
    01125   QString m_negativeSign;
    01126   int m_fracDigits;
    01127   SignPosition m_positiveMonetarySignPosition;
    01128   SignPosition m_negativeMonetarySignPosition;
    01129
    01130   // Date and time
    01131   QString m_timeFormat;
    01132   QString m_dateFormat;
    01133   QString m_dateFormatShort;
    01134
    01135   QString m_language;
    01136   QString m_country;
    01137
    01138   bool m_weekStartsMonday; //### remove for KDE 4.0
    01139   bool m_positivePrefixCurrencySymbol;
    01140   bool m_negativePrefixCurrencySymbol;
    01141
    01142   KLocalePrivate *d;
    01143 };
    01144
    01145 #endif

This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 12:46:39 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001