Port kio_man away from kdelibs4support

Review Request #123131 - Created March 25, 2015 and updated

Information
Alex Richardson
kio-extras
5a8959b...
Reviewers
kdeframeworks, plasma
mkoller
Port kio_man away from kdelibs4support

man view in kdevelop5 works

Not sure about the KLocale::global()->languageList(); -> QLocale().uiLanguages(); change though so I would like some feedback.

Issues

  • 1
  • 0
  • 0
  • 1
Description From Last Updated
Not correct, this returns only user configured list of languages, whereas it previously returned the full list. Lukáš Tinkl Lukáš Tinkl
Luigi Toscano
Alex Richardson
Review request changed

People:

+mkoller
Lukáš Tinkl

   
man/kio_man.cpp (Diff revision 1)
 
 

Not correct, this returns only user configured list of languages, whereas it previously returned the full list.

  1. please see https://projects.kde.org/projects/kde/kdesdk/lokalize/repository/revisions/master/entry/src/common/languagelistmodel.cpp for the ways to get a list of all languages (there is a KDE-way and Qt-way)

  2. So if I parse this correctly the KDE way is: KConfig(QLatin1String("locale/kf5_all_languages"), KConfig::NoGlobals, QStandardPaths::GenericDataLocation).groupList()?
    Should there be something in KI18n or is this sufficiently rare that we can just add "@deprecated use KConfig(QLatin1String("locale/kf5_all_languages"), KConfig::NoGlobals, QStandardPaths::GenericDataLocation).groupList() instead" to KLocale::languageList()?

  3. Sounds to me like it should be a method in ki18n, it's a bit too arcane to be maintainable.

  4. Seems like it's not the right replacement:

    No special env vars set:

    KLocale::global()->languageList()  ("de", "en_US")
    KLocalizedString::availableApplicationTranslations() = ("pt_BR", "nds", "kk", "ga", "mr", "km", "ko", "en_US", "ca", "gl", "is", "it", "el", "nb", "tr", "ro", "pl", "es", "et", "en_GB", "eu", "ja", "ru", "nl", "cs", "nn", "pt", "ar", "ug", "hi", "lt", "da", "lv", "uk", "zh_CN", "zh_TW", "fi", "de", "sk", "hr", "sl", "hu", "bg", "fr", "ca@valencia", "sv")
    QLocale().uiLanguages() = ("de-DE")
    KConfig(kf5_all_languages).groupsList() = ("ca@valencia", "ln", "de", "tw", "lo", "ty", "lt", "lv", "ug", "uk", "pt_BR", "dz", "mg", "mh", "mi", "ur", "mk", "ml", "mn", "mo", "uz", "mr", "ms", "mt", "el", "en", "crh", "eo", "my", "be@latin", "es", "et", "eu", "vi", "na", "nb", "nd", "ne", "vo", "ng", "fa", "nl", "nn", "csb", "nr", "fi", "fj", "sr@ijekavian", "nv", "wa", "fo", "ny", "fr", "oc", "fy", "wo", "ga", "sr@latin", "hne", "om", "gd", "or", "os", "gl", "uz@cyrillic", "gn", "gu", "xh", "gv", "zh_HK", "pa", "nso", "pi", "ha", "pl", "he", "hi", "mai", "ps", "pt", "ho", "hr", "hu", "yi", "hy", "hz", "yo", "ia", "id", "ie", "aa", "ik", "ab", "qu", "ae", "za", "io", "af", "nds", "is", "ven", "it", "iu", "zh", "am", "ar", "as", "ja", "sr@ijekavianlatin", "x-test", "ay", "zu", "az", "rn", "ro", "en_US", "ba", "ru", "be", "rw", "bg", "bh", "bi", "jv", "bn", "sa", "bo", "sc", "sd", "br", "se", "bs", "sg", "si", "ka", "sk", "sl", "zh_CN", "sm", "ast", "sn", "so", "sq", "ki", "sr", "bn_IN", "ca", "ss", "kk", "st", "kl", "su", "km", "sv", "kn", "ce", "sw", "ko", "ch", "ks", "rom", "ku", "kv", "kw", "ta", "co", "ky", "zh_TW", "te", "cs", "tg", "cu", "th", "cv", "ti", "hsb", "la", "lb", "tk", "cy", "tn", "to", "en_GB", "li", "tr", "da", "ts", "tt", "dsb")
    

    With LANGUAGE="de_DE"

    KLocale::global()->languageList()  ("de", "en_US")
    KLocalizedString::availableApplicationTranslations() = ("sv", "pt_BR", "ca@valencia", "kk", "ga", "mr", "km", "ko", "en_US", "nds", "ca", "gl", "is", "it", "el", "nb", "tr", "ro", "en_GB", "pl", "es", "et", "eu", "ja", "ru", "nl", "cs", "nn", "pt", "ar", "ug", "hi", "lt", "da", "zh_CN", "zh_TW", "lv", "uk", "fi", "de", "sk", "hr", "sl", "hu", "bg", "fr")
    QLocale().uiLanguages() = ("de-DE")
    KConfig(kf5_all_languages).groupsList() = (...)
    

    With LANGUAGE="en_GB:de_DE"

    KLocale::global()->languageList()  ("en_GB", "de", "en_US")
    KLocalizedString::availableApplicationTranslations() = ("ga", "nds", "kk", "mr", "km", "ko", "ca", "gl", "pt_BR", "is", "it", "el", "nb", "tr", "ro", "en_US", "pl", "es", "et", "eu", "ja", "ru", "nl", "cs", "nn", "pt", "ar", "en_GB", "ug", "hi", "lt", "da", "lv", "uk", "fi", "de", "sk", "hr", "sl", "hu", "bg", "fr", "ca@valencia", "zh_CN", "zh_TW", "sv")
    QLocale().uiLanguages() = ("en-GB", "de-DE")
    

    With LANGUAGE="de_DE:en_GB"

    KLocale::global()->languageList()  ("en_GB", "de", "en_US")
    KLocalizedString::availableApplicationTranslations() = ("mr", "km", "ko", "nds", "en_GB", "ca", "gl", "is", "it", "el", "nb", "tr", "ro", "pl", "es", "et", "eu", "ja", "ru", "nl", "cs", "nn", "zh_CN", "zh_TW", "pt", "ar", "ca@valencia", "ug", "hi", "lt", "da", "lv", "uk", "fi", "de", "sk", "hr", "sl", "hu", "bg", "pt_BR", "fr", "sv", "en_US", "ga", "kk")
    QLocale().uiLanguages() = ("de-DE", "en-GB")
    KConfig(kf5_all_languages).groupsList() = (...)
    

    This one is very confusing, why is en_GB still the highest priority according to KLocale::global()->languageList()? Maybe it is reading some config file where I set that?

    With LANGUAGE="fr_FR"

    KLocale::global()->languageList()  ("de", "en_US")
    KLocalizedString::availableApplicationTranslations() = ("et", "eu", "ja", "ru", "nl", "cs", "nn", "pt", "en_GB", "ar", "ca@valencia", "ug", "hi", "lt", "da", "lv", "uk", "fi", "de", "sk", "hr", "sl", "zh_CN", "zh_TW", "hu", "bg", "fr", "sv", "nds", "ga", "kk", "mr", "km", "ko", "pt_BR", "ca", "gl", "en_US", "is", "it", "el", "nb", "tr", "ro", "pl", "es")
    QLocale().uiLanguages() = ("fr-FR")
    

    Even more confusion, LANGUAGE now has no effect on KLocale::global()->languageList()

    With LANG=fr_FR

    KLocale::global()->languageList()  ("fr", "en_US")
    KLocalizedString::availableApplicationTranslations() = ("sk", "hr", "sl", "hu", "bg", "pt_BR", "fr", "sv", "en_US", "kk", "ga", "km", "mr", "ko", "en_GB", "ca", "gl", "is", "it", "el", "nb", "tr", "ro", "pl", "es", "et", "eu", "ja", "ru", "nl", "cs", "nn", "zh_CN", "zh_TW", "pt", "ar", "ca@valencia", "nds", "ug", "hi", "lt", "da", "lv", "uk", "fi", "de")
    QLocale().uiLanguages() = ("fr-FR")
    

    LANG seems to work where LANGUAGE doesn't.

    I have no idea what's going on here, I need some feedback from someone with more I18N experience.

    However, QLocale().uiLanguages() seems to be almost the right replacement if we append en_US and convert it from de-DE to de_DE. However, the order is not the same...

  5. Given kf5_all_languages is part of kdelibs4support, making code in ki18n breaks tiering, so a -1 from my side to David's comment.

  6. Ah, then another implementation is needed. Proving even more that ki18n should provide a way to list available translations, since it's definitely not a trivial issue.

  7. ki18n already has such method (availableApplicationTranslations), i'm not sure that is what we want here though.
    
    Can someone clarify what we exactly want in here? all languages? all languages this ki18n-using application is translated too?
  8. What we want here in kio_man is to display the man page a user can read, which includes his preferred language(s) and the untranslated original man page, since this is the true reference.

    Therefore the code loops over the user selected languages and does not use all system installed translation dirs.

    I'd say QLocale().uiLanguages() is the way to go, including the "-" -> "_" replacement

David Faure

How about turning this logic around and just listing the directory (*it_dir)?

After all the current logic is to iterate over a list of languages, and see which ones do exist. Might as well just look at what exists, without starting from a possible list of languages?

Loading...