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

kdecore

  • kdecore
klocale.h
Go to the documentation of this file.
1 // -*- c-basic-offset: 2 -*-
2 /* This file is part of the KDE libraries
3  Copyright (C) 1997 Stephan Kulow <coolo@kde.org>
4  Copyright (C) 1999-2003 Hans Petter Bieker <bieker@kde.org>
5  Copyright (c) 2002 Lukas Tinkl <lukas@kde.org>
6 
7  This library is free software; you can redistribute it and/or
8  modify it under the terms of the GNU Library General Public
9  License as published by the Free Software Foundation; either
10  version 2 of the License, or (at your option) any later version.
11 
12  This library is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  Library General Public License for more details.
16 
17  You should have received a copy of the GNU Library General Public License
18  along with this library; see the file COPYING.LIB. If not, write to
19  the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20  Boston, MA 02110-1301, USA.
21 */
22 #ifndef _KLOCALE_H
23 #define _KLOCALE_H
24 
25 #include <tqstring.h>
26 #include <kdelibs_export.h>
27 
28 class TQStringList;
29 class TQTextCodec;
30 class TQDate;
31 class TQTime;
32 class TQDateTime;
33 
34 class KGlobal;
35 class KConfig;
36 class KConfigBase;
37 class KLocalePrivate;
38 class KCatalogue;
39 class KCalendarSystem;
40 
45 #ifndef I18N_NOOP
52 #define I18N_NOOP(x) x
53 #endif
54 
55 #ifndef I18N_NOOP2
63 #define I18N_NOOP2(comment,x) x
64 #endif
65 
78 KDECORE_EXPORT TQString i18n(const char *text);
79 
87 KDECORE_EXPORT TQString i18n(const char *comment, const char *text);
88 
100 KDECORE_EXPORT TQString i18n(const char *singular, const char *plural, unsigned long n);
101 
108 inline TQString tr2i18n(const char* message, const char* =0) {
109  return i18n(message);
110 }
111 
124 class KDECORE_EXPORT KLocale
125 {
126  friend class KGlobal; // for initInstance()
127 public:
144  KLocale( const TQString& catalog, KConfig *config = 0 );
145 
149  KLocale( const KLocale & rhs );
150 
154  KLocale& operator= ( const KLocale & rhs );
155 
159  ~KLocale();
160 
179  TQString translate( const char *index ) const;
180 
206  TQString translate( const char *comment, const char *fallback) const;
207 
218  TQString translate( const char *singular, const char *plural,
219  unsigned long n) const;
220 
228  bool setEncoding(int mibEnum);
229 
239  bool setLanguage(const TQString & language);
240 
250  bool setLanguage(const TQStringList & languages);
251 
261  bool setCountry(const TQString & country);
262 
267  enum SignPosition { ParensAround = 0, BeforeQuantityMoney = 1,
268  AfterQuantityMoney = 2,
269  BeforeMoney = 3, AfterMoney = 4 };
270 
277  TQString decimalSymbol() const;
278 
286  TQString thousandsSeparator() const;
287 
294  TQString currencySymbol() const;
295 
303  TQString monetaryDecimalSymbol() const;
304 
312  TQString monetaryThousandsSeparator() const;
313 
320  TQString positiveSign() const;
321 
328  TQString negativeSign() const;
329 
336  int fracDigits() const;
337 
344  bool positivePrefixCurrencySymbol() const;
345 
352  bool negativePrefixCurrencySymbol() const;
353 
361  SignPosition positiveMonetarySignPosition() const;
362 
370  SignPosition negativeMonetarySignPosition() const;
371 
386  TQString formatMoney(double num,
387  const TQString & currency = TQString::null,
388  int digits = -1) const;
389 
405  TQString formatNumber(double num, int precision = -1) const;
406 
414  TQString formatNumber(const TQString &numStr) const KDE_DEPRECATED;
415 
429  TQString formatNumber(const TQString &numStr, bool round, int precision) const;
430 
442  TQString formatLong(long num) const;
443 
452  bool nounDeclension() const;
453 
463  TQString formatDate(const TQDate &pDate, bool shortFormat = false) const;
464 
472  bool dateMonthNamePossessive() const;
473 
486  TQString formatTime(const TQTime &pTime, bool includeSecs, bool isDuration /*=false*/) const;
487 
498  TQString formatTime(const TQTime &pTime, bool includeSecs = false) const; // BIC: merge with above
499 
505  bool use12Clock() const;
506 
516  bool weekStartsMonday() const KDE_DEPRECATED; //### remove for KDE 4.0
517 
524  int weekStartDay() const;
525 
546  TQString monthName(int i, bool shortName = false) const KDE_DEPRECATED;
547 
571  TQString monthNamePossessive(int i, bool shortName = false) const KDE_DEPRECATED;
572 
583  TQString weekDayName(int i, bool shortName = false) const KDE_DEPRECATED;
584 
591  const KCalendarSystem * calendar() const;
592 
600  TQString calendarType() const;
601 
610  void setCalendar(const TQString & calendarType);
611 
622  TQString formatDateTime(const TQDateTime &pDateTime,
623  bool shortFormat = true,
624  bool includeSecs = false) const;
625 
635  double readMoney(const TQString &numStr, bool * ok = 0) const;
636 
646  double readNumber(const TQString &numStr, bool * ok = 0) const;
647 
658  TQDate readDate(const TQString &str, bool* ok = 0) const;
659 
664  TQDate readDate( const TQString &intstr, const TQString &fmt, bool* ok = 0) const;
665 
666  enum ReadDateFlags {
667  NormalFormat = 1,
668  ShortFormat = 2
669  };
670 
684  TQDate readDate(const TQString &str, ReadDateFlags flags, bool *ok = 0) const;
685 
698  TQTime readTime(const TQString &str, bool* ok = 0) const;
699 
700  enum ReadTimeFlags {
701  WithSeconds = 0, // default (no flag set)
702  WithoutSeconds = 1
703  }; // (maybe use this enum as a bitfield, if adding independent features?)
718  TQTime readTime(const TQString &str, ReadTimeFlags flags, bool *ok = 0) const;
719 
727  TQString language() const;
728 
735  TQString country() const;
736 
750  TQStringList languagesTwoAlpha() const;
751 
760  TQStringList languageList() const;
761 
770  const char * encoding() const;
771 
780  int encodingMib() const;
789  TQTextCodec * codecForEncoding() const;
790 
799  int fileEncodingMib() const;
800 
823  void setDateFormat(const TQString & format);
846  void setDateFormatShort(const TQString & format);
853  void setDateMonthNamePossessive(bool possessive);
873  void setTimeFormat(const TQString & format);
874 
884  void setWeekStartsMonday(bool start) KDE_DEPRECATED; //### remove for KDE 4.0
885 
892  void setWeekStartDay(int day);
899  TQString dateFormat() const;
906  TQString dateFormatShort() const;
913  TQString timeFormat() const;
914 
920  void setDecimalSymbol(const TQString & symbol);
926  void setThousandsSeparator(const TQString & separator);
933  void setPositiveSign(const TQString & sign);
939  void setNegativeSign(const TQString & sign);
945  void setPositiveMonetarySignPosition(SignPosition signpos);
951  void setNegativeMonetarySignPosition(SignPosition signpos);
959  void setPositivePrefixCurrencySymbol(bool prefix);
967  void setNegativePrefixCurrencySymbol(bool prefix);
973  void setFracDigits(int digits);
979  void setMonetaryThousandsSeparator(const TQString & separator);
986  void setMonetaryDecimalSymbol(const TQString & symbol);
992  void setCurrencySymbol(const TQString & symbol);
993 
999  int pageSize() const;
1000 
1006  void setPageSize(int paperFormat);
1007 
1012  enum MeasureSystem { Metric, Imperial };
1013 
1019  MeasureSystem measureSystem() const;
1020 
1026  void setMeasureSystem(MeasureSystem value);
1027 
1038  void insertCatalogue(const TQString& catalog);
1039 
1045  void removeCatalogue(const TQString &catalog);
1046 
1051  void setActiveCatalogue(const TQString &catalog);
1052 
1059  TQString translateQt(const char *context,
1060  const char *sourceText,
1061  const char *message) const;
1062 
1068  TQStringList allLanguagesTwoAlpha() const;
1069 
1076  TQString twoAlphaToLanguageName(const TQString &code) const;
1077 
1083  TQStringList allCountriesTwoAlpha() const;
1084 
1091  TQString twoAlphaToCountryName(const TQString &code) const;
1092 
1102  static void splitLocale(const TQString & str,
1103  TQString & language,
1104  TQString & country,
1105  TQString & charset);
1106 
1115  static void setMainCatalogue(const char *catalog);
1116 
1123  static TQString langLookup(const TQString &fname, const char *rtype = "html");
1124 
1130  static TQString defaultLanguage();
1131 
1137  static TQString defaultCountry();
1138 
1139 
1143  static TQString _initLanguage(KConfigBase *config);
1144 
1145 #ifdef KDE_NO_COMPAT
1146 private:
1147 #endif
1152  TQString formatMoney(const TQString &numStr) const KDE_DEPRECATED;
1153 
1160  TQString languages() const KDE_DEPRECATED;
1161 
1166  bool setCharset(const TQString & charset) KDE_DEPRECATED;
1167 
1172  TQString charset() const KDE_DEPRECATED;
1173 
1174 protected:
1179  static void initInstance();
1180 
1181 private:
1188  void initFormat(KConfig *config);
1189 
1196  void initMainCatalogues(const TQString & catalog);
1197 
1206  void initLanguageList(KConfig * config, bool useEnv);
1207 
1213  void initEncoding(KConfig * config);
1214 
1219  void initFileNameEncoding(KConfig *config);
1220 
1224 #ifdef USE_QT3
1225  static TQCString encodeFileNameUTF8( const TQString & fileName );
1226 #endif // USE_QT3
1227 #ifdef USE_QT4
1228  static QByteArray encodeFileNameUTF8( const QString & fileName );
1229 #endif // USE_QT4
1230 
1234 #ifdef USE_QT3
1235  static TQString decodeFileNameUTF8( const TQCString & localFileName );
1236 #endif // USE_QT3
1237 #ifdef USE_QT4
1238  static QString decodeFileNameUTF8( const QByteArray & localFileName );
1239 #endif // USE_QT4
1240 
1245  void initCatalogue( KCatalogue & catalog );
1246 
1250  void doFormatInit() const;
1251 
1255  void initFormat();
1256 
1260  TQString translate_priv(const char *index,
1261  const char *text,
1262  const char ** original = 0,
1263  int* pluralType = 0) const;
1264 
1268  bool useDefaultLanguage() const;
1269 
1273  bool isLanguageInstalled(const TQString & language) const;
1274 
1279  void updateCatalogues( );
1280 
1284  void initPluralTypes( );
1290  int pluralType( const TQString & language );
1291 
1298  int pluralType( const KCatalogue& catalog );
1305  // const KCatalogue * catalog( const TQString & language, const TQString & name );
1306 
1307 
1312  static TQString catalogueFileName(const TQString & language,
1313  const KCatalogue & catalog);
1314 public:
1320  bool isApplicationTranslatedInto( const TQString & language);
1321 
1322 private:
1323  // Numbers and money
1324  TQString m_decimalSymbol;
1325  TQString m_thousandsSeparator;
1326  TQString m_currencySymbol;
1327  TQString m_monetaryDecimalSymbol;
1328  TQString m_monetaryThousandsSeparator;
1329  TQString m_positiveSign;
1330  TQString m_negativeSign;
1331  int m_fracDigits;
1332  SignPosition m_positiveMonetarySignPosition;
1333  SignPosition m_negativeMonetarySignPosition;
1334 
1335  // Date and time
1336  TQString m_timeFormat;
1337  TQString m_dateFormat;
1338  TQString m_dateFormatShort;
1339 
1340  TQString m_language;
1341  TQString m_country;
1342 
1343  bool m_weekStartsMonday; //### remove for KDE 4.0
1344  bool m_positivePrefixCurrencySymbol;
1345  bool m_negativePrefixCurrencySymbol;
1346 
1347  KLocalePrivate *d;
1348 };
1349 
1350 #endif
KCalendarSystem
CalendarSystem abstract class, default derived kde gregorian class and factory class.
Definition: kcalendarsystem.h:43
KCatalogue
This class abstracts a gettext message catalog.
Definition: kcatalogue.h:38
KConfigBase
KDE Configuration Management abstract base class.
Definition: kconfigbase.h:71
KConfig
Access KDE Configuration entries.
Definition: kconfig.h:44
KGlobal
Access to the KDE global objects.
Definition: kglobal.h:45
KGlobal::config
static KConfig * config()
Returns the general config object.
Definition: kglobal.cpp:61
KLocale
KLocale provides support for country specific stuff like the national language.
Definition: klocale.h:125
KLocale::SignPosition
SignPosition
Various positions for where to place the positive or negative sign when they are related to a monetar...
Definition: klocale.h:267
KLocale::i18n
TQString i18n(const char *text)
i18n is the function that does everything you need to translate a string.
Definition: klocale.cpp:1977
KLocale::MeasureSystem
MeasureSystem
The Metric system will give you information in mm, while the Imperial system will give you informatio...
Definition: klocale.h:1012
KLocale::tr2i18n
TQString tr2i18n(const char *message, const char *=0)
Qt3's uic generates i18n( "msg", "comment" ) calls which conflict with our i18n method.
Definition: klocale.h:108

kdecore

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

kdecore

Skip menu "kdecore"
  • arts
  • dcop
  • dnssd
  • interfaces
  •     interface
  •     library
  •   kspeech
  •   ktexteditor
  • kabc
  • kate
  • kcmshell
  • kdecore
  • kded
  • kdefx
  • kdeprint
  • kdesu
  • kdeui
  • kdoctools
  • khtml
  • kimgio
  • kinit
  • kio
  •   bookmarks
  •   httpfilter
  •   kfile
  •   kio
  •   kioexec
  •   kpasswdserver
  •   kssl
  • kioslave
  •   http
  • kjs
  • kmdi
  •   kmdi
  • knewstuff
  • kparts
  • krandr
  • kresources
  • kspell2
  • kunittest
  • kutils
  • kwallet
  • libkmid
  • libkscreensaver
Generated for kdecore by doxygen 1.9.1
This website is maintained by Timothy Pearson.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. |