|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.kde.koala.KLocale
public class KLocale
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.
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 ) + \ |
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 |
---|
public static final int ParensAround
public static final int BeforeQuantityMoney
public static final int AfterQuantityMoney
public static final int BeforeMoney
public static final int AfterMoney
public static final int NormalFormat
public static final int ShortFormat
public static final int WithSeconds
public static final int WithoutSeconds
public static final int Metric
public static final int Imperial
Constructor Detail |
---|
protected KLocale(java.lang.Class dummy)
public KLocale(java.lang.String catalog, KConfig config)
catalog
- The name of the main language fileconfig
- The configuration file to use.public KLocale(java.lang.String catalog)
public KLocale(KLocale rhs)
Method Detail |
---|
public java.lang.String translate(java.lang.String index)
index
- The lookup text and default text, if not found.public java.lang.String translate(java.lang.String comment, java.lang.String fallback)
comment
- the comment. The lookup text is made out of comment + fallback
fallback
- the default text, if not found
public java.lang.String translate(java.lang.String singular, java.lang.String plural, long n)
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
public boolean setEncoding(int mibEnum)
mibEnum
- The mib of the preferred codec
public boolean setLanguage(java.lang.String language)
language
- The language code.
public boolean setLanguage(java.lang.String[] languages)
languages
- The list of language codes.
public boolean setCountry(java.lang.String country)
country
- The ISO 3166 country code.
public java.lang.String decimalSymbol()
public java.lang.String thousandsSeparator()
public java.lang.String currencySymbol()
public java.lang.String monetaryDecimalSymbol()
public java.lang.String monetaryThousandsSeparator()
public java.lang.String positiveSign()
public java.lang.String negativeSign()
public int fracDigits()
public boolean positivePrefixCurrencySymbol()
public boolean negativePrefixCurrencySymbol()
public int positiveMonetarySignPosition()
SignPosition
public int negativeMonetarySignPosition()
SignPosition
public java.lang.String formatMoney(double num, java.lang.String currency, int digits)
num
- The number we want to formatcurrency
- The currency symbol you want.digits
- Number of fractional digits, or -1 for the default
value
fracDigits()
public java.lang.String formatMoney(double num, java.lang.String currency)
public java.lang.String formatMoney(double num)
public java.lang.String formatNumber(double num, int precision)
num
- The number to convertprecision
- Number of fractional digits used.
#formatNumber(const
,
#boolean
,
#int)
public java.lang.String formatNumber(double num)
public java.lang.String formatNumber(java.lang.String numStr, boolean round, int precision)
numStr
- The number to convertround
- Round fractional digits.precision
- Number of fractional digits used.
public java.lang.String formatLong(long num)
num
- The number to convert
public boolean nounDeclension()
public java.lang.String formatDate(java.util.Calendar pDate, boolean shortFormat)
pDate
- The date to be formated.shortFormat
- True for non text dates.
public java.lang.String formatDate(java.util.Calendar pDate)
public boolean dateMonthNamePossessive()
public java.lang.String formatTime(java.util.Date pTime, boolean includeSecs, boolean isDuration)
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.
public java.lang.String formatTime(java.util.Date pTime, boolean includeSecs)
pTime
- The time to be formated.includeSecs
- if true, seconds are included in the output,
otherwise only hours and minutes are formatted.
public java.lang.String formatTime(java.util.Date pTime)
public boolean use12Clock()
public int weekStartDay()
public KCalendarSystem calendar()
public java.lang.String calendarType()
public void setCalendar(java.lang.String calendarType)
calendarType
- the name of the calendar typepublic java.lang.String formatDateTime(java.util.Calendar pDateTime, boolean shortFormat, boolean includeSecs)
pDateTime
- The date and time to be formated.shortFormat
- using the short date format.includeSecs
- using the short date format.
public java.lang.String formatDateTime(java.util.Calendar pDateTime, boolean shortFormat)
public java.lang.String formatDateTime(java.util.Calendar pDateTime)
public double readMoney(java.lang.String numStr, boolean[] ok)
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
public double readMoney(java.lang.String numStr)
public double readNumber(java.lang.String numStr, boolean[] ok)
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
public double readNumber(java.lang.String numStr)
public java.util.Calendar readDate(java.lang.String str, boolean[] ok)
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
public java.util.Calendar readDate(java.lang.String str)
public java.util.Calendar readDate(java.lang.String intstr, java.lang.String fmt, boolean[] ok)
public java.util.Calendar readDate(java.lang.String intstr, java.lang.String fmt)
public java.util.Calendar readDate(java.lang.String str, int flags, boolean[] ok)
flags.
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
public java.util.Calendar readDate(java.lang.String str, int flags)
public java.util.Date readTime(java.lang.String str, boolean[] ok)
ok
will be set to false if the time entered was
not valid.
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
public java.util.Date readTime(java.lang.String str)
public java.util.Date readTime(java.lang.String str, int flags, boolean[] ok)
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
public java.util.Date readTime(java.lang.String str, int flags)
public java.lang.String language()
public java.lang.String country()
public java.util.ArrayList languagesTwoAlpha()
languageList()
public java.util.ArrayList languageList()
languagesTwoAlpha()
public java.lang.String encoding()
codecForEncoding()
,
encodingMib()
public int encodingMib()
encoding()
,
codecForEncoding()
public org.kde.qt.QTextCodec codecForEncoding()
encoding()
,
encodingMib()
public int fileEncodingMib()
QFile.encodeName(java.lang.String)
,
QFile.decodeName(java.lang.String)
public void setDateFormat(java.lang.String format)
format
- The new date formatpublic void setDateFormatShort(java.lang.String format)
format
- The new short date formatpublic void setDateMonthNamePossessive(boolean possessive)
possessive
- True if possessive forms should be usedpublic void setTimeFormat(java.lang.String format)
format
- The new time formatpublic void setWeekStartDay(int day)
day
- first day of the week (Monday=1..Sunday=7) as integerpublic java.lang.String dateFormat()
setDateFormat(java.lang.String)
public java.lang.String dateFormatShort()
setDateFormatShort(java.lang.String)
public java.lang.String timeFormat()
setTimeFormat(java.lang.String)
public void setDecimalSymbol(java.lang.String symbol)
symbol
- The new decimal symbol.public void setThousandsSeparator(java.lang.String separator)
separator
- The new thousands separator.public void setPositiveSign(java.lang.String sign)
sign
- Sign used for positive numbers.public void setNegativeSign(java.lang.String sign)
sign
- Sign used for negative numbers.public void setPositiveMonetarySignPosition(int signpos)
signpos
- The new sign positionpublic void setNegativeMonetarySignPosition(int signpos)
signpos
- The new sign positionpublic void setPositivePrefixCurrencySymbol(boolean prefix)
prefix
- True if the currency symbol should be prefixed instead of
postfixedpublic void setNegativePrefixCurrencySymbol(boolean prefix)
prefix
- True if the currency symbol should be prefixed instead of
postfixedpublic void setFracDigits(int digits)
digits
- The default number of digits to use.public void setMonetaryThousandsSeparator(java.lang.String separator)
separator
- The new thousands separator.public void setMonetaryDecimalSymbol(java.lang.String symbol)
symbol
- The new decimal symbol.public void setCurrencySymbol(java.lang.String symbol)
symbol
- The new currency symbolpublic int pageSize()
public void setPageSize(int paperFormat)
paperFormat
- the new preferred page size in the format QPrinter.PageSizepublic int measureSystem()
public void setMeasureSystem(int value)
public void insertCatalogue(java.lang.String catalog)
catalog
- The catalog to add.public void removeCatalogue(java.lang.String catalog)
catalog
- The catalog to remove.insertCatalogue(java.lang.String)
public void setActiveCatalogue(java.lang.String catalog)
catalog
- The catalog to activate.public java.lang.String translateQt(java.lang.String context, java.lang.String sourceText, java.lang.String message)
public java.util.ArrayList allLanguagesTwoAlpha()
public java.lang.String twoAlphaToLanguageName(java.lang.String code)
code
- the language ISO 639-1 code
public java.util.ArrayList allCountriesTwoAlpha()
public java.lang.String twoAlphaToCountryName(java.lang.String code)
code
- the country code
public static void splitLocale(java.lang.String str, java.lang.StringBuffer language, java.lang.StringBuffer country, java.lang.StringBuffer charset)
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.public static void setMainCatalogue(java.lang.String catalog)
catalog
- Catalogue to override all other main catalogues.public static java.lang.String langLookup(java.lang.String fname, java.lang.String rtype)
fname
- relative path to findrtype
- resource type to usepublic static java.lang.String langLookup(java.lang.String fname)
public static java.lang.String defaultLanguage()
public static java.lang.String defaultCountry()
public static java.lang.String _initLanguage(KConfigBase config)
protected static void initInstance()
protected void finalize() throws java.lang.InternalError
finalize
in class java.lang.Object
java.lang.InternalError
public void dispose()
public boolean isDisposed()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |