Commit graph

193 commits

Author SHA1 Message Date
Ivailo Monev
de7070d2bb kdecore: return only the language part from KLocale::language()
e.g. "bg" for "bg_BG", the default locale is special case for that method
too because of expectations in other places (such as KConfig, KMimeType
tries to match all of the languages returned by KLocale::languageList()
which is how it should be done but that is for another commit)

that is essentially the last bit to bring it back to a compatible state
with the previous implementation, except now more locales are supported

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-28 12:28:08 +03:00
Ivailo Monev
476f006aab kdecore: do not insert duplicate catalogs into KLocale
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-28 11:57:30 +03:00
Ivailo Monev
c44da5428f kdecore: do not insert and remove catalogs from KPluginFactory
already done by KComponentDataPrivate, when the component is created and
deleted

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-28 10:04:36 +03:00
Ivailo Monev
95ccbcb31b kdecore: do not insert invalid catalogs into KLocale
to optimize translation lookup, also re-purposed
KCatalog::catalogLocaleDir() for that

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-28 10:02:57 +03:00
Ivailo Monev
b1ffffeb89 kdecore: preserve manually inserted catalogs on KLocale configuration reparse
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-28 06:21:00 +03:00
Ivailo Monev
eedfed825a kdecore: format and indent
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-28 05:40:10 +03:00
Ivailo Monev
3e1e82534a kdecore: reduce branches in KLocale::translateRaw()
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-28 05:13:08 +03:00
Ivailo Monev
5143a5895e kdecore: update KLocale documentation
QLocale checks for LC_CTYPE, KLocale may check for LC_MESSAGES in the
future

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-28 05:10:06 +03:00
Ivailo Monev
69a479047f kdecore: KLocale::translateRaw() and KLocale::translateQt() optimizations
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-28 05:00:47 +03:00
Ivailo Monev
5e95db910f kdecore: magic bits for numbers formatting
people really messed up the precisions, look at what kcalc does with the
constants:
kde-extraapps/kcalc/kcalcdisplay.cpp

zero precision is essentially rounding the constants! also setlocale() no
longer has effect on Katie and thus Katana so updated the method to
override locale in KLocalizedString test while at it (tests pass after one
adjustment for the french locale case)

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-28 04:59:57 +03:00
Ivailo Monev
e5b48177a6 kdecore: add missing QMutableListIterator template argument in KLocale::removeCatalog()
how did that compile again?

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-27 23:07:44 +03:00
Ivailo Monev
762f01a33a kdecore: use std::array<T,T> for the date and time formats in KLocale
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-27 23:05:25 +03:00
Ivailo Monev
5a1aa5568e kdecore: fix KLocale thread-safety issues
it was locked before too but the mutex was recursive, now it is not

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-27 22:05:29 +03:00
Ivailo Monev
ed04fb1b13 kdecore: set the locale of the configuration files from KLocale::languageCodeToName() and KLocale::countryCodeToName()
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-27 21:41:34 +03:00
Ivailo Monev
12f3ffd120 kdecore: remove redundant KLocale::translateRaw() methods
context can be null now

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-27 21:21:57 +03:00
Ivailo Monev
20e92c8398 kdecore: remove duplicates from the result of KLocale::allLanguagesList()
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-27 07:48:02 +03:00
Ivailo Monev
e413cbc41f kdecore: reimplement KLocale::formatDuration()
much like the old (and now gone) KLocale::prettyFormatDuration() except
with miliseconds precision instead of days

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-27 07:12:53 +03:00
Ivailo Monev
938d0dd7e0 generic: remove KCalendarSystem leftovers
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-27 03:01:17 +03:00
Ivailo Monev
fc4c832b3d kdecore: KLocale::translateRaw() methods optimization
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-27 00:07:52 +03:00
Ivailo Monev
1a45508306 kdecore: reimplement KLocale
by using QLocale in KLocale and separating the date, time and numbers
conversion from translation KLocale actually gets extended locale
support from QLocale (which uses CLDR data v43 currently). translation
remains unaffected. for comparison here is the result of two function
calls the result of which should explain the whole change:
KLocale::allLanguagesList().size() = 669
KLocale::installedLanguages().size() = 68

the first number is locales Katie supports, the second being the
number of languages Katana is translated into

KSwitchLanguageDialog needs a rewrite but that is on the TODO

also copyrighting KCatalog to me because I rewrote it, for reference:
881b47b8ea

KCalendarSystem gets the middle finger - batteries not included for date
and time. extra calendar systems can, but are unlikely to be, supported
in the future

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-26 23:50:18 +03:00
Ivailo Monev
0fa46d60db kdecore: remove declaration of non-existing KLocale::setEncoding() method
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-24 21:44:30 +03:00
Ivailo Monev
de31c50479 kdecore: drop support for all but gregorian and julian calendars
additional calendar systems can be supported via ICU in the future but
for now that will be more than enough considering other things such as
QDateTime and QCalendarWidget, the gregorian and julian calendars being
common, etc.

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-23 22:58:43 +03:00
Ivailo Monev
2cf411e2ed kdecore: remove unused and deprecated KLocale/KCalendarSystem setters and getters
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-23 08:04:44 +03:00
Ivailo Monev
714b6f2021 kdecore: remove unused KLocalizedDate class
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-23 06:54:53 +03:00
Ivailo Monev
f452e2e50b kdecore: reimplement KDateTime via QDateTime
KDateTime shall be used only for storing date and time while KLocale
shall be used to display such, not even going to test what KDateTime
does because it is basically a few methods on top of QDateTime now.

