• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • tdecore
 

tdecore

tdelocale.h

Go to the documentation of this file.
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-2003 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., 51 Franklin Street, Fifth Floor,
00020     Boston, MA 02110-1301, USA.
00021 */
00022 #ifndef _TDELOCALE_H
00023 #define _TDELOCALE_H
00024 
00025 #include <tqstring.h>
00026 #include <tdelibs_export.h>
00027 
00028 class TQStringList;
00029 class TQTextCodec;
00030 class TQDate;
00031 class TQTime;
00032 class TQDateTime;
00033 
00034 class TDEGlobal;
00035 class TDEConfig;
00036 class TDEConfigBase;
00037 class TDELocalePrivate;
00038 class KCatalogue;
00039 class KCalendarSystem;
00040 
00045 #ifndef I18N_NOOP
00046 
00052 #define I18N_NOOP(x) x
00053 #endif
00054 
00055 #ifndef I18N_NOOP2
00056 
00063 #define I18N_NOOP2(comment,x) x
00064 #endif
00065 
00078 TDECORE_EXPORT TQString i18n(const char *text);
00079 
00087 TDECORE_EXPORT TQString i18n(const char *comment, const char *text);
00088 
00100 TDECORE_EXPORT TQString i18n(const char *singular, const char *plural, unsigned long n);
00101 
00108 inline TQString tr2i18n(const char* message, const char* =0) {
00109   return i18n(message);
00110 }
00111 
00124 class TDECORE_EXPORT TDELocale
00125 {
00126   friend class TDEGlobal; // for initInstance()
00127 public:
00144   TDELocale( const TQString& catalog, TDEConfig *config = 0 );
00145 
00149   TDELocale( const TDELocale & rhs );
00150 
00154   TDELocale& operator= ( const TDELocale & rhs );
00155 
00159   ~TDELocale();
00160 
00179   TQString translate( const char *index ) const;
00180 
00206   TQString translate( const char *comment, const char *fallback) const;
00207 
00218   TQString translate( const char *singular, const char *plural,
00219              unsigned long n) const;
00220 
00228   bool setEncoding(int mibEnum);
00229 
00239   bool setLanguage(const TQString & language);
00240 
00250   bool setLanguage(const TQStringList & languages);
00251  
00261   bool setCountry(const TQString & country);
00262 
00267   enum SignPosition { ParensAround = 0, BeforeQuantityMoney = 1,
00268               AfterQuantityMoney = 2,
00269               BeforeMoney = 3, AfterMoney = 4 };
00270 
00277   TQString decimalSymbol() const;
00278 
00286   TQString thousandsSeparator() const;
00287 
00294   TQString currencySymbol() const;
00295 
00303   TQString monetaryDecimalSymbol() const;
00304 
00312   TQString monetaryThousandsSeparator() const;
00313 
00320   TQString positiveSign() const;
00321 
00328   TQString negativeSign() const;
00329 
00336   int fracDigits() const;
00337 
00344   bool positivePrefixCurrencySymbol() const;
00345 
00352   bool negativePrefixCurrencySymbol() const;
00353 
00361   SignPosition positiveMonetarySignPosition() const;
00362 
00370   SignPosition negativeMonetarySignPosition() const;
00371 
00386   TQString formatMoney(double num,
00387               const TQString & currency = TQString::null,
00388               int digits = -1) const;
00389 
00405   TQString formatNumber(double num, int precision = -1) const;
00406 
00414   TQString formatNumber(const TQString &numStr) const KDE_DEPRECATED;
00415 
00429   TQString formatNumber(const TQString &numStr, bool round, int precision) const;
00430 
00442   TQString formatLong(long num) const;
00443 
00452    bool nounDeclension() const;
00453 
00463   TQString formatDate(const TQDate &pDate, bool shortFormat = false) const;
00464 
00472   bool dateMonthNamePossessive() const;
00473 
00486   TQString formatTime(const TQTime &pTime, bool includeSecs, bool isDuration /*=false*/) const;
00487 
00498   TQString formatTime(const TQTime &pTime, bool includeSecs = false) const; // BIC: merge with above
00499 
00505   bool use12Clock() const;
00506 
00516   bool weekStartsMonday() const KDE_DEPRECATED; //### remove for KDE 4.0
00517 
00524   int weekStartDay() const;
00525 
00546   TQString monthName(int i, bool shortName = false) const KDE_DEPRECATED;
00547 
00571   TQString monthNamePossessive(int i, bool shortName = false) const KDE_DEPRECATED;
00572 
00583   TQString weekDayName(int i, bool shortName = false) const KDE_DEPRECATED;
00584 
00591   const KCalendarSystem * calendar() const;
00592 
00600   TQString calendarType() const;
00601 
00610   void setCalendar(const TQString & calendarType);
00611 
00622   TQString formatDateTime(const TQDateTime &pDateTime,
00623              bool shortFormat = true,
00624              bool includeSecs = false) const;
00625 
00635   double readMoney(const TQString &numStr, bool * ok = 0) const;
00636 
00646   double readNumber(const TQString &numStr, bool * ok = 0) const;
00647 
00658   TQDate readDate(const TQString &str, bool* ok = 0) const;
00659 
00664   TQDate readDate( const TQString &intstr, const TQString &fmt, bool* ok = 0) const;
00665 
00666   enum ReadDateFlags {
00667       NormalFormat = 1,
00668       ShortFormat = 2
00669   };
00670 
00684   TQDate readDate(const TQString &str, ReadDateFlags flags, bool *ok = 0) const;
00685 
00698   TQTime readTime(const TQString &str, bool* ok = 0) const;
00699 
00700   enum ReadTimeFlags {
00701       WithSeconds = 0, // default (no flag set)
00702       WithoutSeconds = 1
00703   }; // (maybe use this enum as a bitfield, if adding independent features?)
00718   TQTime readTime(const TQString &str, ReadTimeFlags flags, bool *ok = 0) const;
00719 
00727   TQString language() const;
00728 
00735   TQString country() const;
00736 
00750   TQStringList languagesTwoAlpha() const;
00751 
00760   TQStringList languageList() const;
00761 
00770   const char * encoding() const;
00771 
00780   int encodingMib() const;
00789   TQTextCodec * codecForEncoding() const;
00790 
00799   int fileEncodingMib() const;
00800 
00823   void setDateFormat(const TQString & format);
00846   void setDateFormatShort(const TQString & format);
00853   void setDateMonthNamePossessive(bool possessive);
00873   void setTimeFormat(const TQString & format);
00874 
00884   void setWeekStartsMonday(bool start) KDE_DEPRECATED; //### remove for KDE 4.0
00885 
00892   void setWeekStartDay(int day);
00899   TQString dateFormat() const;
00906   TQString dateFormatShort() const;
00913   TQString timeFormat() const;
00914 
00920   void setDecimalSymbol(const TQString & symbol);
00926   void setThousandsSeparator(const TQString & separator);
00933   void setPositiveSign(const TQString & sign);
00939   void setNegativeSign(const TQString & sign);
00945   void setPositiveMonetarySignPosition(SignPosition signpos);
00951   void setNegativeMonetarySignPosition(SignPosition signpos);
00959   void setPositivePrefixCurrencySymbol(bool prefix);
00967   void setNegativePrefixCurrencySymbol(bool prefix);
00973   void setFracDigits(int digits);
00979   void setMonetaryThousandsSeparator(const TQString & separator);
00986   void setMonetaryDecimalSymbol(const TQString & symbol);
00992   void setCurrencySymbol(const TQString & symbol);
00993 
00999   int pageSize() const;
01000 
01006   void setPageSize(int paperFormat);
01007 
01012   enum MeasureSystem { Metric, Imperial };
01013 
01019   MeasureSystem measureSystem() const;
01020 
01026   void setMeasureSystem(MeasureSystem value);
01027   
01038   void insertCatalogue(const TQString& catalog);
01039 
01045   void removeCatalogue(const TQString &catalog);
01046 
01051   void setActiveCatalogue(const TQString &catalog);
01052 
01059   TQString translateQt(const char *context,
01060               const char *sourceText,
01061               const char *message) const;
01062 
01068   TQStringList allLanguagesTwoAlpha() const;
01069 
01076   TQString twoAlphaToLanguageName(const TQString &code) const;
01077 
01083   TQStringList allCountriesTwoAlpha() const;
01084 
01091   TQString twoAlphaToCountryName(const TQString &code) const;
01092 
01102   static void splitLocale(const TQString & str,
01103               TQString & language,
01104               TQString & country,
01105               TQString & charset);
01106 
01115   static void setMainCatalogue(const char *catalog);
01116 
01123   static TQString langLookup(const TQString &fname, const char *rtype = "html");
01124 
01130   static TQString defaultLanguage();
01131 
01137   static TQString defaultCountry();
01138 
01139 
01143   static TQString _initLanguage(TDEConfigBase *config);
01144 
01145 #ifdef KDE_NO_COMPAT
01146 private:
01147 #endif
01148 
01152   TQString formatMoney(const TQString &numStr) const KDE_DEPRECATED;
01153 
01160   TQString languages() const KDE_DEPRECATED;
01161 
01166   bool setCharset(const TQString & charset) KDE_DEPRECATED;
01167 
01172   TQString charset() const KDE_DEPRECATED;
01173 
01174 protected:
01179   static void initInstance();
01180 
01181 private:
01188   void initFormat(TDEConfig *config);
01189   
01196   void initMainCatalogues(const TQString & catalog);
01197   
01206   void initLanguageList(TDEConfig * config, bool useEnv);
01207 
01213   void initEncoding(TDEConfig * config);
01214 
01219   void initFileNameEncoding(TDEConfig *config);
01220 
01224 #ifdef USE_QT3
01225   static TQCString encodeFileNameUTF8( const TQString & fileName );
01226 #endif // USE_QT3
01227 #ifdef USE_QT4
01228   static QByteArray encodeFileNameUTF8( const QString & fileName );
01229 #endif // USE_QT4
01230 
01234 #ifdef USE_QT3
01235   static TQString decodeFileNameUTF8( const TQCString & localFileName );
01236 #endif // USE_QT3
01237 #ifdef USE_QT4
01238   static QString decodeFileNameUTF8( const QByteArray & localFileName );
01239 #endif // USE_QT4
01240 
01245   void initCatalogue( KCatalogue & catalog );
01246 
01250   void doFormatInit() const;
01251 
01255   void initFormat();
01256 
01260   TQString translate_priv(const char *index,
01261              const char *text,
01262              const char ** original = 0,
01263              int* pluralType = 0) const;
01264 
01268   bool useDefaultLanguage() const;
01269 
01273   bool isLanguageInstalled(const TQString & language) const;
01274   
01279   void updateCatalogues( );
01280   
01284   void initPluralTypes( );
01290   int pluralType( const TQString & language );
01291   
01298   int pluralType( const KCatalogue& catalog );
01305   // const KCatalogue * catalog( const TQString & language, const TQString & name );
01306   
01307 
01312   static TQString catalogueFileName(const TQString & language,
01313                    const KCatalogue & catalog);
01314 public:
01320    bool isApplicationTranslatedInto( const TQString & language);
01321    
01322 private:
01323   // Numbers and money
01324   TQString m_decimalSymbol;
01325   TQString m_thousandsSeparator;
01326   TQString m_currencySymbol;
01327   TQString m_monetaryDecimalSymbol;
01328   TQString m_monetaryThousandsSeparator;
01329   TQString m_positiveSign;
01330   TQString m_negativeSign;
01331   int m_fracDigits;
01332   SignPosition m_positiveMonetarySignPosition;
01333   SignPosition m_negativeMonetarySignPosition;
01334 
01335   // Date and time
01336   TQString m_timeFormat;
01337   TQString m_dateFormat;
01338   TQString m_dateFormatShort;
01339 
01340   TQString m_language;
01341   TQString m_country;
01342 
01343   bool m_weekStartsMonday; //### remove for KDE 4.0
01344   bool m_positivePrefixCurrencySymbol;
01345   bool m_negativePrefixCurrencySymbol;
01346 
01347   TDELocalePrivate *d;
01348 };
01349 
01350 #endif

tdecore

Skip menu "tdecore"
  • Main Page
  • Modules
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

tdecore

Skip menu "tdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.6.3
This website is maintained by Timothy Pearson.