• 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
27class TQStringList;
28class TQTextCodec;
29class TQDate;
30class TQTime;
31class TQDateTime;
32
33class TDEGlobal;
34class TDEConfig;
35class TDEConfigBase;
36class TDELocalePrivate;
37class KCatalogue;
38class KCalendarSystem;
39
44#ifndef I18N_NOOP
51#define I18N_NOOP(x) x
52#endif
53
54#ifndef I18N_NOOP2
62#define I18N_NOOP2(comment,x) x
63#endif
64
77TDECORE_EXPORT TQString i18n(const char *text);
78
86TDECORE_EXPORT TQString i18n(const char *comment, const char *text);
87
99TDECORE_EXPORT TQString i18n(const char *singular, const char *plural, unsigned long n);
100
107inline TQString tr2i18n(const char* message, const char* =0) {
108 return i18n(message);
109}
110
123class TDECORE_EXPORT TDELocale
124{
125 friend class TDEGlobal; // for initInstance()
126public:
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 TDE_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 TDE_DEPRECATED; //### remove for KDE 4.0
516
523 int weekStartDay() const;
524
545 TQString monthName(int i, bool shortName = false) const TDE_DEPRECATED;
546
570 TQString monthNamePossessive(int i, bool shortName = false) const TDE_DEPRECATED;
571
582 TQString weekDayName(int i, bool shortName = false) const TDE_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) TDE_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
1145private:
1146#endif
1151 TQString formatMoney(const TQString &numStr) const TDE_DEPRECATED;
1152
1159 TQString languages() const TDE_DEPRECATED;
1160
1165 bool setCharset(const TQString & charset) TDE_DEPRECATED;
1166
1171 TQString charset() const TDE_DEPRECATED;
1172
1173protected:
1178 static void initInstance();
1179
1180private:
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 static TQCString encodeFileNameUTF8( const TQString & fileName );
1224
1228 static TQString decodeFileNameUTF8( const TQCString & localFileName );
1229
1234 void initCatalogue( KCatalogue & catalog );
1235
1239 void doFormatInit() const;
1240
1244 void initFormat();
1245
1249 TQString translate_priv(const char *index,
1250 const char *text,
1251 const char ** original = 0,
1252 int* pluralType = 0) const;
1253
1257 bool useDefaultLanguage() const;
1258
1262 bool isLanguageInstalled(const TQString & language) const;
1263
1268 void updateCatalogues( );
1269
1273 void initPluralTypes( );
1279 int pluralType( const TQString & language );
1280
1287 int pluralType( const KCatalogue& catalog );
1294 // const KCatalogue * catalog( const TQString & language, const TQString & name );
1295
1296
1301 static TQString catalogueFileName(const TQString & language,
1302 const KCatalogue & catalog);
1303public:
1309 bool isApplicationTranslatedInto( const TQString & language);
1310
1311private:
1312 // Numbers and money
1313 TQString m_decimalSymbol;
1314 TQString m_thousandsSeparator;
1315 TQString m_currencySymbol;
1316 TQString m_monetaryDecimalSymbol;
1317 TQString m_monetaryThousandsSeparator;
1318 TQString m_positiveSign;
1319 TQString m_negativeSign;
1320 int m_fracDigits;
1321 SignPosition m_positiveMonetarySignPosition;
1322 SignPosition m_negativeMonetarySignPosition;
1323
1324 // Date and time
1325 TQString m_timeFormat;
1326 TQString m_dateFormat;
1327 TQString m_dateFormatShort;
1328
1329 TQString m_language;
1330 TQString m_country;
1331
1332 bool m_weekStartsMonday; //### remove for KDE 4.0
1333 bool m_positivePrefixCurrencySymbol;
1334 bool m_negativePrefixCurrencySymbol;
1335
1336 TDELocalePrivate *d;
1337};
1338
1339#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
TDEConfigBase
KDE Configuration Management abstract base class.
Definition: tdeconfigbase.h:71
TDEConfig
Access KDE Configuration entries.
Definition: tdeconfig.h:44
TDEGlobal
Access to the KDE global objects.
Definition: tdeglobal.h:49
TDEGlobal::config
static TDEConfig * config()
Returns the general config object.
Definition: tdeglobal.cpp:65
TDELocale
TDELocale provides support for country specific stuff like the national language.
Definition: tdelocale.h:124
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
TDELocale::i18n
TQString i18n(const char *text)
i18n is the function that does everything you need to translate a string.
Definition: tdelocale.cpp:1976
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)
Qt3's uic generates i18n( "msg", "comment" ) calls which conflict with our i18n method.
Definition: tdelocale.h:107

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.9.4
This website is maintained by Timothy Pearson.