Commit graph

52 commits

Author SHA1 Message Date
Ivailo Monev
1c22bf126b kdecore: round duration to seconds in KLocale::formatDuration()
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2024-05-02 22:02:07 +03:00
Ivailo Monev
2372a3991f kdecore: KLocale optimization
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2024-03-16 19:41:34 +02:00
Ivailo Monev
982afdb961 kdecore: use static string for the default language
QString::fromLatin1() goes trough converter every time

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2024-03-14 01:39:17 +02:00
Ivailo Monev
d923fd1ee8 kdecore: minor KLocale optimizations
QLocale::name() concats strings while QLocale::language() returns the value
of internal private member thus there will be less memory allocations

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2024-03-14 00:18:45 +02:00
Ivailo Monev
6dbd6b5a8e kdecore: update note in KLocale::formatNumber()
kcalc is no more, the plasma applet (which i rewrote too) is there for such
things. for complex operations there is the plasma (krunner) plugin

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2024-03-14 00:05:17 +02:00
Ivailo Monev
d254c051ed kdecore: do not insert the solid_qt catalog by default
that means to get the translations linking to solid library or calling
KGlobal::locale()->insertCatalog("solid_qt") is required

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-09-03 02:20:43 +03:00
Ivailo Monev
5fb7d39eb2 kdecore: disable KLOCALE_DUMP_UNTRANSLATED by default
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-08-08 23:42:52 +03:00
Ivailo Monev
4472e87d19 kdecore: add compile-time definition to dump catalogs when translations is not found
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-08-08 23:41:24 +03:00
Ivailo Monev
4d3d7840f2 kdecore: call KLocalizedString::notifyCatalogsUpdated() only when the catalogs were actually updated
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-08-07 02:15:02 +03:00
Ivailo Monev
65587af47d kdecore: probe all languages from KLocale::languageCodeToName() and KLocale::countryCodeToName()
for that to work what KConfig expects (the language only) has to be first
in the list, otherwise KConfig returns entries that are actually not in the
set locale (go figure)

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-08-06 18:55:59 +03:00
Ivailo Monev
8bea5c9837 kdecore: set the config locale to the highest priority language from KLocale::languageCodeToName() and KLocale::countryCodeToName()
as noted in de7070d2bb having multiple
languages and matching the correct one for each use case will have to be
tuned

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-08-02 07:11:08 +03:00
Ivailo Monev
5e51868194 kdecore: const-ify variables in KLocale::translateRaw() methods
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-08-01 05:18:47 +00:00
Ivailo Monev
886187c647 kdecore: remove unused kdatetime header inclusion
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-08-01 03:55:47 +00:00
Ivailo Monev
ecc721b59c kdecore: change locale language from KLocale::reparseConfiguration() of default KLocale objects
default as in no explicit language has been passed as argument to KLocale
and the language comes either from config or the environemnt variables

with this change KCalendarWidget properly adapts to KLocale config change,
however other applications and widgets may not which is something that has
to be looked into. note that logout is (and was before the KLocale rewrite
even) recommended by the locale KCM for the change to fully take effect

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-29 08:08:13 +03:00
Ivailo Monev
f04d336bc0 kdecore: more compat bits for KLocale::formatNumber()
one more hack comming right up..

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-28 15:38:13 +03:00
Ivailo Monev
8d3cf0ad3d kdecore: compat bits for KLocale::formatNumber()
the test case for this is in a KSignalPlotter test, see:
kde-workspace/libs/ksysguard/tests/signalplottertest.cpp

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-28 14:38:05 +03:00
Ivailo Monev
c4a5205981 kdecore: correct milisecond(s) spelling
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-28 13:20:53 +03:00
Ivailo Monev
d47978309e kdecore: replace the "ok" argument of KLocale::readDate() and KLocale::readTime() with "format" one
beware that bad things will happen if the input strings are not in one of
the formats KLocale::formatDate() and KLocale::formatTime() output

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2023-07-28 12:54:53 +03:00
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
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
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
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
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
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
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
a9ef1523ff kdecore: remove old QTranslator virtual method overload
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2022-06-06 01:24:47 +03:00
Ivailo Monev
eca1a8fcb0 kdecore: remove transcript support leftovers
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2021-06-26 12:58:44 +03:00
Ivailo Monev
74bcfd8a4d kdecore: remove non-const KLocale::weekNumberSystem() getter
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2021-06-16 14:34:48 +03:00
Ivailo Monev
50dd0cd82c kdecore: merge KLocaleUnixPrivate into KLocalePrivate
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2021-03-26 13:58:44 +02:00
Ivailo Monev
055f2e8331 kdecore: make use of thread_local
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2016-10-24 06:24:11 +00:00
Ivailo Monev
d4f3cb5ef4 kdecore: drop internal file encoding functions
these seems unnecessary because QString::fromLocal8Bit() is used
if the function is not overriden, though some sorta UTF-16 support
is suggested in the internal functions I have no trouble creating
files with UTF-16 characters in theirs names and working with
them. if there are any complaints on this it shall be reverted

Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2015-11-08 17:35:08 +02:00
Ivailo Monev
5333af40b5 kdecore: remove unused setFracDigits() from klocale
Signed-off-by: Ivailo Monev <xakepa10@gmail.com>
2015-10-28 10:26:03 +02:00
Ivailo Monev
9457544b8b kdecore: misc cleanups 2015-10-12 18:43:14 +03:00
Ivailo Monev
c7a2a17692 yet more windows and mac code remove 2014-11-19 15:30:39 +00:00