Bug 351015

Summary: Switch Application Language - Partial list of languages
Product: [Frameworks and Libraries] frameworks-kxmlgui Reporter: Stephane MANKOWSKI <stephane>
Component: generalAssignee: kdelibs bugs <kdelibs-bugs-null>
Status: RESOLVED WORKSFORME    
Severity: major CC: aspotashev, bugseforuns, caslav.ilic, kdelibs-bugs-null
Priority: NOR    
Version First Reported In: unspecified   
Target Milestone: ---   
Platform: Other   
OS: Linux   
Latest Commit: Version Fixed/Implemented In:
Sentry Crash Report:

Description Stephane MANKOWSKI 2015-08-05 20:33:34 UTC
Hi,

I am the main developer of Skrooge and I have a problem since I migrated to Qt5/Kf5.

Indeed, even if Skrooge is translated in many languages, only 3 are available in "Switch Application Language".

Be aware that, if I click on "Réglages par défaut" the application is translated in french even if french is not available in the list.


Reproducible: Always

Steps to Reproduce:
Install skrooge.
Run skrooge
Launch the action "Switch Application Language"

Actual Results:  
Only 3 languages are available.

Expected Results:  
More languages must be available. At least french.

I tried to analyse with and here is my understanding:
1-Available languages are installed like this:

    /usr/share/locale/ast/LC_MESSAGES/skrooge.mo
    ...
    /usr/share/locale/ca@valencia/LC_MESSAGES/skrooge.mo
    ...
    /usr/share/locale/en_GB/LC_MESSAGES/skrooge.mo
    ...
    /usr/share/locale/fr/LC_MESSAGES/skrooge.mo
    ...
    /usr/share/locale/pt_BR/LC_MESSAGES/skrooge.mo
    ...
    /usr/share/locale/zh_CN/LC_MESSAGES/skrooge.mo
    /usr/share/locale/zh_TW/LC_MESSAGES/skrooge.mo

2-To fill the list, KSwitchLanguageDialog calls this method:

    void KSwitchLanguageDialogPrivate::fillApplicationLanguages(KLanguageButton *button)
    {
        QLocale defaultLocale;
        QLocale cLocale(QLocale::C);
        QLocale::setDefault(cLocale);
        //we start with 2, because the 0 is AnyLanguage and 1 is C
        for (int i = 2; i <= QLocale::LastLanguage; ++i) {
            QLocale l(static_cast<QLocale::Language>(i));
            QString languageCode = l.name();
            if (l != cLocale && KLocalizedString::isApplicationTranslatedInto(languageCode)) {
                button->insertLanguage(languageCode);
            }
        }
        QLocale::setDefault(defaultLocale);
    }

3-For french, the languageCode is set to "fr_FR" and KLocalizedString::isApplicationTranslatedInto(languageCode) return false.
This is normal, because the language code is "fr" and not "fr_FR"

4-If I do "sudo cp /usr/share/locale/fr/LC_MESSAGES/skrooge.mo /usr/share/locale/fr_FR/LC_MESSAGES/skrooge.mo" then french is available in the list.

So, all languages with two digits are not available in "Switch Application Language".
This is not normal.
This bug should appear on all applications.
Comment 1 Chusslove Illich 2015-08-11 07:47:23 UTC
KLocalizedString::isApplicationTranslatedInto itself checks for the language code as-is, and it must continue to do so. Any heuristics is upon the caller. So I'll reassign this to KXMLGUI.

As for the heuristics, note that, for example, while fr and fr_FR codes should be treated as the same language, pt and pt_BR must be treated as different.
Comment 2 Stephane MANKOWSKI 2019-03-23 18:30:23 UTC
Hi,

I'm no more able to reproduce this issue with KDE 5.56.0.
So, I think you can close it.

Regards.
Comment 3 Patrick Silva 2019-03-29 16:54:37 UTC
closing as per comment 2