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

tdecore

Public Types | Public Member Functions | Static Public Member Functions | Static Protected Member Functions | Friends | Related Functions | List of all members
TDELocale Class Reference

#include <tdelocale.h>

Public Types

enum  SignPosition {
  ParensAround = 0 , BeforeQuantityMoney = 1 , AfterQuantityMoney = 2 , BeforeMoney = 3 ,
  AfterMoney = 4
}
 
enum  ReadDateFlags { NormalFormat = 1 , ShortFormat = 2 }
 
enum  ReadTimeFlags { WithSeconds = 0 , WithoutSeconds = 1 }
 
enum  MeasureSystem { Metric , Imperial }
 

Public Member Functions

 TDELocale (const TQString &catalog, TDEConfig *config=0)
 
 TDELocale (const TDELocale &rhs)
 
TDELocale & operator= (const TDELocale &rhs)
 
 ~TDELocale ()
 
TQString translate (const char *index) const
 
TQString translate (const char *comment, const char *fallback) const
 
TQString translate (const char *singular, const char *plural, unsigned long n) const
 
bool setEncoding (int mibEnum)
 
bool setLanguage (const TQString &language)
 
bool setLanguage (const TQStringList &languages)
 
bool setCountry (const TQString &country)
 
TQString decimalSymbol () const
 
TQString thousandsSeparator () const
 
TQString currencySymbol () const
 
TQString monetaryDecimalSymbol () const
 
TQString monetaryThousandsSeparator () const
 
TQString positiveSign () const
 
TQString negativeSign () const
 
int fracDigits () const
 
bool positivePrefixCurrencySymbol () const
 
bool negativePrefixCurrencySymbol () const
 
SignPosition positiveMonetarySignPosition () const
 
SignPosition negativeMonetarySignPosition () const
 
TQString formatMoney (double num, const TQString &currency=TQString::null, int digits=-1) const
 
TQString formatNumber (double num, int precision=-1) const
 
TQString formatNumber (const TQString &numStr) const TDE_DEPRECATED
 
TQString formatNumber (const TQString &numStr, bool round, int precision) const
 
TQString formatLong (long num) const
 
bool nounDeclension () const
 
TQString formatDate (const TQDate &pDate, bool shortFormat=false) const
 
bool dateMonthNamePossessive () const
 
TQString formatTime (const TQTime &pTime, bool includeSecs, bool isDuration) const
 
TQString formatTime (const TQTime &pTime, bool includeSecs=false) const
 
bool use12Clock () const
 
bool weekStartsMonday () const TDE_DEPRECATED
 
int weekStartDay () const
 
TQString monthName (int i, bool shortName=false) const TDE_DEPRECATED
 
TQString monthNamePossessive (int i, bool shortName=false) const TDE_DEPRECATED
 
TQString weekDayName (int i, bool shortName=false) const TDE_DEPRECATED
 
const KCalendarSystem * calendar () const
 
TQString calendarType () const
 
void setCalendar (const TQString &calendarType)
 
TQString formatDateTime (const TQDateTime &pDateTime, bool shortFormat=true, bool includeSecs=false) const
 
double readMoney (const TQString &numStr, bool *ok=0) const
 
double readNumber (const TQString &numStr, bool *ok=0) const
 
TQDate readDate (const TQString &str, bool *ok=0) const
 
TQDate readDate (const TQString &intstr, const TQString &fmt, bool *ok=0) const
 
TQDate readDate (const TQString &str, ReadDateFlags flags, bool *ok=0) const
 
TQTime readTime (const TQString &str, bool *ok=0) const
 
TQTime readTime (const TQString &str, ReadTimeFlags flags, bool *ok=0) const
 
TQString language () const
 
TQString country () const
 
TQStringList languagesTwoAlpha () const
 
TQStringList languageList () const
 
const char * encoding () const
 
int encodingMib () const
 
TQTextCodec * codecForEncoding () const
 
int fileEncodingMib () const
 
void setDateFormat (const TQString &format)
 
void setDateFormatShort (const TQString &format)
 
void setDateMonthNamePossessive (bool possessive)
 
void setTimeFormat (const TQString &format)
 
void setWeekStartsMonday (bool start) TDE_DEPRECATED
 
void setWeekStartDay (int day)
 
TQString dateFormat () const
 
TQString dateFormatShort () const
 
TQString timeFormat () const
 
void setDecimalSymbol (const TQString &symbol)
 
void setThousandsSeparator (const TQString &separator)
 
void setPositiveSign (const TQString &sign)
 
void setNegativeSign (const TQString &sign)
 
void setPositiveMonetarySignPosition (SignPosition signpos)
 
void setNegativeMonetarySignPosition (SignPosition signpos)
 
void setPositivePrefixCurrencySymbol (bool prefix)
 
void setNegativePrefixCurrencySymbol (bool prefix)
 
void setFracDigits (int digits)
 
void setMonetaryThousandsSeparator (const TQString &separator)
 
void setMonetaryDecimalSymbol (const TQString &symbol)
 
void setCurrencySymbol (const TQString &symbol)
 
int pageSize () const
 
void setPageSize (int paperFormat)
 
MeasureSystem measureSystem () const
 
void setMeasureSystem (MeasureSystem value)
 
void insertCatalogue (const TQString &catalog)
 
void removeCatalogue (const TQString &catalog)
 
void setActiveCatalogue (const TQString &catalog)
 
TQString translateQt (const char *context, const char *sourceText, const char *message) const
 
TQStringList allLanguagesTwoAlpha () const
 
TQString twoAlphaToLanguageName (const TQString &code) const
 
TQStringList allCountriesTwoAlpha () const
 
TQString twoAlphaToCountryName (const TQString &code) const
 
TQString formatMoney (const TQString &numStr) const TDE_DEPRECATED
 
TQString languages () const TDE_DEPRECATED
 
bool setCharset (const TQString &charset) TDE_DEPRECATED
 
TQString charset () const TDE_DEPRECATED
 
bool isApplicationTranslatedInto (const TQString &language)
 

Static Public Member Functions

static void splitLocale (const TQString &str, TQString &language, TQString &country, TQString &charset)
 
static void setMainCatalogue (const char *catalog)
 
static TQString langLookup (const TQString &fname, const char *rtype="html")
 
static TQString defaultLanguage ()
 
static TQString defaultCountry ()
 
static TQString _initLanguage (TDEConfigBase *config)
 

Static Protected Member Functions

static void initInstance ()
 

Friends

class TDEGlobal
 

Related Functions

(Note that these are not member functions.)

#define I18N_NOOP(x)   x
 
#define I18N_NOOP2(comment, x)   x
 
TQString i18n (const char *text)
 
TQString i18n (const char *comment, const char *text)
 
TQString i18n (const char *singular, const char *plural, unsigned long n)
 
TQString tr2i18n (const char *message, const char *=0)
 

Detailed Description

TDELocale provides support for country specific stuff like the national language.

TDELocale supports translating, as well as specifying the format for numbers, currency, time, and date.

Author
Stephan Kulow coolo.nosp@m.@kde.nosp@m..org, Preston Brown pbrow.nosp@m.n@kd.nosp@m.e.org, Hans Petter Bieker bieke.nosp@m.r@kd.nosp@m.e.org, Lukas Tinkl lukas.nosp@m..tin.nosp@m.kl@su.nosp@m.se.c.nosp@m.z

class for supporting locale settings and national language

Definition at line 123 of file tdelocale.h.

Member Enumeration Documentation

◆ MeasureSystem

enum TDELocale::MeasureSystem

The Metric system will give you information in mm, while the Imperial system will give you information in inches.

Definition at line 1011 of file tdelocale.h.

◆ ReadDateFlags

enum TDELocale::ReadDateFlags

Definition at line 665 of file tdelocale.h.

◆ ReadTimeFlags

enum TDELocale::ReadTimeFlags

Definition at line 699 of file tdelocale.h.

◆ SignPosition

enum TDELocale::SignPosition

Various positions for where to place the positive or negative sign when they are related to a monetary value.

Definition at line 266 of file tdelocale.h.

Constructor & Destructor Documentation

◆ TDELocale() [1/2]

TDELocale::TDELocale ( const TQString &  catalog,
TDEConfig *  config = 0 
)

Constructs a TDELocale with the given catalog name.

The constructor looks for an entry Locale/Language in the configuration file. If no config file is specified, it will also look for languages using the environment variables (TDE_LANG, LC_MESSAGES, LC_ALL, LANG), as well as the global configuration file. If TDELocale is not able to use any of the specified languages, the default language (en_US) will be used.

If you specify a configuration file, it has to be valid until the TDELocale object is destroyed.

Parameters
catalogThe name of the main language file
configThe configuration file to use.

Definition at line 83 of file tdelocale.cpp.

◆ TDELocale() [2/2]

TDELocale::TDELocale ( const TDELocale &  rhs)

Copy constructor.

Definition at line 2418 of file tdelocale.cpp.

◆ ~TDELocale()

TDELocale::~TDELocale ( )

Destructor.

Definition at line 711 of file tdelocale.cpp.

Member Function Documentation

◆ _initLanguage()

TQString TDELocale::_initLanguage ( TDEConfigBase *  config)
static

Definition at line 105 of file tdelocale.cpp.

◆ allCountriesTwoAlpha()

TQStringList TDELocale::allCountriesTwoAlpha ( ) const

Returns list of all known country codes.

Returns
a list of all country codes
Since
3.1

Definition at line 2369 of file tdelocale.cpp.

◆ allLanguagesTwoAlpha()

TQStringList TDELocale::allLanguagesTwoAlpha ( ) const

Returns list of all known ISO 639-1 codes.

Returns
a list of all language codes
Since
3.1

Definition at line 2348 of file tdelocale.cpp.

◆ calendar()

const KCalendarSystem * TDELocale::calendar ( ) const

Returns a pointer to the calendar system object.

Returns
the current calendar system instance
Since
3.2

Definition at line 2407 of file tdelocale.cpp.

◆ calendarType()

TQString TDELocale::calendarType ( ) const

Returns the name of the calendar system that is currently being used by the system.

Returns
the name of the calendar system
Since
3.2

Definition at line 2400 of file tdelocale.cpp.

◆ charset()

TQString TDELocale::charset ( ) const
Deprecated:
See also
encoding

Definition at line 2458 of file tdelocale.cpp.

◆ codecForEncoding()

TQTextCodec * TDELocale::codecForEncoding ( ) const

Returns the user's preferred encoding.

Should never be NULL.

Returns
The codec for the preferred encoding
See also
encoding
encodingMib

Definition at line 2294 of file tdelocale.cpp.

◆ country()

TQString TDELocale::country ( ) const

Returns the country code of the country where the user lives.

defaultCountry() is returned by default, if no other available.

Returns
The country code for the user.

Definition at line 558 of file tdelocale.cpp.

◆ currencySymbol()

TQString TDELocale::currencySymbol ( ) const

Returns what the symbol denoting currency in the current locale as as defined by user settings should look like.

Returns
The default currency symbol used by locale.

Definition at line 1042 of file tdelocale.cpp.

◆ dateFormat()

TQString TDELocale::dateFormat ( ) const

