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

tdecore

  • tdecore
tdelocale.h
Go to the documentation of this file.
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 _TDELOCALE_H
22 #define _TDELOCALE_H
23 
24 #include <tqstring.h>
25 #include <tdelibs_export.h>
26 
27 class TQStringList;
28 class TQTextCodec;
29 class TQDate;
30 class TQTime;
31 class TQDateTime;
32 
33 class TDEGlobal;
34 class TDEConfig;
35 class TDEConfigBase;
36 class TDELocalePrivate;
37 class KCatalogue;
38 class KCalendarSystem;
39 
44 #ifndef I18N_NOOP
45 
51 #define I18N_NOOP(x) x
52 #endif
53 
54 #ifndef I18N_NOOP2
55 
62 #define I18N_NOOP2(comment,x) x
63 #endif
64 
77 TDECORE_EXPORT TQString i18n(const char *text);
78 
86 TDECORE_EXPORT TQString i18n(const char *comment, const char *text);
87 
99 TDECORE_EXPORT TQString i18n(const char *singular, const char *plural, unsigned long n);
100 
107 inline TQString tr2i18n(const char* message, const char* =0) {
108  return i18n(message);
109 }
110 
123 class TDECORE_EXPORT TDELocale
124 {
125  friend class TDEGlobal; // for initInstance()
126 public:
143  TDELocale( const TQString& catalog, TDEConfig *config = 0 );
144 
148  TDELocale( const TDELocale & rhs );
149 
153  TDELocale& operator= ( const TDELocale & rhs );
154 
158  ~TDELocale();
159 
178  TQString translate( const char *index ) const;
179 
205  TQString translate( const char *comment, const char *fallback) const;
206 
217  TQString translate( const char *singular, const char *plural,
218  unsigned long n) const;
219 
227  bool setEncoding(int mibEnum);
228 
238  bool setLanguage(const TQString & language);
239 
249  bool setLanguage(const TQStringList & languages);
250 
260  bool setCountry(const TQString & country);
261 
266  enum SignPosition { ParensAround = 0, BeforeQuantityMoney = 1,
267  AfterQuantityMoney = 2,
268  BeforeMoney = 3, AfterMoney = 4 };
269 
276  TQString decimalSymbol() const;
277 
285  TQString thousandsSeparator() const;
286 
293  TQString currencySymbol() const;
294 
302  TQString monetaryDecimalSymbol() const;
303 
311  TQString monetaryThousandsSeparator() const;
312 
319  TQString positiveSign() const;
320 
327  TQString negativeSign() const;
328 
335  int fracDigits() const;
336 
343  bool positivePrefixCurrencySymbol() const;
344 
351  bool negativePrefixCurrencySymbol() const;
352 
360  SignPosition positiveMonetarySignPosition() const;
361 
369  SignPosition negativeMonetarySignPosition() const;
370 
385  TQString formatMoney(double num,
386  const TQString & currency = TQString::null,
387  int digits = -1) const;
388 
404  TQString formatNumber(double num, int precision = -1) const;
405 
413  TQString formatNumber(const TQString &numStr) const KDE_DEPRECATED;
414 
428  TQString formatNumber(const TQString &numStr, bool round, int precision) const;
429 
441  TQString formatLong(long num) const;
442 
451  bool nounDeclension() const;
452 
462  TQString formatDate(const TQDate &pDate, bool shortFormat = false) const;
463 
471  bool dateMonthNamePossessive() const;
472 
485  TQString formatTime(const TQTime &pTime, bool includeSecs, bool isDuration /*=false*/) const;
486 
497  TQString formatTime(const TQTime &pTime, bool includeSecs = false) const; // BIC: merge with above
498 
504  bool use12Clock() const;
505 
515  bool weekStartsMonday() const KDE_DEPRECATED; //### remove for KDE 4.0
516 
523  int weekStartDay() const;
524 
545  TQString monthName(int i, bool shortName = false) const KDE_DEPRECATED;
546 
570  TQString monthNamePossessive(int i, bool shortName = false) const KDE_DEPRECATED;
571 
582  TQString weekDayName(int i, bool shortName = false) const KDE_DEPRECATED;
583 
590  const KCalendarSystem * calendar() const;
591 
599  TQString calendarType() const;
600 
609  void setCalendar(const TQString & calendarType);
610 
621  TQString formatDateTime(const TQDateTime &pDateTime,
622  bool shortFormat = true,
623  bool includeSecs = false) const;
624 
634  double readMoney(const TQString &numStr, bool * ok = 0) const;
635 
645  double readNumber(const TQString &numStr, bool * ok = 0) const;
646 
657  TQDate readDate(const TQString &str, bool* ok = 0) const;
658 
663  TQDate readDate( const TQString &intstr, const TQString &fmt, bool* ok = 0) const;
664 
665  enum ReadDateFlags {
666  NormalFormat = 1,
667  ShortFormat = 2
668  };
669 
683  TQDate readDate(const TQString &str, ReadDateFlags flags, bool *ok = 0) const;
684 
697  TQTime readTime(const TQString &str, bool* ok = 0) const;
698 
699  enum ReadTimeFlags {
700  WithSeconds = 0, // default (no flag set)
701  WithoutSeconds = 1
702  }; // (maybe use this enum as a bitfield, if adding independent features?)
717  TQTime readTime(const TQString &str, ReadTimeFlags flags, bool *ok = 0) const;
718 
726  TQString language() const;
727 
734  TQString country() const;
735 
749  TQStringList languagesTwoAlpha() const;
750 
759  TQStringList languageList() const;
760 
769  const char * encoding() const;
770 
779  int encodingMib() const;
788  TQTextCodec * codecForEncoding() const;
789 
798  int fileEncodingMib() const;
799 
822  void setDateFormat(const TQString & format);
845  void setDateFormatShort(const TQString & format);
852  void setDateMonthNamePossessive(bool possessive);
872  void setTimeFormat(const TQString & format);
873 
883  void setWeekStartsMonday(bool start) KDE_DEPRECATED; //### remove for KDE 4.0
884 
891  void setWeekStartDay(int day);
898  TQString dateFormat() const;
905  TQString dateFormatShort() const;
912  TQString timeFormat() const;
913 
919  void setDecimalSymbol(const TQString & symbol);
925  void setThousandsSeparator(const TQString & separator);
932  void setPositiveSign(const TQString & sign);
938  void setNegativeSign(const TQString & sign);
944  void setPositiveMonetarySignPosition(SignPosition signpos);
950  void setNegativeMonetarySignPosition(SignPosition signpos);
958  void setPositivePrefixCurrencySymbol(bool prefix);
966  void setNegativePrefixCurrencySymbol(bool prefix);
972  void setFracDigits(int digits);
978  void setMonetaryThousandsSeparator(const TQString & separator);
985  void setMonetaryDecimalSymbol(const TQString & symbol);
991  void setCurrencySymbol(const TQString & symbol);
992 
998  int pageSize() const;
999 
1005  void setPageSize(int paperFormat);
1006 
1011  enum MeasureSystem { Metric, Imperial };
1012 
1018  MeasureSystem measureSystem() const;
1019 
1025  void setMeasureSystem(MeasureSystem value);
1026 
1037  void insertCatalogue(const TQString& catalog);
1038 
1044  void removeCatalogue(const TQString &catalog);
1045 
1050  void setActiveCatalogue(const TQString &catalog);
1051 
1058  TQString translateQt(const char *context,
1059  const char *sourceText,
1060  const char *message) const;
1061 
1067  TQStringList allLanguagesTwoAlpha() const;
1068 
1075  TQString twoAlphaToLanguageName(const TQString &code) const;
1076 
1082  TQStringList allCountriesTwoAlpha() const;
1083 
1090  TQString twoAlphaToCountryName(const TQString &code) const;
1091 
1101  static void splitLocale(const TQString & str,
1102  TQString & language,
1103  TQString & country,
1104  TQString & charset);
1105 
1114  static void setMainCatalogue(const char *catalog);
1115 
1122  static TQString langLookup(const TQString &fname, const char *rtype = "html");
1123 
1129  static TQString defaultLanguage();
1130 
1136  static TQString defaultCountry();
1137 
1138 
1142  static TQString _initLanguage(TDEConfigBase *config);
1143 
1144 #ifdef KDE_NO_COMPAT
1145 private:
1146 #endif
1147 
1151  TQString formatMoney(const TQString &numStr) const KDE_DEPRECATED;
1152 
1159  TQString languages() const KDE_DEPRECATED;
1160 
1165  bool setCharset(const TQString & charset) KDE_DEPRECATED;
1166 
1171  TQString charset() const KDE_DEPRECATED;
1172 
1173 protected:
1178  static void initInstance();
1179 
1180 private:
1187  void initFormat(TDEConfig *config);
1188 
1195  void initMainCatalogues(const TQString & catalog);
1196 
1205  void initLanguageList(TDEConfig * config, bool useEnv);
1206 
1212  void initEncoding(TDEConfig * config);
1213 
1218  void initFileNameEncoding(TDEConfig *config);
1219 
1223 #ifdef USE_QT3
1224  static TQCString encodeFileNameUTF8( const TQString & fileName );
1225 #endif // USE_QT3
1226 #ifdef USE_QT4
1227  static QByteArray encodeFileNameUTF8( const QString & fileName );
1228 #endif // USE_QT4
1229 
1233 #ifdef USE_QT3
1234  static TQString decodeFileNameUTF8( const TQCString & localFileName );
1235 #endif // USE_QT3
1236 #ifdef USE_QT4
1237  static QString decodeFileNameUTF8( const QByteArray & localFileName );
1238 #endif // USE_QT4
1239 
1244  void initCatalogue( KCatalogue & catalog );
1245 
1249  void doFormatInit() const;
1250 
1254  void initFormat();
1255 
1259  TQString translate_priv(const char *index,
1260  const char *text,
1261  const char ** original = 0,
1262  int* pluralType = 0) const;
1263 
1267  bool useDefaultLanguage() const;
1268 
1272  bool isLanguageInstalled(const TQString & language) const;
1273 
1278  void updateCatalogues( );
1279 
1283  void initPluralTypes( );
1289  int pluralType( const TQString & language );
1290 
1297  int pluralType( const KCatalogue& catalog );
1304  // const KCatalogue * catalog( const TQString & language, const TQString & name );
1305 
1306 
1311  static TQString catalogueFileName(const TQString & language,
1312  const KCatalogue & catalog);
1313 public:
1319  bool isApplicationTranslatedInto( const TQString & language);
1320 
1321 private:
1322  // Numbers and money
1323  TQString m_decimalSymbol;
1324  TQString m_thousandsSeparator;
1325  TQString m_currencySymbol;
1326  TQString m_monetaryDecimalSymbol;
1327  TQString m_monetaryThousandsSeparator;
1328  TQString m_positiveSign;
1329  TQString m_negativeSign;
1330  int m_fracDigits;
1331  SignPosition m_positiveMonetarySignPosition;
1332  SignPosition m_negativeMonetarySignPosition;
1333 
1334  // Date and time
1335  TQString m_timeFormat;
1336  TQString m_dateFormat;
1337  TQString m_dateFormatShort;
1338 
1339  TQString m_language;
1340  TQString m_country;
1341 
1342  bool m_weekStartsMonday; //### remove for KDE 4.0
1343  bool m_positivePrefixCurrencySymbol;
1344  bool m_negativePrefixCurrencySymbol;
1345 
1346  TDELocalePrivate *d;
1347 };
1348 
1349 #endif
TDEConfig
Access KDE Configuration entries.
Definition: tdeconfig.h:43
TDEGlobal
Access to the KDE global objects.
Definition: tdeglobal.h:48
TDELocale::i18n
TQString i18n(const char *text)
Definition: tdelocale.cpp:1976
KCalendarSystem
CalendarSystem abstract class, default derived kde gregorian class and factory class.
Definition: kcalendarsystem.h:42
TDEConfigBase
KDE Configuration Management abstract base class.
Definition: tdeconfigbase.h:70
TDELocale::MeasureSystem
MeasureSystem
The Metric system will give you information in mm, while the Imperial system will give you informatio...
Definition: tdelocale.h:1011
TDELocale::tr2i18n
TQString tr2i18n(const char *message, const char *=0)
Definition: tdelocale.h:107
TDELocale
TDELocale provides support for country specific stuff like the national language. ...
Definition: tdelocale.h:123
KCatalogue
This class abstracts a gettext message catalog.
Definition: kcatalogue.h:37
TDELocale::SignPosition
SignPosition
Various positions for where to place the positive or negative sign when they are related to a monetar...
Definition: tdelocale.h:266
TDEGlobal::config
static TDEConfig * config()
Returns the general config object.
Definition: tdeglobal.cpp:65

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
  •     tdecore
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  • tdeioslave
  •   http
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for tdecore by doxygen 1.8.8
This website is maintained by Timothy Pearson.