Save up a bunch of stat() calls on application start
ClosedPublic

Authored by apol on Aug 10 2017, 1:17 PM.

Details

Summary

We are checking if every language known to us is present just to make
sure that we have more than one and show the dialog entry.
Always showing it is not a big deal and we'd save up this penalty at
start.

Diff Detail

Repository
R263 KXmlGui
Lint
Automatic diff as part of commit; lint not applicable.
Unit
Automatic diff as part of commit; unit tests not applicable.
apol created this revision.Aug 10 2017, 1:17 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptAug 10 2017, 1:17 PM

Another idea would be to check it in aboutToShow of the menu?

+1
We bundle translations in tarballs almost everywhere now, so it's safe to assume that we have > 1 translations around.

dfaure added a subscriber: dfaure.Aug 10 2017, 6:39 PM

That's one solution. The other is to add bool KLocalizedString::hasApplicationTranslations() which stops at the first translation found.

Does the argument about shipping translations in tarballs apply to kmail, dolphin, etc. or just to KF5 and extragear? For apps, I thought only releaseme did that, is that used by the "Applications" product?

Just wondering, I don't care much either way.

That's one solution. The other is to add bool KLocalizedString::hasApplicationTranslations() which stops at the first translation found.

Does the argument about shipping translations in tarballs apply to kmail, dolphin, etc. or just to KF5 and extragear? For apps, I thought only releaseme did that, is that used by the "Applications" product?

Yep, since Applications 17.04

dfaure accepted this revision.Aug 10 2017, 10:01 PM

Ah, OK then.

This revision is now accepted and ready to land.Aug 10 2017, 10:01 PM
aacid added a subscriber: aacid.Aug 10 2017, 10:12 PM

That's one solution. The other is to add bool KLocalizedString::hasApplicationTranslations() which stops at the first translation found.

Does the argument about shipping translations in tarballs apply to kmail, dolphin, etc. or just to KF5 and extragear? For apps, I thought only releaseme did that, is that used by the "Applications" product?

Yep, since Applications 17.04

No, we do not use releaseme
Yes, we do ship translations inside tarballs.

I would still ask distributions: some of them may strip the translations in some cases.

Thanks for adding me, at least Gentoo indeed supports stripping translations even after they were moved into the packages - so that would break.

A minor "breakage" though, just a menu item that brings a selection of 0 or 1 language, i.e. showing the user that no translation is available. Arguably that's actually better user interface than a missing menu item (A: "click on that menu item!" -- B: "where? you're dreaming, there's no such menu item!")

asturmlechner accepted this revision.Aug 15 2017, 4:08 PM

Briefly runtime tested it as well with and without translations, no issues.

This revision was automatically updated to reflect the committed changes.