Returns the currently selected date format.

Returns
Current date format.
See also
setDateFormat()

Definition at line 2138 of file tdelocale.cpp.

◆ dateFormatShort()

TQString TDELocale::dateFormatShort ( ) const

Returns the currently selected short date format.

Returns
Current short date format.
See also
setDateFormatShort()

Definition at line 2144 of file tdelocale.cpp.

◆ dateMonthNamePossessive()

bool TDELocale::dateMonthNamePossessive ( ) const

Use this to determine whether in dates a possessive form of month name is preferred ("of January" rather than "January")

Returns
If possessive form should be used
Since
3.1

Definition at line 1012 of file tdelocale.cpp.

◆ decimalSymbol()

TQString TDELocale::decimalSymbol ( ) const

Returns what a decimal point should look like ("." or "," etc.) according to the current locale or user settings.

Returns
The decimal symbol used by locale.

Definition at line 1030 of file tdelocale.cpp.

◆ defaultCountry()

TQString TDELocale::defaultCountry ( )
static

Returns the name of the default country.

Returns
Name of the default country

Definition at line 2260 of file tdelocale.cpp.

◆ defaultLanguage()

TQString TDELocale::defaultLanguage ( )
static

Returns the name of the internal language.

Returns
Name of the default language

Definition at line 2255 of file tdelocale.cpp.

◆ encoding()

const char * TDELocale::encoding ( ) const

Returns the user's preferred encoding.

Returns
The name of the preferred encoding
See also
codecForEncoding
encodingMib

Definition at line 2265 of file tdelocale.cpp.

◆ encodingMib()

int TDELocale::encodingMib ( ) const

Returns the user's preferred encoding.

Returns
The Mib of the preferred encoding
See also
encoding
codecForEncoding

Definition at line 2282 of file tdelocale.cpp.

◆ fileEncodingMib()

int TDELocale::fileEncodingMib ( ) const

Returns the file encoding.

Returns
The Mib of the file encoding
See also
TQFile::encodeName
TQFile::decodeName

Definition at line 2287 of file tdelocale.cpp.

◆ formatDate()

TQString TDELocale::formatDate ( const TQDate &  pDate,
bool  shortFormat = false 
) const

Returns a string formatted to the current locale's conventions regarding dates.

Parameters
pDateThe date to be formated.
shortFormatTrue for non text dates.
Returns
The date as a string

Definition at line 1337 of file tdelocale.cpp.

◆ formatDateTime()

TQString TDELocale::formatDateTime ( const TQDateTime &  pDateTime,
bool  shortFormat = true,
bool  includeSecs = false 
) const

Returns a string formated to the current locale's conventions regarding both date and time.

Parameters
pDateTimeThe date and time to be formated.
shortFormatusing the short date format.
includeSecsusing the short date format.
Returns
The date and time as a string

Definition at line 1967 of file tdelocale.cpp.

◆ formatLong()

TQString TDELocale::formatLong ( long  num) const

Given an integer, converts that to a numeric string containing the localized numeric equivalent.

e.g. given 123456L, return "123,456" (for some European country).

Parameters
numThe number to convert
Returns
The number as a localized string
Since
3.2

Definition at line 1202 of file tdelocale.cpp.

◆ formatMoney() [1/2]

TQString TDELocale::formatMoney ( const TQString &  numStr) const
Deprecated:
use formatMoney(double)

Definition at line 1190 of file tdelocale.cpp.

◆ formatMoney() [2/2]

TQString TDELocale::formatMoney ( double  num,
const TQString &  currency = TQString::null,
int  digits = -1 
) const

Given a double, converts that to a numeric string containing the localized monetary equivalent.

e.g. given 123456, return "$ 123,456.00".

Parameters
numThe number we want to format
currencyThe currency symbol you want.
digitsNumber of fractional digits, or -1 for the default value
Returns
The number of money as a localized string
See also
fracDigits()

Definition at line 1129 of file tdelocale.cpp.

◆ formatNumber() [1/3]

TQString TDELocale::formatNumber ( const TQString &  numStr) const
Deprecated:

KDE 4.0: merge with formatNumber(const TQString int)

calls formatNumber(numStr, 2)

Definition at line 1207 of file tdelocale.cpp.

◆ formatNumber() [2/3]

TQString TDELocale::formatNumber ( const TQString &  numStr,
bool  round,
int  precision 
) const

Given a string representing a number, converts that to a numeric string containing the localized numeric equivalent.

e.g. given 123456.78F, return "123,456.78" (for some European country).

Parameters
numStrThe number to convert
roundRound fractional digits.
precisionNumber of fractional digits used.
Returns
The number as a localized string
Since
3.5

Definition at line 1303 of file tdelocale.cpp.

◆ formatNumber() [3/3]

TQString TDELocale::formatNumber ( double  num,
int  precision = -1 
) const

Given a double, converts that to a numeric string containing the localized numeric equivalent.

e.g. given 123456.78F, return "123,456.78" (for some European country). If precision isn't specified, 2 is used.

This function is a wrapper that is provided for convenience.

Parameters
numThe number to convert
precisionNumber of fractional digits used.
Returns
The number as a localized string
See also
formatNumber(const TQString, bool, int)

Definition at line 1195 of file tdelocale.cpp.

◆ formatTime() [1/2]

TQString TDELocale::formatTime ( const TQTime &  pTime,
bool  includeSecs,
bool  isDuration 
) const

Returns a string formatted to the current locale's conventions regarding times.

Parameters
pTimeThe time to be formated.
includeSecsif true, seconds are included in the output, otherwise only hours and minutes are formatted.
isDurationif true, the given time is a duration, not a clock time. This means "am/pm" shouldn't be displayed.
Returns
The time as a string

Definition at line 1862 of file tdelocale.cpp.

◆ formatTime() [2/2]

TQString TDELocale::formatTime ( const TQTime &  pTime,
bool  includeSecs = false 
) const

Returns a string formatted to the current locale's conventions regarding times.

Parameters
pTimeThe time to be formated.
includeSecsif true, seconds are included in the output, otherwise only hours and minutes are formatted.
Returns
The time as a string

Definition at line 1857 of file tdelocale.cpp.

◆ fracDigits()

int TDELocale::fracDigits ( ) const

The number of fractional digits to include in numeric/monetary values (usually 2).

Returns
Default number of fractional digits used by locale.

Definition at line 1072 of file tdelocale.cpp.

◆ initInstance()

void TDELocale::initInstance ( )
staticprotected

Definition at line 2003 of file tdelocale.cpp.

◆ insertCatalogue()

void TDELocale::insertCatalogue ( const TQString &  catalog)

Adds another catalog to search for translation lookup.

This function is useful for extern libraries and/or code, that provide there own messages.

If the catalog does not exist for the chosen language, it will be ignored and en_US will be used.

Parameters
catalogThe catalog to add.

Definition at line 644 of file tdelocale.cpp.

◆ isApplicationTranslatedInto()

bool TDELocale::isApplicationTranslatedInto ( const TQString &  language)

Definition at line 486 of file tdelocale.cpp.

◆ langLookup()

TQString TDELocale::langLookup ( const TQString &  fname,
const char *  rtype = "html" 
)
static

Finds localized resource in resourceDir( rtype ) + <lang> + fname.

Parameters
fnamerelative path to find
rtyperesource type to use

Definition at line 2019 of file tdelocale.cpp.

◆ language()

TQString TDELocale::language ( ) const

Returns the language used by this object.

The domain AND the library translation must be available in this language. defaultLanguage() is returned by default, if no other available.

Returns
The currently used language.

Definition at line 553 of file tdelocale.cpp.

◆ languageList()

TQStringList TDELocale::languageList ( ) const

Returns the languages selected by user.

The codes returned here is the internal language codes.

Returns
List of language codes
See also
languagesTwoAlpha

Definition at line 1962 of file tdelocale.cpp.

◆ languages()

TQString TDELocale::languages ( ) const
Deprecated:
Use languageList()
Returns
String containing language codes separated by colons

Definition at line 1957 of file tdelocale.cpp.

◆ languagesTwoAlpha()

TQStringList TDELocale::languagesTwoAlpha ( ) const

Returns the preferred languages as ISO 639-1 codes.

This means that information about country is removed. If the internal language code might be represented by more than one 639-1 code, they will all be listed (but only once).

If the selected languages are "nn, nb, pt_BR", you will get: "nn, nb, pt".

Returns
List of language codes
See also
languageList

Definition at line 2308 of file tdelocale.cpp.

◆ measureSystem()

TDELocale::MeasureSystem TDELocale::measureSystem ( ) const

Returns which measuring system we use.

Returns
The preferred measuring system

Definition at line 2243 of file tdelocale.cpp.

◆ monetaryDecimalSymbol()

TQString TDELocale::monetaryDecimalSymbol ( ) const

Returns what a decimal point should look like ("." or "," etc.) for monetary values, according to the current locale or user settings.

Returns
The monetary decimal symbol used by locale.

Definition at line 1048 of file tdelocale.cpp.

◆ monetaryThousandsSeparator()

TQString TDELocale::monetaryThousandsSeparator ( ) const

Returns what a thousands separator for monetary values should look like ("," or " " etc.) according to the current locale or user settings.

Returns
The monetary thousands separator used by locale.

Definition at line 1054 of file tdelocale.cpp.

◆ monthName()

TQString TDELocale::monthName ( int  i,
bool  shortName = false 
) const
Deprecated:

Returns a string containing the name of the month name used in the Gregorian calendar.

Parameters
ithe month number of the year starting at 1/January.
shortNamewe will return the short version of the string.
Returns
The name of the month

Typically the correct replacement for this deprecated class is calendar()->monthString(), which requires a TQDate (rather than an integer month) or both a month and a year. This will work across different calendars. Note that you also need to add

#include <kcalendarsystem.h>

to the applicable file.

Definition at line 563 of file tdelocale.cpp.

◆ monthNamePossessive()

TQString TDELocale::monthNamePossessive ( int  i,
bool  shortName = false 
) const
Deprecated:

Returns a string containing the possessive form of the month name used in the Gregorian calendar. ("of January", "of February", etc.) It's needed in long format dates in some languages.

Parameters
ithe month number of the year starting at 1/January.
shortNamewe will return the short version of the string.
Returns
The possessive form of the name of the month
Since
3.1

Typically the correct replacement for this deprecated class is calendar()->monthNamePossessive(), which requires a TQDate (rather than an integer month) or both a month and a year. This will work across different calendars. Note that you also need to add

#include <kcalendarsystem.h>

to the applicable file.

Definition at line 601 of file tdelocale.cpp.

◆ negativeMonetarySignPosition()

TDELocale::SignPosition TDELocale::negativeMonetarySignPosition ( ) const

Denotes where to place a negative sign in relation to a monetary value.

Returns
Where/how to print the negative sign.
See also
SignPosition

Definition at line 1096 of file tdelocale.cpp.

◆ negativePrefixCurrencySymbol()

bool TDELocale::negativePrefixCurrencySymbol ( ) const

If and only if the currency symbol precedes a negative value, this will be true.

Returns
True if the currency symbol precedes negative numbers.

Definition at line 1084 of file tdelocale.cpp.

