1
// -*- c-basic-offset: 2 -*-
2
/* This file is part of the KDE libraries
3
Copyright (C) 1997 Stephan Kulow <coolo@kde.org>
4
Copyright (C) 1999-2003 Hans Petter Bieker <bieker@kde.org>
5
Copyright (c) 2002 Lukas Tinkl <lukas@kde.org>
7
This library is free software; you can redistribute it and/or
8
modify it under the terms of the GNU Library General Public
9
License as published by the Free Software Foundation; either
10
version 2 of the License, or (at your option) any later version.
12
This library is distributed in the hope that it will be useful,
13
but WITHOUT ANY WARRANTY; without even the implied warranty of
14
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
Library General Public License for more details.
17
You should have received a copy of the GNU Library General Public License
18
along with this library; see the file COPYING.LIB. If not, write to
19
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20
Boston, MA 02110-1301, USA.
26
#include <kdelibs_export.h>
27
#include <klocalizedstring.h>
39
class KCalendarSystem;
48
* KLocale provides support for country specific stuff like
49
* the national language.
51
* KLocale supports translating, as well as specifying the format
52
* for numbers, currency, time, and date.
54
* @author Stephan Kulow <coolo@kde.org>, Preston Brown <pbrown@kde.org>,
55
* Hans Petter Bieker <bieker@kde.org>, Lukas Tinkl <lukas.tinkl@suse.cz>
56
* @short class for supporting locale settings and national language
58
class KDECORE_EXPORT KLocale
60
friend class KGlobal; // for initInstance()
63
* Constructs a KLocale with the given catalog name.
64
* The constructor looks for an entry Locale/Language in the
66
* If no config file is specified, it will also look for languages
67
* using the environment variables (KDE_LANG, LC_MESSAGES, LC_ALL, LANG),
68
* as well as the global configuration file. If KLocale is not able to use
69
* any of the specified languages, the default language (en_US) will be
72
* If you specify a configuration file, it has to be valid until
73
* the KLocale object is destroyed.
75
* @param catalog The name of the main language file
76
* @param config The configuration file to use.
78
explicit KLocale(const QString& catalog, KSharedConfig::Ptr config = KSharedConfig::Ptr());
83
KLocale( const KLocale & rhs );
86
* Assignment operator.
88
KLocale& operator= ( const KLocale & rhs );
96
* Raw translation from message catalogs.
98
* Never use this directly to get message translations. See i18n* and ki18n*
99
* calls related to KLocalizedString.
101
* @param msg the message. Must not be null. Must be UTF-8 encoded.
102
* @param lang language in which the translation was found. If no translation
103
* was found, KLocale::defaultLanguage() is reported. If null,
104
* the language is not reported.
105
* @param trans raw translation, or original if not found. If no translation
106
* was found, original message is reported. If null, the
107
* translation is not reported.
109
* @see KLocalizedString
111
void translateRaw(const char* msg,
112
QString *lang, QString *trans) const;
115
* Raw translation from message catalogs, with given context.
116
* Context + message are used as the lookup key in catalogs.
118
* Never use this directly to get message translations. See i18n* and ki18n*
119
* calls related to KLocalizedString.
121
* @param ctxt the context. Must not be null. Must be UTF-8 encoded.
122
* @param msg the message. Must not be null. Must be UTF-8 encoded.
123
* @param lang language in which the translation was found. If no translation
124
* was found, KLocale::defaultLanguage() is reported. If null,
125
* the language is not reported.
126
* @param trans raw translation, or original if not found. If no translation
127
* was found, original message is reported. If null, the
128
* translation is not reported.
130
* @see KLocalizedString
132
void translateRaw(const char *ctxt, const char *msg,
133
QString *lang, QString *trans) const;
136
* Raw translation from message catalogs, with given singular/plural form.
137
* Singular form is used as the lookup key in catalogs.
139
* Never use this directly to get message translations. See i18n* and ki18n*
140
* calls related to KLocalizedString.
142
* @param singular the singular form. Must not be null. Must be UTF-8 encoded.
143
* @param plural the plural form. Must not be null. Must be UTF-8 encoded.
144
* @param n number on which the forms are decided.
145
* @param lang language in which the translation was found. If no translation
146
* was found, KLocale::defaultLanguage() is reported. If null,
147
* the language is not reported.
148
* @param trans raw translation, or original if not found. If no translation
149
* was found, original message is reported (either plural or
150
* singular, as determined by @p n ). If null, the
151
* translation is not reported.
153
* @see KLocalizedString
155
void translateRaw(const char *singular, const char *plural, unsigned long n,
156
QString *lang, QString *trans) const;
159
* Raw translation from message catalogs, with given context and
160
* singular/plural form.
161
* Context + singular form is used as the lookup key in catalogs.
163
* Never use this directly to get message translations. See i18n* and ki18n*
164
* calls related to KLocalizedString.
166
* @param ctxt the context. Must not be null. Must be UTF-8 encoded.
167
* @param singular the singular form. Must not be null. Must be UTF-8 encoded.
168
* @param plural the plural form. Must not be null. Must be UTF-8 encoded.
169
* @param n number on which the forms are decided.
170
* @param lang language in which the translation was found. If no translation
171
* was found, KLocale::defaultLanguage() is reported. If null,
172
* the language is not reported.
173
* @param trans raw translation, or original if not found. If no translation
174
* was found, original message is reported (either plural or
175
* singular, as determined by @p n ). If null, the
176
* translation is not reported.
178
* @see KLocalizedString
180
void translateRaw(const char *ctxt, const char *singular, const char *plural,
181
unsigned long n, QString *lang, QString *trans) const;
184
* Changes the current encoding.
186
* @param mibEnum The mib of the preferred codec
188
* @return True on success.
190
bool setEncoding(int mibEnum);
193
* Changes the current language. The current language will be left
194
* unchanged if failed. It will force a reload of the country specific
195
* configuration as well.
197
* @param language The language code.
199
* @return True on success.
201
bool setLanguage(const QString & language);
204
* Changes the list of prefed languages for the locale. The first valid
205
* language in the list will be used, or the default (en_US) language
206
* will be used if non of the specified languages were available.
208
* @param languages The list of language codes.
210
* @return True if one of the specified languages were used.
212
bool setLanguage(const QStringList & languages);
215
* Changes the current country. The current country will be left
216
* unchanged if failed. It will force a reload of the country specific
219
* @param country The ISO 3166 country code.
221
* @return True on success.
223
bool setCountry(const QString & country);
226
* Various positions for where to place the positive or negative
227
* sign when they are related to a monetary value.
231
* Put parantheses around the quantity, e.g. "$ (217)"
235
* Prefix the quantity with the sign, e.g. "$ -217"
237
BeforeQuantityMoney = 1,
239
* Suffix the quanitity with the sign, e.g. "$ 217-"
241
AfterQuantityMoney = 2,
243
* Prefix the currency symbol with the sign, e.g. "-$ 217"
247
* Suffix the currency symbol with the sign, e.g. "$- 217"
253
* Returns what a decimal point should look like ("." or "," etc.)
254
* according to the current locale or user settings.
256
* @return The decimal symbol used by locale.
258
QString decimalSymbol() const;
261
* Returns what the thousands separator should look
262
* like ("," or "." etc.)
263
* according to the current locale or user settings.
265
* @return The thousands separator used by locale.
267
QString thousandsSeparator() const;
270
* Returns what the symbol denoting currency in the current locale
271
* as as defined by user settings should look like.
273
* @return The default currency symbol used by locale.
275
QString currencySymbol() const;
278
* Returns what a decimal point should look like ("." or "," etc.)
279
* for monetary values, according to the current locale or user
282
* @return The monetary decimal symbol used by locale.
284
QString monetaryDecimalSymbol() const;
287
* Returns what a thousands separator for monetary values should
288
* look like ("," or " " etc.) according to the current locale or
291
* @return The monetary thousands separator used by locale.
293
QString monetaryThousandsSeparator() const;
296
* Returns what a positive sign should look like ("+", " ", etc.)
297
* according to the current locale or user settings.
299
* @return The positive sign used by locale.
301
QString positiveSign() const;
304
* Returns what a negative sign should look like ("-", etc.)
305
* according to the current locale or user settings.
307
* @return The negative sign used by locale.
309
QString negativeSign() const;
312
* The number of fractional digits to include in numeric/monetary
313
* values (usually 2).
315
* @return Default number of fractional digits used by locale.
317
int fracDigits() const;
320
* If and only if the currency symbol precedes a positive value,
323
* @return Where to print the currency symbol for positive numbers.
325
bool positivePrefixCurrencySymbol() const;
328
* If and only if the currency symbol precedes a negative value,
331
* @return True if the currency symbol precedes negative numbers.
333
bool negativePrefixCurrencySymbol() const;
336
* Returns the position of a positive sign in relation to a
339
* @return Where/how to print the positive sign.
342
SignPosition positiveMonetarySignPosition() const;
345
* Denotes where to place a negative sign in relation to a
348
* @return Where/how to print the negative sign.
351
SignPosition negativeMonetarySignPosition() const;
354
* Given a double, converts that to a numeric string containing
355
* the localized monetary equivalent.
357
* e.g. given 123456, return "$ 123,456.00".
359
* @param num The number we want to format
360
* @param currency The currency symbol you want.
361
* @param digits Number of fractional digits, or -1 for the default
364
* @return The number of money as a localized string
367
QString formatMoney(double num,
368
const QString & currency = QString(),
369
int digits = -1) const;
372
* Given a double, converts that to a numeric string containing
373
* the localized numeric equivalent.
375
* e.g. given 123456.78F, return "123,456.78" (for some European country).
376
* If precision isn't specified, 2 is used.
378
* This function is a wrapper that is provided for convenience.
380
* @param num The number to convert
381
* @param precision Number of fractional digits used.
383
* @return The number as a localized string
384
* @see formatNumber(const QString, bool, int)
386
QString formatNumber(double num, int precision = -1) const;
389
* Given a string representing a number, converts that to a numeric
390
* string containing the localized numeric equivalent.
392
* e.g. given 123456.78F, return "123,456.78" (for some European country).
394
* @param numStr The number to format, as a string.
395
* @param round Round fractional digits. (default true)
396
* @param precision Number of fractional digits used for rounding. Unused if round=false. (default 2)
398
* @return The number as a localized string
400
QString formatNumber(const QString &numStr, bool round=true, int precision=2) const;
403
* Given an integer, converts that to a numeric string containing
404
* the localized numeric equivalent.
406
* e.g. given 123456L, return "123,456" (for some European country).
408
* @param num The number to convert
410
* @return The number as a localized string
412
QString formatLong(long num) const;
415
* Converts @p size from bytes to the string representation using the
416
* IEC 60027-2 standard
419
* formatByteSize(1024) returns "1.0 KiB"
421
* @param size size in bytes
422
* @return converted size as a string - e.g. 123.4 KiB , 12.0 MiB
424
QString formatByteSize( double size ) const;
427
* Given a number of milliseconds, converts that to a string containing
428
* the localized equivalent
430
* e.g. given formatDuration(60000), returns "1.0 minutes"
432
* @param mSec Time duration in milliseconds
433
* @return converted duration as a string - e.g. "5.5 seconds" "23.0 minutes"
435
QString formatDuration( unsigned long mSec) const;
437
* Use this to determine whether nouns are declined in
438
* locale's language. This property should remain
439
* read-only (no setter function)
441
* @return If nouns are declined
443
bool nounDeclension() const;
446
* Returns a string formatted to the current locale's conventions
449
* @param pDate The date to be formatted.
450
* @param shortFormat True for non text dates.
452
* @return The date as a string
454
QString formatDate(const QDate &pDate, bool shortFormat = false) const;
457
* Use this to determine whether in dates a possessive form of month
458
* name is preferred ("of January" rather than "January")
460
* @return If possessive form should be used
462
bool dateMonthNamePossessive() const;
465
* Returns a string formatted to the current locale's conventions
468
* @param pTime The time to be formatted.
469
* @param includeSecs if true, seconds are included in the output,
470
* otherwise only hours and minutes are formatted.
471
* @param isDuration if true, the given time is a duration, not a clock time.
472
* This means "am/pm" shouldn't be displayed.
474
* @return The time as a string
476
QString formatTime(const QTime &pTime, bool includeSecs = false,
477
bool isDuration = false) const;
480
* Use this to determine if the user wants a 12 hour clock.
482
* @return If the user wants 12h clock
484
bool use12Clock() const;
487
* Use this to determine which day is the first day of the week.
489
* @return an integer (Monday=1..Sunday=7)
491
int weekStartDay() const;
494
* Returns a pointer to the calendar system object.
496
* @return the current calendar system instance
498
const KCalendarSystem * calendar() const;
501
* Returns the name of the calendar system that is currently being
502
* used by the system.
504
* @return the name of the calendar system
506
QString calendarType() const;
509
* Changes the current calendar system to the calendar specified.
510
* Currently "gregorian" and "hijri" are supported. If the calendar
511
* system specified is not found, gregorian will be used.
513
* @param calendarType the name of the calendar type
515
void setCalendar(const QString & calendarType);
518
* Returns a string formatted to the current locale's conventions
519
* regarding both date and time.
521
* @param pDateTime the date and time to be formatted
522
* @param shortFormat using the short date format
523
* @param includeSecs include the seconds value
525
* @return The date and time as a string
527
QString formatDateTime(const QDateTime &pDateTime,
528
bool shortFormat = true,
529
bool includeSecs = false) const;
532
* Returns a string formatted to the current locale's conventions
533
* regarding both date and time.
535
* @param pDateTime the date and time to be formatted
536
* @param shortFormat using the short date format
537
* @param includeSecs include the seconds value
538
* @param includeTimeZone include a time zone string
540
* @return The date and time as a string
542
QString formatDateTime(const KDateTime &pDateTime,
543
bool shortFormat = true,
544
bool includeSecs = false,
545
bool includeTimeZone = false) const;
548
* Converts a localized monetary string to a double.
550
* @param numStr the string we want to convert.
551
* @param ok the boolean that is set to false if it's not a number.
552
* If @p ok is 0, it will be ignored
554
* @return The string converted to a double
556
double readMoney(const QString &numStr, bool * ok = 0) const;
559
* Converts a localized numeric string to a double.
561
* @param numStr the string we want to convert.
562
* @param ok the boolean that is set to false if it's not a number.
563
* If @p ok is 0, it will be ignored
565
* @return The string converted to a double
567
double readNumber(const QString &numStr, bool * ok = 0) const;
570
* Converts a localized date string to a QDate.
571
* The bool pointed by ok will be invalid if the date entered was not valid.
573
* @param str the string we want to convert.
574
* @param ok the boolean that is set to false if it's not a valid date.
575
* If @p ok is 0, it will be ignored
577
* @return The string converted to a QDate
579
QDate readDate(const QString &str, bool* ok = 0) const;
582
* Converts a localized date string to a QDate, using the specified format.
583
* You will usually not want to use this method.
585
QDate readDate( const QString &intstr, const QString &fmt, bool* ok = 0) const;
588
* Flags for readDate()
591
NormalFormat = 1, ///< Only accept a date string in normal (long) format
592
ShortFormat = 2 ///< Only accept a date string in short format
596
* Converts a localized date string to a QDate.
597
* This method is stricter than readDate(str,&ok): it will either accept
598
* a date in full format or a date in short format, depending on @p flags.
600
* @param str the string we want to convert.
601
* @param flags whether the date string is to be in full format or in short format.
602
* @param ok the boolean that is set to false if it's not a valid date.
603
* If @p ok is 0, it will be ignored
605
* @return The string converted to a QDate
607
QDate readDate(const QString &str, ReadDateFlags flags, bool *ok = 0) const;
610
* Converts a localized time string to a QTime.
611
* This method will try to parse it with seconds, then without seconds.
612
* The bool pointed to by @p ok will be set to false if the time entered was
615
* @param str the string we want to convert.
616
* @param ok the boolean that is set to false if it's not a valid time.
617
* If @p ok is 0, it will be ignored
619
* @return The string converted to a QTime
621
QTime readTime(const QString &str, bool* ok = 0) const;
624
* Flags for readTime()
627
WithSeconds = 0, ///< Only accept a time string with seconds. Default (no flag set)
628
WithoutSeconds = 1 ///< Only accept a time string without seconds.
629
}; // (maybe use this enum as a bitfield, if adding independent features?)
631
* Converts a localized time string to a QTime.
632
* This method is stricter than readTime(str,&ok): it will either accept
633
* a time with seconds or a time without seconds.
634
* Use this method when the format is known by the application.
636
* @param str the string we want to convert.
637
* @param flags whether the time string is expected to contain seconds or not.
638
* @param ok the boolean that is set to false if it's not a valid time.
639
* If @p ok is 0, it will be ignored
641
* @return The string converted to a QTime
643
QTime readTime(const QString &str, ReadTimeFlags flags, bool *ok = 0) const;
646
* Returns the language used by this object. The domain AND the
647
* library translation must be available in this language.
648
* defaultLanguage() is returned by default, if no other available.
650
* @return The currently used language.
652
QString language() const;
655
* Returns the country code of the country where the user lives.
656
* defaultCountry() is returned by default, if no other available.
658
* @return The country code for the user.
660
QString country() const;
663
* Returns the preferred languages as ISO 639-1 codes. This means
664
* that information about country is removed. If the internal language
665
* code might be represented by more than one 639-1 code, they will all be
666
* listed (but only once).
668
* If the selected languages are "nn, nb, pt_BR", you will get:
671
* @return List of language codes
675
QStringList languagesTwoAlpha() const;
678
* Returns the languages selected by user. The codes returned here is the
679
* internal language codes.
681
* @return List of language codes
683
* @see languagesTwoAlpha
685
QStringList languageList() const;
688
* Returns the user's preferred encoding.
690
* @return The name of the preferred encoding
692
* @see codecForEncoding
695
const QByteArray encoding() const;
698
* Returns the user's preferred encoding.
700
* @return The Mib of the preferred encoding
703
* @see codecForEncoding
705
int encodingMib() const;
707
* Returns the user's preferred encoding. Should never be NULL.
709
* @return The codec for the preferred encoding
714
QTextCodec * codecForEncoding() const;
717
* Returns the file encoding.
719
* @return The Mib of the file encoding
721
* @see QFile::encodeName
722
* @see QFile::decodeName
724
int fileEncodingMib() const;
727
* Changes the current date format.
729
* The format of the date is a string which contains variables that will
731
* @li %Y with the century (e.g. "19" for "1984")
732
* @li %y with the lower 2 digits of the year (e.g. "84" for "1984")
733
* @li %n with the month (January="1", December="12")
734
* @li %m with the month with two digits (January="01", December="12")
735
* @li %e with the day of the month (e.g. "1" on the first of march)
736
* @li %d with the day of the month with two digits(e.g. "01" on the first of march)
737
* @li %b with the short form of the month (e.g. "Jan" for January)
738
* @li %B with the long form of the month (e.g. "January")
739
* @li %a with the short form of the weekday (e.g. "Wed" for Wednesday)
740
* @li %A with the long form of the weekday (e.g. "Wednesday" for Wednesday)
742
* Everything else in the format string will be taken as is.
743
* For example, March 20th 1989 with the format "%y:%m:%d" results
746
* @param format The new date format
748
void setDateFormat(const QString & format);
750
* Changes the current short date format.
752
* The format of the date is a string which contains variables that will
754
* @li %Y with the century (e.g. "19" for "1984")
755
* @li %y with the lower 2 digits of the year (e.g. "84" for "1984")
756
* @li %n with the month (January="1", December="12")
757
* @li %m with the month with two digits (January="01", December="12")
758
* @li %e with the day of the month (e.g. "1" on the first of march)
759
* @li %d with the day of the month with two digits(e.g. "01" on the first of march)
760
* @li %b with the short form of the month (e.g. "Jan" for January)
761
* @li %B with the long form of the month (e.g. "January")
762
* @li %a with the short form of the weekday (e.g. "Wed" for Wednesday)
763
* @li %A with the long form of the weekday (e.g. "Wednesday" for Wednesday)
765
* Everything else in the format string will be taken as is.
766
* For example, March 20th 1989 with the format "%y:%m:%d" results
769
* @param format The new short date format
771
void setDateFormatShort(const QString & format);
773
* Changes the form of month name used in dates.
775
* @param possessive True if possessive forms should be used
777
void setDateMonthNamePossessive(bool possessive);
779
* Changes the current time format.
781
* The format of the time is string a which contains variables that will
783
* @li %H with the hour in 24h format and 2 digits (e.g. 5pm is "17", 5am is "05")
784
* @li %k with the hour in 24h format and one digits (e.g. 5pm is "17", 5am is "5")
785
* @li %I with the hour in 12h format and 2 digits (e.g. 5pm is "05", 5am is "05")
786
* @li %l with the hour in 12h format and one digits (e.g. 5pm is "5", 5am is "5")
787
* @li %M with the minute with 2 digits (e.g. the minute of 07:02:09 is "02")
788
* @li %S with the seconds with 2 digits (e.g. the minute of 07:02:09 is "09")
789
* @li %p with pm or am (e.g. 17.00 is "pm", 05.00 is "am")
791
* Everything else in the format string will be taken as is.
792
* For example, 5.23pm with the format "%H:%M" results
795
* @param format The new time format
797
void setTimeFormat(const QString & format);
801
* Changes how KLocale defines the first day in week.
803
* @param day first day of the week (Monday=1..Sunday=7) as integer
805
void setWeekStartDay(int day);
807
* Returns the currently selected date format.
809
* @return Current date format.
810
* @see setDateFormat()
812
QString dateFormat() const;
814
* Returns the currently selected short date format.
816
* @return Current short date format.
817
* @see setDateFormatShort()
819
QString dateFormatShort() const;
821
* Returns the currently selected time format.
823
* @return Current time format.
824
* @see setTimeFormat()
826
QString timeFormat() const;
829
* Changes the symbol used to identify the decimal pointer.
831
* @param symbol The new decimal symbol.
833
void setDecimalSymbol(const QString & symbol);
835
* Changes the separator used to group digits when formating numbers.
837
* @param separator The new thousands separator.
839
void setThousandsSeparator(const QString & separator);
841
* Changes the sign used to identify a positive number. Normally this is
844
* @param sign Sign used for positive numbers.
846
void setPositiveSign(const QString & sign);
848
* Changes the sign used to identify a negative number.
850
* @param sign Sign used for negative numbers.
852
void setNegativeSign(const QString & sign);
854
* Changes the sign position used for positive monetary values.
856
* @param signpos The new sign position
858
void setPositiveMonetarySignPosition(SignPosition signpos);
860
* Changes the sign position used for negative monetary values.
862
* @param signpos The new sign position
864
void setNegativeMonetarySignPosition(SignPosition signpos);
866
* Changes the position where the currency symbol should be printed for
867
* positive monetary values.
869
* @param prefix True if the currency symbol should be prefixed instead of
872
void setPositivePrefixCurrencySymbol(bool prefix);
874
* Changes the position where the currency symbol should be printed for
875
* negative monetary values.
877
* @param prefix True if the currency symbol should be prefixed instead of
880
void setNegativePrefixCurrencySymbol(bool prefix);
882
* Changes the number of digits used when formating numbers.
884
* @param digits The default number of digits to use.
886
void setFracDigits(int digits);
888
* Changes the separator used to group digits when formating monetary values.
890
* @param separator The new thousands separator.
892
void setMonetaryThousandsSeparator(const QString & separator);
894
* Changes the symbol used to identify the decimal pointer for monetary
897
* @param symbol The new decimal symbol.
899
void setMonetaryDecimalSymbol(const QString & symbol);
901
* Changes the current currency symbol.
903
* @param symbol The new currency symbol
905
void setCurrencySymbol(const QString & symbol);
908
* Returns the preferred page size for printing.
910
* @return The preferred page size, cast it to QPrinter::PageSize
912
int pageSize() const;
915
* Changes the preferred page size when printing.
917
* @param paperFormat the new preferred page size in the format QPrinter::PageSize
919
void setPageSize(int paperFormat);
922
* The Metric system will give you information in mm, while the
923
* Imperial system will give you information in inches.
926
Metric, ///< Metric system (used e.g. in Europe)
927
Imperial ///< Imperial system (used e.g. in the United States)
931
* Returns which measuring system we use.
933
* @return The preferred measuring system
935
MeasureSystem measureSystem() const;
938
* Changes the preferred measuring system.
940
* @return value The preferred measuring system
942
void setMeasureSystem(MeasureSystem value);
945
* Adds another catalog to search for translation lookup.
946
* This function is useful for extern libraries and/or code,
947
* that provide there own messages.
949
* If the catalog does not exist for the chosen language,
950
* it will be ignored and en_US will be used.
952
* @param catalog The catalog to add.
954
void insertCatalog(const QString& catalog);
957
* Removes a catalog for translation lookup.
958
* @param catalog The catalog to remove.
959
* @see insertCatalog()
961
void removeCatalog(const QString &catalog);
964
* Sets the active catalog for translation lookup.
965
* @param catalog The catalog to activate.
967
void setActiveCatalog(const QString &catalog);
970
* Translates a message as a QTranslator is supposed to.
971
* The parameters are similar to i18n(), but the result
972
* value has other semantics (it can be QString())
974
QString translateQt(const char *context,
975
const char *sourceText,
976
const char *message) const;
979
* Returns list of all known ISO 639-1 codes.
980
* @return a list of all language codes
982
QStringList allLanguagesTwoAlpha() const;
985
* Convert a ISO 639-1 code to a human readable form.
986
* @param code the language ISO 639-1 code
987
* @return the human readable form
989
QString twoAlphaToLanguageName(const QString &code) const;
992
* Returns list of all known country codes.
993
* @return a list of all country codes
995
QStringList allCountriesTwoAlpha() const;
998
* Convert a country code to a human readable form.
999
* @param code the country code
1000
* @return the human readable form of the country name
1002
QString twoAlphaToCountryName(const QString &code) const;
1005
* Returns the parts of the parameter str understood as language setting
1006
* the format is language_COUNTRY.charset
1008
* @param str The string to split.
1009
* @param language This will be set to the language part of the string.
1010
* @param country This will be set to the country part of the string.
1011
* @param charset This will be set to the charset part of the string.
1013
static void splitLocale(const QString & str,
1019
* Use this as main catalog for *all* KLocales, if not the appname
1020
* will be used. This function is best to be the very first instruction
1021
* in your program's main function as it only has an effect before the
1022
* first KLocale object is created.
1024
* @param catalog Catalog to override all other main Catalogs.
1026
static void setMainCatalog(const char *catalog);
1029
* Finds localized resource in resourceDir( rtype ) + \<lang> + fname.
1031
* @param fname relative path to find
1032
* @param rtype resource type to use
1034
static QString langLookup(const QString &fname, const char *rtype = "html");
1037
* Returns the name of the internal language.
1039
* @return Name of the default language
1041
static QString defaultLanguage();
1044
* Returns the name of the default country.
1046
* @return Name of the default country
1048
static QString defaultCountry();
1052
* @internal Called from KConfigBackend to initialize language.
1054
static QString _initLanguage(KConfigBase *config);
1059
* @internal Creates a KLocale object for KGlobal and inits the locale
1062
static void initInstance();
1065
KLocalePrivate * const d;