org.kde.koala
Class KLocale

java.lang.Object
  extended by org.kde.koala.KLocale
All Implemented Interfaces:
org.kde.qt.QtSupport

public class KLocale
extends java.lang.Object
implements org.kde.qt.QtSupport

KLocale provides support for country specific stuff like the national language. KLocale supports translating, as well as specifying the format for numbers, currency, time, and date.

Author:
Stephan Kulow , Preston Brown , Hans Petter Bieker , Lukas Tinkl

Field Summary
static int AfterMoney
           
static int AfterQuantityMoney
           
static int BeforeMoney
           
static int BeforeQuantityMoney
           
static int Imperial
           
static int Metric
          The Metric system will give you information in mm, while the Imperial system will give you information in inches.
static int NormalFormat
           
static int ParensAround
          Various positions for where to place the positive or negative sign when they are related to a monetary value.
static int ShortFormat
           
static int WithoutSeconds
           
static int WithSeconds
           
 
Constructor Summary
protected KLocale(java.lang.Class dummy)
           
  KLocale(KLocale rhs)
          Copy constructor.
  KLocale(java.lang.String catalog)
           
  KLocale(java.lang.String catalog, KConfig config)
          Constructs a KLocale with the given catalog name.
 
Method Summary
static java.lang.String _initLanguage(KConfigBase config)
           
 java.util.ArrayList allCountriesTwoAlpha()
          Returns list of all known country codes.
 java.util.ArrayList allLanguagesTwoAlpha()
          Returns list of all known ISO 639-1 codes.
 KCalendarSystem calendar()
          Returns a pointer to the calendar system object.
 java.lang.String calendarType()
          Returns the name of the calendar system that is currently being used by the system.
 org.kde.qt.QTextCodec codecForEncoding()
          Returns the user's preferred encoding.
 java.lang.String country()
          Returns the country code of the country where the user lives.
 java.lang.String currencySymbol()
          Returns what the symbol denoting currency in the current locale as as defined by user settings should look like.
 java.lang.String dateFormat()
          Returns the currently selected date format.
 java.lang.String dateFormatShort()
          Returns the currently selected short date format.
 boolean dateMonthNamePossessive()
          Use this to determine whether in dates a possessive form of month name is preferred ("of January" rather than "January")
 java.lang.String decimalSymbol()
          Returns what a decimal point should look like ("." or "," etc.) according to the current locale or user settings.
static java.lang.String defaultCountry()
          Returns the name of the default country.
static java.lang.String defaultLanguage()
          Returns the name of the internal language.
 void dispose()
          Delete the wrapped C++ instance ahead of finalize()
 java.lang.String encoding()
          Returns the user's preferred encoding.
 int encodingMib()
          Returns the user's preferred encoding.
 int fileEncodingMib()
          Returns the file encoding.
protected  void finalize()
          Deletes the wrapped C++ instance
 java.lang.String formatDate(java.util.Calendar pDate)
           
 java.lang.String formatDate(java.util.Calendar pDate, boolean shortFormat)
          Returns a string formatted to the current locale's conventions regarding dates.
 java.lang.String formatDateTime(java.util.Calendar pDateTime)
           
 java.lang.String formatDateTime(java.util.Calendar pDateTime, boolean shortFormat)
           
 java.lang.String formatDateTime(java.util.Calendar pDateTime, boolean shortFormat, boolean includeSecs)
          Returns a string formated to the current locale's conventions regarding both date and time.
 java.lang.String formatLong(long num)
          Given an integer, converts that to a numeric string containing the localized numeric equivalent.
 java.lang.String formatMoney(double num)
           
 java.lang.String formatMoney(double num, java.lang.String currency)
           
 java.lang.String formatMoney(double num, java.lang.String currency, int digits)
          Given a double, converts that to a numeric string containing the localized monetary equivalent.
 java.lang.String formatNumber(double num)
           
 java.lang.String formatNumber(double num, int precision)
          Given a double, converts that to a numeric string containing the localized numeric equivalent.
 java.lang.String formatNumber(java.lang.String numStr, boolean round, int precision)
          Given a string representing a number, converts that to a numeric string containing the localized numeric equivalent.
 java.lang.String formatTime(java.util.Date pTime)
           
 java.lang.String formatTime(java.util.Date pTime, boolean includeSecs)
          Returns a string formatted to the current locale's conventions regarding times.
 java.lang.String formatTime(java.util.Date pTime, boolean includeSecs, boolean isDuration)
          Returns a string formatted to the current locale's conventions regarding times.
 int fracDigits()
          The number of fractional digits to include in numeric/monetary values (usually 2).
protected static void initInstance()
          pointer.
 void insertCatalogue(java.lang.String catalog)
          Adds another catalog to search for translation lookup.
 boolean isDisposed()
          Has the wrapped C++ instance been deleted?
static java.lang.String langLookup(java.lang.String fname)
           
static java.lang.String langLookup(java.lang.String fname, java.lang.String rtype)
          Finds localized resource in resourceDir( rtype ) + \ + fname.
 java.lang.String language()
          Returns the language used by this object.
 java.util.ArrayList languageList()
          Returns the languages selected by user.
 java.util.ArrayList languagesTwoAlpha()
          Returns the preferred languages as ISO 639-1 codes.
 int measureSystem()
          Returns which measuring system we use.
 java.lang.String monetaryDecimalSymbol()
          Returns what a decimal point should look like ("." or "," etc.) for monetary values, according to the current locale or user settings.
 java.lang.String monetaryThousandsSeparator()
          Returns what a thousands separator for monetary values should look like ("," or " " etc.) according to the current locale or user settings.
 int negativeMonetarySignPosition()
          Denotes where to place a negative sign in relation to a monetary value.
 boolean negativePrefixCurrencySymbol()
          If and only if the currency symbol precedes a negative value, this will be true.
 java.lang.String negativeSign()
          Returns what a negative sign should look like ("-", etc.) according to the current locale or user settings.
 boolean nounDeclension()
          Use this to determine whether nouns are declined in locale's language.
 int pageSize()
          Returns the preferred page size for printing.
 int positiveMonetarySignPosition()
          Returns the position of a positive sign in relation to a monetary value.
 boolean positivePrefixCurrencySymbol()
          If and only if the currency symbol precedes a positive value, this will be true.
 java.lang.String positiveSign()
          Returns what a positive sign should look like ("+", " ", etc.) according to the current locale or user settings.
 java.util.Calendar readDate(java.lang.String str)
           
 java.util.Calendar readDate(java.lang.String str, boolean[] ok)
          Converts a localized date string to a Calendar.
 java.util.Calendar readDate(java.lang.String str, int flags)
           
 java.util.Calendar readDate(java.lang.String str, int flags, boolean[] ok)
          Converts a localized date string to a Calendar.
 java.util.Calendar readDate(java.lang.String intstr, java.lang.String fmt)
           
 java.util.Calendar readDate(java.lang.String intstr, java.lang.String fmt, boolean[] ok)
          Converts a localized date string to a Calendar, using the specified format.
 double readMoney(java.lang.String numStr)
           
 double readMoney(java.lang.String numStr, boolean[] ok)
          Converts a localized monetary string to a double.
 double readNumber(java.lang.String numStr)
           
 double readNumber(java.lang.String numStr, boolean[] ok)
          Converts a localized numeric string to a double.
 java.util.Date readTime(java.lang.String str)
           
 java.util.Date readTime(java.lang.String str, boolean[] ok)
          Converts a localized time string to a Date This method will try to parse it with seconds, then without seconds.
 java.util.Date readTime(java.lang.String str, int flags)
           
 java.util.Date readTime(java.lang.String str, int flags, boolean[] ok)
          Converts a localized time string to a Date This method is stricter than readTime(str,&ok): it will either accept a time with seconds or a time without seconds.
 void removeCatalogue(java.lang.String catalog)
          Removes a catalog for translation lookup.
 void setActiveCatalogue(java.lang.String catalog)
          Sets the active catalog for translation lookup.
 void setCalendar(java.lang.String calendarType)
          Changes the current calendar system to the calendar specified.
 boolean setCountry(java.lang.String country)
          Changes the current country.
 void setCurrencySymbol(java.lang.String symbol)
          Changes the current currency symbol.
 void setDateFormat(java.lang.String format)
          Changes the current date format.
 void setDateFormatShort(java.lang.String format)
          Changes the current short date format.
 void setDateMonthNamePossessive(boolean possessive)
          Changes the form of month name used in dates.
 void setDecimalSymbol(java.lang.String symbol)
          Changes the symbol used to identify the decimal pointer.
 boolean setEncoding(int mibEnum)
          Changes the current encoding.
 void setFracDigits(int digits)
          Changes the number of digits used when formating numbers.
 boolean setLanguage(java.lang.String language)
          Changes the current language.
 boolean setLanguage(java.lang.String[] languages)
          Changes the list of prefed languages for the locale.