◆ negativeSign()

TQString TDELocale::negativeSign ( ) const

Returns what a negative sign should look like ("-", etc.) according to the current locale or user settings.

Returns
The negative sign used by locale.

Definition at line 1066 of file tdelocale.cpp.

◆ nounDeclension()

bool TDELocale::nounDeclension ( ) const

Use this to determine whether nouns are declined in locale's language.

This property should remain read-only (no setter function)

Returns
If nouns are declined
Since
3.1

Definition at line 1006 of file tdelocale.cpp.

◆ operator=()

TDELocale & TDELocale::operator= ( const TDELocale &  rhs)

Assignment operator.

Definition at line 2425 of file tdelocale.cpp.

◆ pageSize()

int TDELocale::pageSize ( ) const

Returns the preferred page size for printing.

Returns
The preferred page size, cast it to TQPrinter::PageSize

Definition at line 2230 of file tdelocale.cpp.

◆ positiveMonetarySignPosition()

TDELocale::SignPosition TDELocale::positiveMonetarySignPosition ( ) const

Returns the position of a positive sign in relation to a monetary value.

Returns
Where/how to print the positive sign.
See also
SignPosition

Definition at line 1090 of file tdelocale.cpp.

◆ positivePrefixCurrencySymbol()

bool TDELocale::positivePrefixCurrencySymbol ( ) const

If and only if the currency symbol precedes a positive value, this will be true.

Returns
Where to print the currency symbol for positive numbers.

Definition at line 1078 of file tdelocale.cpp.

◆ positiveSign()

TQString TDELocale::positiveSign ( ) const

Returns what a positive sign should look like ("+", " ", etc.) according to the current locale or user settings.

Returns
The positive sign used by locale.

Definition at line 1060 of file tdelocale.cpp.

◆ readDate() [1/3]

TQDate TDELocale::readDate ( const TQString &  intstr,
const TQString &  fmt,
bool *  ok = 0 
) const

Converts a localized date string to a TQDate, using the specified format.

You will usually not want to use this method.

Definition at line 1610 of file tdelocale.cpp.

◆ readDate() [2/3]

TQDate TDELocale::readDate ( const TQString &  str,
bool *  ok = 0 
) const

Converts a localized date string to a TQDate.

The bool pointed by ok will be invalid if the date entered was not valid.

Parameters
strthe string we want to convert.
okthe boolean that is set to false if it's not a valid date. If ok is 0, it will be ignored
Returns
The string converted to a QDate

Definition at line 1596 of file tdelocale.cpp.

◆ readDate() [3/3]

TQDate TDELocale::readDate ( const TQString &  str,
ReadDateFlags  flags,
bool *  ok = 0 
) const

Converts a localized date string to a TQDate.

This method is stricter than readDate(str,&ok): it will either accept a date in full format or a date in short format, depending on flags.

Parameters
strthe string we want to convert.
flagswhether the date string is to be in full format or in short format.
okthe boolean that is set to false if it's not a valid date. If ok is 0, it will be ignored
Returns
The string converted to a QDate
Since
3.2

Definition at line 1604 of file tdelocale.cpp.

◆ readMoney()

double TDELocale::readMoney ( const TQString &  numStr,
bool *  ok = 0 
) const

Converts a localized monetary string to a double.

Parameters
numStrthe string we want to convert.
okthe boolean that is set to false if it's not a number. If ok is 0, it will be ignored
Returns
The string converted to a double

Definition at line 1482 of file tdelocale.cpp.

◆ readNumber()

double TDELocale::readNumber ( const TQString &  numStr,
bool *  ok = 0 
) const

Converts a localized numeric string to a double.

Parameters
numStrthe string we want to convert.
okthe boolean that is set to false if it's not a number. If ok is 0, it will be ignored
Returns
The string converted to a double

Definition at line 1417 of file tdelocale.cpp.

◆ readTime() [1/2]

TQTime TDELocale::readTime ( const TQString &  str,
bool *  ok = 0 
) const

Converts a localized time string to a TQTime.

This method will try to parse it with seconds, then without seconds. The bool pointed to by ok will be set to false if the time entered was not valid.

Parameters
strthe string we want to convert.
okthe boolean that is set to false if it's not a valid time. If ok is 0, it will be ignored
Returns
The string converted to a QTime

Definition at line 1741 of file tdelocale.cpp.

◆ readTime() [2/2]

TQTime TDELocale::readTime ( const TQString &  str,
ReadTimeFlags  flags,
bool *  ok = 0 
) const

Converts a localized time string to a TQTime.

This method is stricter than readTime(str,&ok): it will either accept a time with seconds or a time without seconds. Use this method when the format is known by the application.

Parameters
strthe string we want to convert.
flagswhether the time string is expected to contain seconds or not.
okthe boolean that is set to false if it's not a valid time. If ok is 0, it will be ignored
Returns
The string converted to a QTime
Since
3.2

Definition at line 1749 of file tdelocale.cpp.

◆ removeCatalogue()

void TDELocale::removeCatalogue ( const TQString &  catalog)

Removes a catalog for translation lookup.

Parameters
catalogThe catalog to remove.
See also
insertCatalogue()

Definition at line 693 of file tdelocale.cpp.

◆ setActiveCatalogue()

void TDELocale::setActiveCatalogue ( const TQString &  catalog)

Sets the active catalog for translation lookup.

Parameters
catalogThe catalog to activate.

Definition at line 702 of file tdelocale.cpp.

◆ setCalendar()

void TDELocale::setCalendar ( const TQString &  calendarType)

Changes the current calendar system to the calendar specified.

Currently "gregorian" and "hijri" are supported. If the calendar system specified is not found, gregorian will be used.

Parameters
calendarTypethe name of the calendar type
Since
3.2

Definition at line 2390 of file tdelocale.cpp.

◆ setCharset()

bool TDELocale::setCharset ( const TQString &  charset)
Deprecated:
Returns
True

Definition at line 2457 of file tdelocale.cpp.

◆ setCountry()

bool TDELocale::setCountry ( const TQString &  country)

Changes the current country.

The current country will be left unchanged if failed. It will force a reload of the country specific configuration.

Parameters
countryThe ISO 3166 country code.
Returns
True on success.

Definition at line 390 of file tdelocale.cpp.

◆ setCurrencySymbol()

void TDELocale::setCurrencySymbol ( const TQString &  symbol)

Changes the current currency symbol.

Parameters
symbolThe new currency symbol

Definition at line 2224 of file tdelocale.cpp.

◆ setDateFormat()

void TDELocale::setDateFormat ( const TQString &  format)

Changes the current date format.

The format of the date is a string which contains variables that will be replaced:

  • Y with the century (e.g. "19" for "1984")
  • y with the lower 2 digits of the year (e.g. "84" for "1984")
  • n with the month (January="1", December="12")
  • m with the month with two digits (January="01", December="12")
  • e with the day of the month (e.g. "1" on the first of march)
  • d with the day of the month with two digits(e.g. "01" on the first of march)
  • b with the short form of the month (e.g. "Jan" for January)
  • B with the long form of the month (e.g. "January")
  • a with the short form of the weekday (e.g. "Wed" for Wednesday)
  • A with the long form of the weekday (e.g. "Wednesday" for Wednesday)

Everything else in the format string will be taken as is. For example, March 20th 1989 with the format "%y:%m:%d" results in "89:03:20".

Parameters
formatThe new date format

Definition at line 2096 of file tdelocale.cpp.

◆ setDateFormatShort()

void TDELocale::setDateFormatShort ( const TQString &  format)

Changes the current short date format.

The format of the date is a string which contains variables that will be replaced:

  • Y with the century (e.g. "19" for "1984")
  • y with the lower 2 digits of the year (e.g. "84" for "1984")
  • n with the month (January="1", December="12")
  • m with the month with two digits (January="01", December="12")
  • e with the day of the month (e.g. "1" on the first of march)
  • d with the day of the month with two digits(e.g. "01" on the first of march)
  • b with the short form of the month (e.g. "Jan" for January)
  • B with the long form of the month (e.g. "January")
  • a with the short form of the weekday (e.g. "Wed" for Wednesday)
  • A with the long form of the weekday (e.g. "Wednesday" for Wednesday)

Everything else in the format string will be taken as is. For example, March 20th 1989 with the format "%y:%m:%d" results in "89:03:20".

Parameters
formatThe new short date format

Definition at line 2102 of file tdelocale.cpp.

◆ setDateMonthNamePossessive()

void TDELocale::setDateMonthNamePossessive ( bool  possessive)

Changes the form of month name used in dates.

Parameters
possessiveTrue if possessive forms should be used
Since
3.1

Definition at line 2108 of file tdelocale.cpp.

◆ setDecimalSymbol()

void TDELocale::setDecimalSymbol ( const TQString &  symbol)

Changes the symbol used to identify the decimal pointer.

Parameters
symbolThe new decimal symbol.

Definition at line 2156 of file tdelocale.cpp.

◆ setEncoding()

bool TDELocale::setEncoding ( int  mibEnum)

Changes the current encoding.

Parameters
mibEnumThe mib of the preferred codec
Returns
True on success.

Definition at line 2299 of file tdelocale.cpp.

◆ setFracDigits()

void TDELocale::setFracDigits ( int  digits)

Changes the number of digits used when formating numbers.

Parameters
digitsThe default number of digits to use.

Definition at line 2205 of file tdelocale.cpp.

◆ setLanguage() [1/2]

bool TDELocale::setLanguage ( const TQString &  language)

Changes the current language.

The current language will be left unchanged if failed. It will force a reload of the country specific configuration as well.

Parameters
languageThe language code.
Returns
True on success.

Definition at line 417 of file tdelocale.cpp.

◆ setLanguage() [2/2]

bool TDELocale::setLanguage ( const TQStringList &  languages)

Changes the list of prefed languages for the locale.

The first valid language in the list will be used, or the default (en_US) language will be used if non of the specified languages were available.

Parameters
languagesThe list of language codes.
Returns
True if one of the specified languages were used.

Definition at line 435 of file tdelocale.cpp.

◆ setMainCatalogue()

void TDELocale::setMainCatalogue ( const char *  catalog)
static

Use this as main catalog for all TDELocales, if not the appname will be used.

This function is best to be the very first instruction in your program's main function as it only has an effect before the first TDELocale object is created.

Parameters
catalogCatalogue to override all other main catalogues.

Definition at line 1412 of file tdelocale.cpp.

◆ setMeasureSystem()

void TDELocale::setMeasureSystem ( MeasureSystem  value)

Changes the preferred measuring system.

Returns
value The preferred measuring system

Definition at line 2249 of file tdelocale.cpp.

◆ setMonetaryDecimalSymbol()

void TDELocale::setMonetaryDecimalSymbol ( const TQString &  symbol)

Changes the symbol used to identify the decimal pointer for monetary values.

Parameters
symbolThe new decimal symbol.

Definition at line 2218 of file tdelocale.cpp.

◆ setMonetaryThousandsSeparator()

void TDELocale::setMonetaryThousandsSeparator ( const TQString &  separator)

Changes the separator used to group digits when formating monetary values.

Parameters
separatorThe new thousands separator.