and because QDateTime knows not much about calendar systems while
KLocale supports several it makes sense for KDateTime to not be used for
displaying date and time thus the TODOs for KLocale are simply removed

note that KLocale still uses its own parser and formatter which means
that the change affects only KDateTime and its uses, not KLocale

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-21 07:51:13 +03:00
Ivailo Monev
89177c0614 kdecore: KCharsets optimizations
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2022-12-11 09:49:04 +02:00
Ivailo Monev
9b41127ecb generic: prepare for Katie changes
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2022-11-13 00:40:18 +02:00
Ivailo Monev
74cbd4de8d kdecore: do not attempt to load empty data into QTranslator
fixes runtime warning about empty data for invalid catalogs (e.g. when
translations are not installed either for the language requested or at all)

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2022-11-04 04:21:39 +02:00
Ivailo Monev
1af12047e6 kdecore: remove unused KLocalizedString semantics
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2022-11-03 01:06:07 +02:00
Ivailo Monev
8d9978f7e5 kdecore: remove unused KLocalizedString semantics
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2022-11-03 00:47:26 +02:00
Ivailo Monev
169e338449 kdecore: convert KuitFormats functions to static
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2022-11-03 02:37:11 +02:00
Ivailo Monev
b8b37e01a3 kdecore: actually install the KDETranslator
was non-operational code due to QT_NO_TRANSLATION being defined in the
kglobal source file for some reason, it has a huge impact on performance
ofcourse because anything Katie will attempt to translate will go trough it

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2022-11-02 11:02:51 +02:00
Ivailo Monev
95ee157d51 kdecore: undeprecate raw string translation methods
the catalog name argument is unused, KCatalog should be public if
translation from specific catalog is required

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2022-11-02 08:48:28 +02:00
Ivailo Monev
4afeec1725 kdecore: do not copy the catalogs list in KLocalePrivate::translateRawFrom()
the global KLocale mutex is locked in that method

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2022-11-02 07:08:04 +02:00
Ivailo Monev
881b47b8ea kdecore: use the Katie translations format
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2022-11-02 05:42:59 +02:00
Ivailo Monev
9cac859359 kdecore: const-ify iterator in KCharsets::encodingsByScript()
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2022-10-27 11:24:11 +03:00
Ivailo Monev
3e4db45b42 kdecore: crash fix for the case when QT_FOREACH_COMPAT is not defined
QT_FOREACH_COMPAT is eventually going away, it is huge performance penalty

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2022-10-27 11:08:34 +03:00
Ivailo Monev
d9ccab2651 generic: remove reference to default debug area
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2022-10-23 00:10:46 +03:00
Ivailo Monev
860b2d098d kdecore: new KCompressor and KDecompressor classes replacing KFilterDev
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2022-10-17 18:07:24 +03:00
Ivailo Monev
ae5646a52f kdecore: deduplicate code in KLocalePrivate
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2022-10-08 15:00:53 +03:00
Ivailo Monev
718ccc145f kdecore: remove redundant KEncodingDetector class
use QTextCodec::codecForUtfText() or QTextCodec::codecForText() instead

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2022-09-30 20:47:46 +03:00
Ivailo Monev
894a2d52bb kdecore: remove KLocale getters related to text codec
see the comment in KLocalePrivate::initEncoding()

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2022-09-30 20:00:04 +03:00
Ivailo Monev
3be89ba858 kdecore: de-virtualize KLocale destructor
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2022-09-25 07:08:15 +03:00
Ivailo Monev
ba64dcca64 kdecore: remove unused and deprecated KLocale::langLookup() method
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2022-09-24 15:08:33 +03:00
Ivailo Monev
fbd4a17ac2 kdecore: drop currency and monetary support
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2022-09-24 14:43:11 +03:00
Ivailo Monev
202578f350 kdecore: bring back KCurrencyCode::symbolList() method since it is used
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2022-09-24 12:33:11 +03:00
Ivailo Monev
7e935b22d7 kdecore: remove unused KCurrencyCode methods
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2022-09-24 11:49:53 +03:00
Ivailo Monev
b1a1bf07cf kdecore: remove unused KCurrencyCode constructor
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2022-09-24 11:37:56 +03:00
Ivailo Monev
5bd8b63293 kdecore: remove unused KCurrencyCode methods
some of the data in kde-workspace/localization/currency/*.desktop is empty
for these entries too

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2022-09-24 11:26:10 +03:00
Ivailo Monev
4af560eb08 kdecore: de-virtualize KCharsets destructor
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2022-09-23 18:20:44 +03:00