static void setMainCatalogue(java.lang.String catalog)
          Use this as main catalog for all KLocales, if not the appname will be used.
 void setMeasureSystem(int value)
          Changes the preferred measuring system.
 void setMonetaryDecimalSymbol(java.lang.String symbol)
          Changes the symbol used to identify the decimal pointer for monetary values.
 void setMonetaryThousandsSeparator(java.lang.String separator)
          Changes the separator used to group digits when formating monetary values.
 void setNegativeMonetarySignPosition(int signpos)
          Changes the sign position used for negative monetary values.
 void setNegativePrefixCurrencySymbol(boolean prefix)
          Changes the position where the currency symbol should be printed for negative monetary values.
 void setNegativeSign(java.lang.String sign)
          Changes the sign used to identify a negative number.
 void setPageSize(int paperFormat)
          Changes the preferred page size when printing.
 void setPositiveMonetarySignPosition(int signpos)
          Changes the sign position used for positive monetary values.
 void setPositivePrefixCurrencySymbol(boolean prefix)
          Changes the position where the currency symbol should be printed for positive monetary values.
 void setPositiveSign(java.lang.String sign)
          Changes the sign used to identify a positive number.
 void setThousandsSeparator(java.lang.String separator)
          Changes the separator used to group digits when formating numbers.
 void setTimeFormat(java.lang.String format)
          Changes the current time format.
 void setWeekStartDay(int day)
          Changes how KLocale defines the first day in week.
static void splitLocale(java.lang.String str, java.lang.StringBuffer language, java.lang.StringBuffer country, java.lang.StringBuffer charset)
          Returns the parts of the parameter str understood as language setting the format is language_COUNTRY.charset
 java.lang.String thousandsSeparator()
          Returns what the thousands separator should look like ("," or "." etc.) according to the current locale or user settings.
 java.lang.String timeFormat()
          Returns the currently selected time format.
 java.lang.String translate(java.lang.String index)
          Translates the string into the corresponding string in the national language, if available.
 java.lang.String translate(java.lang.String comment, java.lang.String fallback)
          Translates the string into the corresponding string in the national language, if available.
 java.lang.String translate(java.lang.String singular, java.lang.String plural, long n)
          Used to get the correct, translated singular or plural of a word.
 java.lang.String translateQt(java.lang.String context, java.lang.String sourceText, java.lang.String message)
          Translates a message as a QTranslator is supposed to.
 java.lang.String twoAlphaToCountryName(java.lang.String code)
          Convert a country code to a human readable form.
 java.lang.String twoAlphaToLanguageName(java.lang.String code)
          Convert a ISO 639-1 code to a human readable form.
 boolean use12Clock()
          Use this to determine if the user wants a 12 hour clock.
 int weekStartDay()
          Use this to determine which day is the first day of the week.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ParensAround

public static final int ParensAround
Various positions for where to place the positive or negative sign when they are related to a monetary value.

See Also:
Constant Field Values

BeforeQuantityMoney

public static final int BeforeQuantityMoney
See Also:
Constant Field Values

AfterQuantityMoney

public static final int AfterQuantityMoney
See Also:
Constant Field Values

BeforeMoney

public static final int BeforeMoney
See Also:
Constant Field Values

AfterMoney

public static final int AfterMoney
See Also:
Constant Field Values

NormalFormat

public static final int NormalFormat
See Also:
Constant Field Values

ShortFormat

public static final int ShortFormat
See Also:
Constant Field Values

WithSeconds

public static final int WithSeconds
See Also:
Constant Field Values

WithoutSeconds

public static final int WithoutSeconds
See Also:
Constant Field Values

Metric

public static final int Metric
The Metric system will give you information in mm, while the Imperial system will give you information in inches.

See Also:
Constant Field Values

Imperial