Definition at line 2211 of file tdelocale.cpp.

◆ setNegativeMonetarySignPosition()

void TDELocale::setNegativeMonetarySignPosition ( SignPosition  signpos)

Changes the sign position used for negative monetary values.

Parameters
signposThe new sign position

Definition at line 2187 of file tdelocale.cpp.

◆ setNegativePrefixCurrencySymbol()

void TDELocale::setNegativePrefixCurrencySymbol ( bool  prefix)

Changes the position where the currency symbol should be printed for negative monetary values.

Parameters
prefixTrue if the currency symbol should be prefixed instead of postfixed

Definition at line 2199 of file tdelocale.cpp.

◆ setNegativeSign()

void TDELocale::setNegativeSign ( const TQString &  sign)

Changes the sign used to identify a negative number.

Parameters
signSign used for negative numbers.

Definition at line 2175 of file tdelocale.cpp.

◆ setPageSize()

void TDELocale::setPageSize ( int  paperFormat)

Changes the preferred page size when printing.

Parameters
paperFormatthe new preferred page size in the format TQPrinter::PageSize

Definition at line 2236 of file tdelocale.cpp.

◆ setPositiveMonetarySignPosition()

void TDELocale::setPositiveMonetarySignPosition ( SignPosition  signpos)

Changes the sign position used for positive monetary values.

Parameters
signposThe new sign position

Definition at line 2181 of file tdelocale.cpp.

◆ setPositivePrefixCurrencySymbol()

void TDELocale::setPositivePrefixCurrencySymbol ( bool  prefix)

Changes the position where the currency symbol should be printed for positive monetary values.

Parameters
prefixTrue if the currency symbol should be prefixed instead of postfixed

Definition at line 2193 of file tdelocale.cpp.

◆ setPositiveSign()

void TDELocale::setPositiveSign ( const TQString &  sign)

Changes the sign used to identify a positive number.

Normally this is left blank.

Parameters
signSign used for positive numbers.

Definition at line 2169 of file tdelocale.cpp.

◆ setThousandsSeparator()

void TDELocale::setThousandsSeparator ( const TQString &  separator)

Changes the separator used to group digits when formating numbers.

Parameters
separatorThe new thousands separator.

Definition at line 2162 of file tdelocale.cpp.

◆ setTimeFormat()

void TDELocale::setTimeFormat ( const TQString &  format)

Changes the current time format.

The format of the time is string a which contains variables that will be replaced:

  • H with the hour in 24h format and 2 digits (e.g. 5pm is "17", 5am is "05")
  • k with the hour in 24h format and one digits (e.g. 5pm is "17", 5am is "5")
  • I with the hour in 12h format and 2 digits (e.g. 5pm is "05", 5am is "05")
  • l with the hour in 12h format and one digits (e.g. 5pm is "5", 5am is "5")
  • M with the minute with 2 digits (e.g. the minute of 07:02:09 is "02")
  • S with the seconds with 2 digits (e.g. the minute of 07:02:09 is "09")
  • p with pm or am (e.g. 17.00 is "pm", 05.00 is "am")

Everything else in the format string will be taken as is. For example, 5.23pm with the format "%H:%M" results in "17:23".

Parameters
formatThe new time format

Definition at line 2114 of file tdelocale.cpp.

◆ setWeekStartDay()

void TDELocale::setWeekStartDay ( int  day)

Changes how TDELocale defines the first day in week.

Parameters
dayfirst day of the week (Monday=1..Sunday=7) as integer
Since
3.1

Definition at line 2129 of file tdelocale.cpp.

◆ setWeekStartsMonday()

void TDELocale::setWeekStartsMonday ( bool  start)
Deprecated:

Please use setWeekStartDay instead.

Changes how TDELocale defines the first day in week.

Parameters
startTrue if Monday is the first day in the week

Definition at line 2120 of file tdelocale.cpp.

◆ splitLocale()

void TDELocale::splitLocale ( const TQString &  str,
TQString &  language,
TQString &  country,
TQString &  charset 
)
static

Returns the parts of the parameter str understood as language setting the format is language_COUNTRY.charset.

Parameters
strThe string to split.
languageThis will be set to the language part of the string.
countryThis will be set to the country part of the string.
charsetThis will be set to the charset part of the string.

Definition at line 520 of file tdelocale.cpp.

◆ thousandsSeparator()

TQString TDELocale::thousandsSeparator ( ) const

Returns what the thousands separator should look like ("," or "." etc.) according to the current locale or user settings.

Returns
The thousands separator used by locale.

Definition at line 1036 of file tdelocale.cpp.

◆ timeFormat()

TQString TDELocale::timeFormat ( ) const

Returns the currently selected time format.

Returns
Current time format.
See also
setTimeFormat()

Definition at line 2150 of file tdelocale.cpp.

◆ translate() [1/3]

TQString TDELocale::translate ( const char *  comment,
const char *  fallback 
) const

Translates the string into the corresponding string in the national language, if available.

The real contents of the string is in the argument fallback, but the meaning of it is coded into the argument index. In some cases you'll need this function, when english is too ambiguous to express it.

Most of the times the translators will tell you if it can't be translated as it, but think of cases as "New", where the translations differs depending on what is New. Or simple cases as "Open", that can be used to express something is open or it can be used to express that you want something to open... There are tons of such examples.

If translate("Open") is not enough to translate it well, use translate("To Open", "Open") or translate("Is Open", "Open"). The english user will see "Open" in both cases, but the translated version may vary. Of course you can also use i18n()

Parameters
commentthe comment. The lookup text is made out of comment + fallback
fallbackthe default text, if not found
Returns
translation

