klocale.h
Go to the documentation of this file.
// -*- c-basic-offset: 2 -*-
/* This file is part of the KDE libraries
Copyright (C) 1997 Stephan Kulow <coolo@kde.org>
Copyright (C) 1999-2003 Hans Petter Bieker <bieker@kde.org>
Copyright (c) 2002 Lukas Tinkl <lukas@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef _KLOCALE_H
#define _KLOCALE_H
#include <qstring.h>
#include <kdelibs_export.h>
class QStringList;
class QTextCodec;
class QDate;
class QTime;
class QDateTime;
class KGlobal;
class KConfig;
class KConfigBase;
class KLocalePrivate;
class KCatalogue;
class KCalendarSystem;
#ifndef I18N_NOOP
#define I18N_NOOP(x) x
#endif
#ifndef I18N_NOOP2
#define I18N_NOOP2(comment,x) x
#endif
KDECORE_EXPORT QString i18n(const char *text);
KDECORE_EXPORT QString i18n(const char *comment, const char *text);
KDECORE_EXPORT QString i18n(const char *singular, const char *plural, unsigned long n);
inline QString tr2i18n(const char* message, const char* =0) {
return i18n(message);
}
class KDECORE_EXPORT KLocale
{
friend class KGlobal; // for initInstance()
public:
KLocale( const QString& catalog, KConfig *config = 0 );
KLocale( const KLocale & rhs );
KLocale& operator= ( const KLocale & rhs );
~KLocale();
QString translate( const char *index ) const;
QString translate( const char *comment, const char *fallback) const;
QString translate( const char *singular, const char *plural,
unsigned long n) const;
bool setEncoding(int mibEnum);
bool setLanguage(const QString & language);
bool setLanguage(const QStringList & languages);
bool setCountry(const QString & country);
enum SignPosition { ParensAround = 0, BeforeQuantityMoney = 1,
AfterQuantityMoney = 2,
BeforeMoney = 3, AfterMoney = 4 };
QString decimalSymbol() const;
QString thousandsSeparator() const;
QString currencySymbol() const;
QString monetaryDecimalSymbol() const;
QString monetaryThousandsSeparator() const;
QString positiveSign() const;
QString negativeSign() const;
int fracDigits() const;
bool positivePrefixCurrencySymbol() const;
bool negativePrefixCurrencySymbol() const;
SignPosition positiveMonetarySignPosition() const;
SignPosition negativeMonetarySignPosition() const;
QString formatMoney(double num,
const QString & currency = QString::null,
int digits = -1) const;
QString formatNumber(double num, int precision = -1) const;
QString formatNumber(const QString &numStr) const KDE_DEPRECATED;
QString formatNumber(const QString &numStr, bool round, int precision) const;
QString formatLong(long num) const;
bool nounDeclension() const;
QString formatDate(const QDate &pDate, bool shortFormat = false) const;
bool dateMonthNamePossessive() const;
QString formatTime(const QTime &pTime, bool includeSecs, bool isDuration /*=false*/) const;
QString formatTime(const QTime &pTime, bool includeSecs = false) const; // BIC: merge with above
bool use12Clock() const;
bool weekStartsMonday() const KDE_DEPRECATED; //### remove for KDE 4.0
int weekStartDay() const;
QString monthName(int i, bool shortName = false) const KDE_DEPRECATED;
QString monthNamePossessive(int i, bool shortName = false) const KDE_DEPRECATED;
QString weekDayName(int i, bool shortName = false) const KDE_DEPRECATED;
const KCalendarSystem * calendar() const;
QString calendarType() const;
void setCalendar(const QString & calendarType);
QString formatDateTime(const QDateTime &pDateTime,
bool shortFormat = true,
bool includeSecs = false) const;
double readMoney(const QString &numStr, bool * ok = 0) const;
double readNumber(const QString &numStr, bool * ok = 0) const;
QDate readDate(const QString &str, bool* ok = 0) const;
QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const;
enum ReadDateFlags {
NormalFormat = 1,
ShortFormat = 2
};
QDate readDate(const QString &str, ReadDateFlags flags, bool *ok = 0) const;
QTime readTime(const QString &str, bool* ok = 0) const;
enum ReadTimeFlags {
WithSeconds = 0, // default (no flag set)
WithoutSeconds = 1
}; // (maybe use this enum as a bitfield, if adding independent features?)
QTime readTime(const QString &str, ReadTimeFlags flags, bool *ok = 0) const;
QString language() const;
QString country() const;
QStringList languagesTwoAlpha() const;
QStringList languageList() const;
const char * encoding() const;
int encodingMib() const;
QTextCodec * codecForEncoding() const;
int fileEncodingMib() const;
void setDateFormat(const QString & format);
void setDateFormatShort(const QString & format);
void setDateMonthNamePossessive(bool possessive);
void setTimeFormat(const QString & format);
void setWeekStartsMonday(bool start) KDE_DEPRECATED; //### remove for KDE 4.0
void setWeekStartDay(int day);
QString dateFormat() const;
QString dateFormatShort() const;
QString timeFormat() const;
void setDecimalSymbol(const QString & symbol);
void setThousandsSeparator(const QString & separator);
void setPositiveSign(const QString & sign);
void setNegativeSign(const QString & sign);
void setPositiveMonetarySignPosition(SignPosition signpos);
void setNegativeMonetarySignPosition(SignPosition signpos);
void setPositivePrefixCurrencySymbol(bool prefix);
void setNegativePrefixCurrencySymbol(bool prefix);
void setFracDigits(int digits);
void setMonetaryThousandsSeparator(const QString & separator);
void setMonetaryDecimalSymbol(const QString & symbol);
void setCurrencySymbol(const QString & symbol);
int pageSize() const;
void setPageSize(int paperFormat);
enum MeasureSystem { Metric, Imperial };
MeasureSystem measureSystem() const;
void setMeasureSystem(MeasureSystem value);
void insertCatalogue(const QString& catalog);
void removeCatalogue(const QString &catalog);
void setActiveCatalogue(const QString &catalog);
QString translateQt(const char *context,
const char *sourceText,
const char *message) const;
QStringList allLanguagesTwoAlpha() const;
QString twoAlphaToLanguageName(const QString &code) const;
QStringList allCountriesTwoAlpha() const;
QString twoAlphaToCountryName(const QString &code) const;
static void splitLocale(const QString & str,
QString & language,
QString & country,
QString & charset);
static void setMainCatalogue(const char *catalog);
static QString langLookup(const QString &fname, const char *rtype = "html");
static QString defaultLanguage();
static QString defaultCountry();
static QString _initLanguage(KConfigBase *config);
#ifdef KDE_NO_COMPAT
private:
#endif
QString formatMoney(const QString &numStr) const KDE_DEPRECATED;
QString languages() const KDE_DEPRECATED;
bool setCharset(const QString & charset) KDE_DEPRECATED;
QString charset() const KDE_DEPRECATED;
protected:
static void initInstance();
private:
void initFormat(KConfig *config);
void initMainCatalogues(const QString & catalog);
void initLanguageList(KConfig * config, bool useEnv);
void initEncoding(KConfig * config);
void initFileNameEncoding(KConfig *config);
static QCString encodeFileNameUTF8( const QString & fileName );
static QString decodeFileNameUTF8( const QCString & localFileName );
void initCatalogue( KCatalogue & catalog );
void doFormatInit() const;
void initFormat();
QString translate_priv(const char *index,
const char *text,
const char ** original = 0,
int* pluralType = 0) const;
bool useDefaultLanguage() const;
bool isLanguageInstalled(const QString & language) const;
void updateCatalogues( );
void initPluralTypes( );
int pluralType( const QString & language );
int pluralType( const KCatalogue& catalog );
// const KCatalogue * catalog( const QString & language, const QString & name );
static QString catalogueFileName(const QString & language,
const KCatalogue & catalog);
public:
bool isApplicationTranslatedInto( const QString & language);
private:
// Numbers and money
QString m_decimalSymbol;
QString m_thousandsSeparator;
QString m_currencySymbol;
QString m_monetaryDecimalSymbol;
QString m_monetaryThousandsSeparator;
QString m_positiveSign;
QString m_negativeSign;
int m_fracDigits;
SignPosition m_positiveMonetarySignPosition;
SignPosition m_negativeMonetarySignPosition;
// Date and time
QString m_timeFormat;
QString m_dateFormat;
QString m_dateFormatShort;
QString m_language;
QString m_country;
bool m_weekStartsMonday; //### remove for KDE 4.0
bool m_positivePrefixCurrencySymbol;
bool m_negativePrefixCurrencySymbol;
KLocalePrivate *d;
};
#endif
KLocale::MeasureSystem
MeasureSystem
The Metric system will give you information in mm, while the Imperial system will give you informatio...
Definition: klocale.h:1012
KCalendarSystem
CalendarSystem abstract class, default derived kde gregorian class and factory class.
Definition: kcalendarsystem.h:42
KLocale::i18n
QString i18n(const char *text)
Definition: klocale.cpp:1961
KCatalogue
This class abstracts a gettext message catalog.
Definition: kcatalogue.h:37
KConfigBase
KDE Configuration Management abstract base class.
Definition: kconfigbase.h:70
KLocale::tr2i18n
QString tr2i18n(const char *message, const char *=0)
Definition: klocale.h:108
KGlobal
Access to the KDE global objects.
Definition: kglobal.h:44
KConfig
Access KDE Configuration entries.
Definition: kconfig.h:43
KLocale
KLocale provides support for country specific stuff like the national language.
Definition: klocale.h:124
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
KGlobal::config
static KConfig * config()
Returns the general config object.
Definition: kglobal.cpp:61

KDE Home | KDE Accessibility Home | Description of Access Keys