public static final int Imperial
See Also:
Constant Field Values
Constructor Detail

KLocale

protected KLocale(java.lang.Class dummy)

KLocale

public KLocale(java.lang.String catalog,
               KConfig config)
Constructs a KLocale 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 (KDE_LANG, LC_MESSAGES, LC_ALL, LANG), as well as the global configuration file. If KLocale 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 KLocale object is destroyed.

Parameters:
catalog - The name of the main language file
config - The configuration file to use.

KLocale

public KLocale(java.lang.String catalog)

KLocale

public KLocale(KLocale rhs)
Copy constructor.

Method Detail

translate

public java.lang.String translate(java.lang.String index)
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:
index - The lookup text and default text, if not found.

translate

public java.lang.String translate(java.lang.String comment,
                                  java.lang.String fallback)
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:
comment - the comment. The lookup text is made out of comment + fallback
fallback - the default text, if not found
Returns:
translation

translate

public java.lang.String translate(java.lang.String singular,
                                  java.lang.String plural,
                                  long n)
Used to get the correct, translated singular or plural of a word.

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

setEncoding

public boolean setEncoding(int mibEnum)
Changes the current encoding.

Parameters:
mibEnum - The mib of the preferred codec
Returns:
True on success.

setLanguage

public boolean setLanguage(java.lang.String 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:
language - The language code.
Returns:
True on success.

setLanguage

public boolean setLanguage(java.lang.String[] 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:
languages - The list of language codes.
Returns:
True if one of the specified languages were used.

setCountry

public boolean setCountry(java.lang.String 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:
country - The ISO 3166 country code.
Returns:
True on success.

decimalSymbol

public java.lang.String decimalSymbol()
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.

thousandsSeparator

public java.lang.String thousandsSeparator()
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.

currencySymbol

public java.lang.String currencySymbol()
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.

monetaryDecimalSymbol

public java.lang.String monetaryDecimalSymbol()
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.

monetaryThousandsSeparator

public java.lang.String monetaryThousandsSeparator()
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.

positiveSign

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

Returns:
The positive sign used by locale.

negativeSign

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

Returns:
The negative sign used by locale.

fracDigits

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

Returns:
Default number of fractional digits used by locale.

positivePrefixCurrencySymbol

public boolean positivePrefixCurrencySymbol()
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.

negativePrefixCurrencySymbol

public boolean negativePrefixCurrencySymbol()
If and only if the currency symbol precedes a negative value, this will be true.

Returns:
True if the currency symbol precedes negative numbers.

positiveMonetarySignPosition

public int positiveMonetarySignPosition()
Returns the position of a positive sign in relation to a monetary value.

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

negativeMonetarySignPosition

public int negativeMonetarySignPosition()
Denotes where to place a negative sign in relation to a monetary value.

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

formatMoney

public java.lang.String formatMoney(double num,
                                    java.lang.String currency,
                                    int digits)
Given a double, converts that to a numeric string containing the localized monetary equivalent. e.g. given 123456, return "$ 123,456.00".

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

formatMoney

public java.lang.String formatMoney(double num,
                                    java.lang.String currency)

formatMoney

public java.lang.String formatMoney(double num)

formatNumber

public java.lang.String formatNumber(double num,
                                     int precision)
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:
num - The number to convert
precision - Number of fractional digits used.
Returns:
The number as a localized string
See Also:
#formatNumber(const, #boolean, #int)

formatNumber

public java.lang.String formatNumber(double num)

formatNumber

public java.lang.String formatNumber(java.lang.String numStr,
                                     boolean round,
                                     int precision)
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:
numStr - The number to convert
round - Round fractional digits.
precision - Number of fractional digits used.
Returns:
The number as a localized string

formatLong

public java.lang.String formatLong(long num)
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:
num - The number to convert
Returns:
The number as a localized string

nounDeclension

public boolean nounDeclension()
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

formatDate

public java.lang.String formatDate(java.util.Calendar pDate,
                                   boolean shortFormat)
Returns a string formatted to the current locale's conventions regarding dates.

Parameters:
pDate - The date to be formated.
shortFormat - True for non text dates.
Returns:
The date as a string

formatDate

public java.lang.String formatDate(java.util.Calendar pDate)

dateMonthNamePossessive

public boolean dateMonthNamePossessive()
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

formatTime

public java.lang.String formatTime(java.util.Date pTime,
                                   boolean includeSecs,
                                   boolean isDuration)
Returns a string formatted to the current locale's conventions regarding times.

Parameters:
pTime - The time to be formated.
includeSecs - if true, seconds are included in the output, otherwise only hours and minutes are formatted.
isDuration - if 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

formatTime

public java.lang.String formatTime(java.util.Date pTime,
                                   boolean includeSecs)
Returns a string formatted to the current locale's conventions regarding times.

Parameters:
pTime - The time to be formated.
includeSecs - if true, seconds are included in the output, otherwise only hours and minutes are formatted.
Returns:
The time as a string

formatTime

public java.lang.String formatTime(java.util.Date pTime)

use12Clock

public boolean use12Clock()
Use this to determine if the user wants a 12 hour clock.

Returns:
If the user wants 12h clock

weekStartDay

public int weekStartDay()
Use this to determine which day is the first day of the week.

Returns:
an integer (Monday=1..Sunday=7)

calendar

public KCalendarSystem calendar()
Returns a pointer to the calendar system object.

Returns:
the current calendar system instance

calendarType

public java.lang.String calendarType()
Returns the name of the calendar system that is currently being used by the system.

Returns:
the name of the calendar system

setCalendar

public void setCalendar(java.lang.String 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:
calendarType - the name of the calendar type

formatDateTime

public java.lang.String formatDateTime(java.util.Calendar pDateTime,
                                       boolean shortFormat,
                                       boolean includeSecs)
Returns a string formated to the current locale's conventions regarding both date and time.

Parameters:
pDateTime - The date and time to be formated.
shortFormat - using the short date format.
includeSecs - using the short date format.
Returns:
The date and time as a string

formatDateTime

public java.lang.String formatDateTime(java.util.Calendar pDateTime,
                                       boolean shortFormat)

formatDateTime

public java.lang.String formatDateTime(java.util.Calendar pDateTime)

readMoney

public double readMoney(java.lang.String numStr,
                        boolean[] ok)
Converts a localized monetary string to a double.

Parameters:
numStr - the string we want to convert.
ok - the booleanean 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

readMoney

public double readMoney(java.lang.String numStr)

readNumber

public double readNumber(java.lang.String numStr,
                         boolean[] ok)
Converts a localized numeric string to a double.

Parameters:
numStr - the string we want to convert.
ok - the booleanean 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

readNumber

public double readNumber(java.lang.String numStr)

readDate

public java.util.Calendar readDate(java.lang.String str,
                                   boolean[] ok)
Converts a localized date string to a Calendar. The boolean pointed by ok will be invalid if the date entered was not valid.

Parameters:
str - the string we want to convert.
ok - the booleanean 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

readDate

public java.util.Calendar readDate(java.lang.String str)

readDate

public java.util.Calendar readDate(java.lang.String intstr,
                                   java.lang.String fmt,
                                   boolean[] ok)
Converts a localized date string to a Calendar, using the specified format. You will usually not want to use this method.


readDate

public java.util.Calendar readDate(java.lang.String intstr,
                                   java.lang.String fmt)

readDate

public java.util.Calendar readDate(java.lang.String str,
                                   int flags,
                                   boolean[] ok)
Converts a localized date string to a Calendar. 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:
str - the string we want to convert.
flags - whether the date string is to be in full format or in short format.
ok - the booleanean 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

readDate

public java.util.Calendar readDate(java.lang.String str,
                                   int flags)

readTime

public java.util.Date readTime(java.lang.String str,
                               boolean[] ok)
Converts a localized time string to a Date This method will try to parse it with seconds, then without seconds. The boolean pointed to by ok will be set to false if the time entered was not valid.

Parameters:
str - the string we want to convert.
ok - the booleanean 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

readTime

public java.util.Date readTime(java.lang.String str)

readTime

public java.util.Date readTime(java.lang.String str,
                               int flags,
                               boolean[] ok)
Converts a localized time string to a Date 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:
str - the string we want to convert.
flags - whether the time string is expected to contain seconds or not.
ok - the booleanean 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

readTime

public java.util.Date readTime(java.lang.String str,
                               int flags)

language

public java.lang.String language()
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.

country

public java.lang.String country()
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.

languagesTwoAlpha

public java.util.ArrayList languagesTwoAlpha()
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()

languageList

public java.util.ArrayList languageList()
Returns the languages selected by user. The codes returned here is the internal language codes.

Returns:
List of language codes
See Also:
languagesTwoAlpha()

encoding

public java.lang.String encoding()
Returns the user's preferred encoding.

Returns:
The name of the preferred encoding
See Also:
codecForEncoding(), encodingMib()

encodingMib

public int encodingMib()
Returns the user's preferred encoding.

Returns:
The Mib of the preferred encoding
See Also:
encoding(), codecForEncoding()

codecForEncoding

public org.kde.qt.QTextCodec codecForEncoding()
Returns the user's preferred encoding. Should never be NULL.

Returns:
The codec for the preferred encoding
See Also:
encoding(), encodingMib()

fileEncodingMib

public int fileEncodingMib()
Returns the file encoding.

Returns:
The Mib of the file encoding
See Also:
QFile.encodeName(java.lang.String), QFile.decodeName(java.lang.String)

setDateFormat

public void setDateFormat(java.lang.String 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:
    format - The new date format

    setDateFormatShort

    public void setDateFormatShort(java.lang.String 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:
    format - The new short date format

    setDateMonthNamePossessive

    public void setDateMonthNamePossessive(boolean possessive)
    Changes the form of month name used in dates.

    Parameters:
    possessive - True if possessive forms should be used

    setTimeFormat

    public void setTimeFormat(java.lang.String 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:
    format - The new time format

    setWeekStartDay

    public void setWeekStartDay(int day)
    Changes how KLocale defines the first day in week.

    Parameters:
    day - first day of the week (Monday=1..Sunday=7) as integer

    dateFormat

    public java.lang.String dateFormat()
    Returns the currently selected date format.

    Returns:
    Current date format.
    See Also:
    setDateFormat(java.lang.String)

    dateFormatShort

    public java.lang.String dateFormatShort()
    Returns the currently selected short date format.

    Returns:
    Current short date format.
    See Also:
    setDateFormatShort(java.lang.String)

    timeFormat

    public java.lang.String timeFormat()
    Returns the currently selected time format.

    Returns:
    Current time format.
    See Also:
    setTimeFormat(java.lang.String)

    setDecimalSymbol

    public void setDecimalSymbol(java.lang.String symbol)
    Changes the symbol used to identify the decimal pointer.

    Parameters:
    symbol - The new decimal symbol.

    setThousandsSeparator

    public void setThousandsSeparator(java.lang.String separator)
    Changes the separator used to group digits when formating numbers.

    Parameters:
    separator - The new thousands separator.

    setPositiveSign

    public void setPositiveSign(java.lang.String sign)
    Changes the sign used to identify a positive number. Normally this is left blank.

    Parameters:
    sign - Sign used for positive numbers.

    setNegativeSign

    public void setNegativeSign(java.lang.String sign)
    Changes the sign used to identify a negative number.

    Parameters:
    sign - Sign used for negative numbers.

    setPositiveMonetarySignPosition

    public void setPositiveMonetarySignPosition(int signpos)
    Changes the sign position used for positive monetary values.

    Parameters:
    signpos - The new sign position

    setNegativeMonetarySignPosition

    public void setNegativeMonetarySignPosition(int signpos)
    Changes the sign position used for negative monetary values.

    Parameters:
    signpos - The new sign position

    setPositivePrefixCurrencySymbol

    public void setPositivePrefixCurrencySymbol(boolean prefix)
    Changes the position where the currency symbol should be printed for positive monetary values.

    Parameters:
    prefix - True if the currency symbol should be prefixed instead of postfixed

    setNegativePrefixCurrencySymbol

    public void setNegativePrefixCurrencySymbol(boolean prefix)
    Changes the position where the currency symbol should be printed for negative monetary values.

    Parameters:
    prefix - True if the currency symbol should be prefixed instead of postfixed

    setFracDigits

    public void setFracDigits(int digits)
    Changes the number of digits used when formating numbers.

    Parameters:
    digits - The default number of digits to use.

    setMonetaryThousandsSeparator

    public void setMonetaryThousandsSeparator(java.lang.String separator)
    Changes the separator used to group digits when formating monetary values.

    Parameters:
    separator - The new thousands separator.

    setMonetaryDecimalSymbol

    public void setMonetaryDecimalSymbol(java.lang.String symbol)
    Changes the symbol used to identify the decimal pointer for monetary values.

    Parameters:
    symbol - The new decimal symbol.

    setCurrencySymbol

    public void setCurrencySymbol(java.lang.String symbol)
    Changes the current currency symbol.

    Parameters:
    symbol - The new currency symbol

    pageSize

    public int pageSize()
    Returns the preferred page size for printing.

    Returns:
    The preferred page size, cast it to QPrinter.PageSize

    setPageSize

    public void setPageSize(int paperFormat)
    Changes the preferred page size when printing.

    Parameters:
    paperFormat - the new preferred page size in the format QPrinter.PageSize

    measureSystem

    public int measureSystem()
    Returns which measuring system we use.

    Returns:
    The preferred measuring system

    setMeasureSystem

    public void setMeasureSystem(int value)
    Changes the preferred measuring system.


    insertCatalogue

    public void insertCatalogue(java.lang.String 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:
    catalog - The catalog to add.

    removeCatalogue

    public void removeCatalogue(java.lang.String catalog)
    Removes a catalog for translation lookup.

    Parameters:
    catalog - The catalog to remove.
    See Also:
    insertCatalogue(java.lang.String)

    setActiveCatalogue

    public void setActiveCatalogue(java.lang.String catalog)
    Sets the active catalog for translation lookup.

    Parameters:
    catalog - The catalog to activate.

    translateQt

    public java.lang.String translateQt(java.lang.String context,
                                        java.lang.String sourceText,
                                        java.lang.String message)
    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 null)


    allLanguagesTwoAlpha

    public java.util.ArrayList allLanguagesTwoAlpha()
    Returns list of all known ISO 639-1 codes.

    Returns:
    a list of all language codes

    twoAlphaToLanguageName

    public java.lang.String twoAlphaToLanguageName(java.lang.String code)
    Convert a ISO 639-1 code to a human readable form.

    Parameters:
    code - the language ISO 639-1 code
    Returns:
    the human readable form

    allCountriesTwoAlpha

    public java.util.ArrayList allCountriesTwoAlpha()
    Returns list of all known country codes.

    Returns:
    a list of all country codes

    twoAlphaToCountryName

    public java.lang.String twoAlphaToCountryName(java.lang.String code)
    Convert a country code to a human readable form.

    Parameters:
    code - the country code
    Returns:
    the human readable form of the country name

    splitLocale

    public static void splitLocale(java.lang.String str,
                                   java.lang.StringBuffer language,
                                   java.lang.StringBuffer country,
                                   java.lang.StringBuffer charset)
    Returns the parts of the parameter str understood as language setting the format is language_COUNTRY.charset

    Parameters:
    str - The string to split.
    language - This will be set to the language part of the string.
    country - This will be set to the country part of the string.
    charset - This will be set to the charset part of the string.

    setMainCatalogue

    public static void setMainCatalogue(java.lang.String catalog)
    Use this as main catalog for all KLocales, 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 KLocale object is created.

    Parameters:
    catalog - Catalogue to override all other main catalogues.

    langLookup

    public static java.lang.String langLookup(java.lang.String fname,
                                              java.lang.String rtype)
    Finds localized resource in resourceDir( rtype ) + \ + fname.

    Parameters:
    fname - relative path to find
    rtype - resource type to use

    langLookup

    public static java.lang.String langLookup(java.lang.String fname)

    defaultLanguage

    public static java.lang.String defaultLanguage()
    Returns the name of the internal language.

    Returns:
    Name of the default language

    defaultCountry

    public static java.lang.String defaultCountry()
    Returns the name of the default country.

    Returns:
    Name of the default country

    _initLanguage

    public static java.lang.String _initLanguage(KConfigBase config)

    initInstance

    protected static void initInstance()
    pointer.


    finalize

    protected void finalize()
                     throws java.lang.InternalError
    Deletes the wrapped C++ instance

    Overrides:
    finalize in class java.lang.Object
    Throws:
    java.lang.InternalError

    dispose

    public void dispose()
    Delete the wrapped C++ instance ahead of finalize()


    isDisposed

    public boolean isDisposed()
    Has the wrapped C++ instance been deleted?