Definition at line 773 of file tdelocale.cpp.

◆ translate() [2/3]

TQString TDELocale::translate ( const char *  index) const

Translates the string into the corresponding string in the national language, if available.

If not, returns the string itself. There is a KDE wide message file that contains the most often used phrases, so we can avoid duplicating the translation of these phrases. If a phrase is not found in the catalog given to the constructor, it will search in the system catalog. This makes it possible to override some phrases for your needs.

The argument must be an UTF-8 encoded string (If you only use characters that are in US-ASCII you're on the safe side. But for e.g. german umlauts or french accents should be recoded to UTF-8)

Parameters
indexThe lookup text and default text, if not found.

Definition at line 768 of file tdelocale.cpp.

◆ translate() [3/3]

TQString TDELocale::translate ( const char *  singular,
const char *  plural,
unsigned long  n 
) const

Used to get the correct, translated singular or plural of a word.

Parameters
singularthe singular form of the word, for example "file".
pluralthe plural form of the word. Must contain a "%n" that will be replaced by the number n, for example "%n files"
nthe number
Returns
the correct singular or plural for the selected language, depending on n

Definition at line 809 of file tdelocale.cpp.

◆ translateQt()

TQString TDELocale::translateQt ( const char *  context,
const char *  sourceText,
const char *  message 
) const

Translates a message as a QTranslator is supposed to.

The parameters are similar to i18n(), but the result value has other semantics (it can be TQString::null)

Since
3.1

Definition at line 962 of file tdelocale.cpp.

◆ twoAlphaToCountryName()

TQString TDELocale::twoAlphaToCountryName ( const TQString &  code) const

Convert a country code to a human readable form.

Parameters
codethe country code
Returns
the human readable form of the country name
Since
3.1

Definition at line 2383 of file tdelocale.cpp.

◆ twoAlphaToLanguageName()

TQString TDELocale::twoAlphaToLanguageName ( const TQString &  code) const

Convert a ISO 639-1 code to a human readable form.

Parameters
codethe language ISO 639-1 code
Returns
the human readable form
Since
3.1

Definition at line 2356 of file tdelocale.cpp.

◆ use12Clock()

bool TDELocale::use12Clock ( ) const

Use this to determine if the user wants a 12 hour clock.

Returns
If the user wants 12h clock

Definition at line 1948 of file tdelocale.cpp.

◆ weekDayName()

TQString TDELocale::weekDayName ( int  i,
bool  shortName = false 
) const
Deprecated:
use calendar()->weekDayName

Returns a string containing the name of the week day used in the Gregorian calendar.

Parameters
ithe day number of the week starting at 1/Monday.
shortNamewe will return the short version of the string.
Returns
The name of the day

Definition at line 639 of file tdelocale.cpp.

◆ weekStartDay()

int TDELocale::weekStartDay ( ) const

Use this to determine which day is the first day of the week.

Returns
an integer (Monday=1..Sunday=7)
Since
3.1

Definition at line 1018 of file tdelocale.cpp.

◆ weekStartsMonday()

bool TDELocale::weekStartsMonday ( ) const
Deprecated:

Please use the weekStartDay method instead.

Use this to determine if the user wants the week to start on Monday.

Returns
true if the week starts on Monday

Definition at line 1024 of file tdelocale.cpp.

Friends And Related Function Documentation

◆ i18n() [1/3]

TQString i18n ( const char *  comment,
const char *  text 
)
related

If the string is too ambiguous to be translated well to a non-english language, use this form of i18n to separate lookup string and english text.

See also
translate

Definition at line 1984 of file tdelocale.cpp.

◆ i18n() [2/3]

TQString i18n ( const char *  singular,
const char *  plural,
unsigned long  n 
)
related

If you want to handle plural forms, use this form of i18n.

Parameters
singularthe singular form of the word, for example "file".
pluralthe plural form of the word. Must contain a "%n" that will be replaced by the number n, for example "%n files"
nthe number
Returns
the correct singular or plural for the selected language, depending on n
See also
translate

Definition at line 1992 of file tdelocale.cpp.

◆ i18n() [3/3]

TQString i18n ( const char *  text)
related

i18n is the function that does everything you need to translate a string.

You just wrap around every user visible string a i18n call to get a TQString with the string in the user's preferred language.

The argument must be an UTF-8 encoded string (If you only use characters that are in US-ASCII, you're on the safe side. But for e.g. German umlauts or French accents should be recoded to UTF-8)

Definition at line 1976 of file tdelocale.cpp.

◆ I18N_NOOP

#define I18N_NOOP (   x)    x
related

I18N_NOOP marks a string to be translated without translating it.

Do not use this unless you know you need it. http://developer.kde.org/documentation/other/developer-faq.html#q2.11.2

Definition at line 51 of file tdelocale.h.

◆ I18N_NOOP2

#define I18N_NOOP2 (   comment,
  x 
)    x
related

If the string is too ambiguous to be translated well to a non-english language, use this instead of I18N_NOOP to separate lookup string and english.

Warning
You need to call i18n( comment, stringVar ) later on, not just i18n( stringVar ).
Since
3.3

Definition at line 62 of file tdelocale.h.

◆ TDEGlobal

friend class TDEGlobal
friend

Definition at line 125 of file tdelocale.h.

◆ tr2i18n()

TQString tr2i18n ( const char *  message,
const char *  = 0 
)
related

Qt3's uic generates i18n( "msg", "comment" ) calls which conflict with our i18n method.

We use uic -tr tr2i18n to redirect to the right i18n() function

Definition at line 107 of file tdelocale.h.


The documentation for this class was generated from the following files:
  • tdelocale.h
  • tdelocale.cpp

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.