https://bugs.kde.org/show_bug.cgi?id=407179

--- Comment #8 from Harald Sitter <sit...@kde.org> ---
Yeah, I think this issue is actually a bit ballooned up in scope by design
mistakes I've made. You are on the right track though.

Upon further inspection I don't think a constructor will do. We not only need
the KLocalizedString to be evaluated "later" but also the KFormat substitution.
That complicates things beyond what we can achieve by passing the KLS around.
Instead we'll need a virtual function here:

Entry's member `value` needs to become a private m_value for starters.
To replace it we'll need a `virtual QString value(Language language =
Language::System)` which by default simply returns the string member. This
function can then be selectively overridden in Entries that need to localize
the value. Functionally this would behave like localizedLabel.

Now that we can override value() in MemoryEntry things are a bit simpler.
In the MemoryEntry's value() override we'll want to recycle the logic current
in text() and massage the code a bit. We'll need

a) to deal with KLocalizedStrings instead of QString
b) get a QLocale for KFormat
c) need a more generic `QString localize(const KLocalizedString &string,
Language language) const` function to help us deal with localizing our strings

a) is kinda simple, albeit not well documented. i18n*() calls become ki18n*()
calls. Additionally if they have substitutions those need to be calls on the
KLS.

e.g. in our specific case i18nc(..., KFormat()) becomes
ki18nc(...).subs(KFormat()). Where ki18nc() gives us the KLS and with subs() we
replace the %N marker.

b) should simply be a switch over Language mapping to QLocale::system() or
QLocale(Enlish, US). It'd probably be a good idea to pack that in a helper
function `QLocale localeForLanguage(Language language) const` for ease of
reading

c) could be easily built out of refactoring localizedLabel. it'd simply need to
switch over language and call the right .toString() on the KLS

With that in place you should be able to achieve englishification.

-- 
You are receiving this mail because:
You are watching all bug changes.

Reply via email to