ubports / ubuntu-touch

Ubuntu Touch's issue inbox is now migrated to GitLab.
https://gitlab.com/ubports/ubuntu-touch
1.28k stars 110 forks source link

Check available phone languages vs. language-packs #655

Open Flohack74 opened 6 years ago

Flohack74 commented 6 years ago

This is a list of language packs installed on the phone:

ii  language-pack-touch-ast                              1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Asturian
ii  language-pack-touch-bg                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Bulgarian
ii  language-pack-touch-br                               2+0~20180107223001.1~1.gbp190b3b                         all          Ubuntu Touch translations for language Breton
ii  language-pack-touch-bs                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Bosnian
ii  language-pack-touch-ca                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Catalan; Valencian
ii  language-pack-touch-cs                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Czech
ii  language-pack-touch-cy                               2+0~20180107223133.1~1.gbpc73c54                         all          Ubuntu Touch translations for language Welsh
ii  language-pack-touch-da                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Danish
ii  language-pack-touch-de                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language German
ii  language-pack-touch-el                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Greek, Modern (1453-)
ii  language-pack-touch-en                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language English
ii  language-pack-touch-es                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Spanish; Castilian
ii  language-pack-touch-eu                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Basque
ii  language-pack-touch-fi                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Finnish
ii  language-pack-touch-fr                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language French
ii  language-pack-touch-gd                               14.10+20140610.3                                         all          Ubuntu Touch translations for language Gaelic; Scottish Gaelic
ii  language-pack-touch-gl                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Galician
ii  language-pack-touch-he                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Hebrew
ii  language-pack-touch-hr                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Croatian
ii  language-pack-touch-hu                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Hungarian
ii  language-pack-touch-id                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Indonesian
ii  language-pack-touch-it                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Italian
ii  language-pack-touch-ja                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Japanese
ii  language-pack-touch-ko                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Korean
ii  language-pack-touch-lt                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Lithuanian
ii  language-pack-touch-lv                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Latvian
ii  language-pack-touch-ms                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Malay
ii  language-pack-touch-nb                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Bokmål, Norwegian; Norwegian Bokmål
ii  language-pack-touch-nl                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Dutch; Flemish
ii  language-pack-touch-oc                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Occitan (post 1500)
ii  language-pack-touch-pa                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Panjabi; Punjabi
ii  language-pack-touch-pl                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Polish
ii  language-pack-touch-pt                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Portuguese
ii  language-pack-touch-ro                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Romanian
ii  language-pack-touch-ru                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Russian
ii  language-pack-touch-sk                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Slovak
ii  language-pack-touch-sl                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Slovenian
ii  language-pack-touch-sr                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Serbian
ii  language-pack-touch-sv                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Swedish
ii  language-pack-touch-tr                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Turkish
ii  language-pack-touch-ug                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Uighur; Uyghur
ii  language-pack-touch-uk                               1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Ukrainian
ii  language-pack-touch-zh-hans                          1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Simplified Chinese
ii  language-pack-touch-zh-hant                          1:16.04+20160627.1                                       all          Ubuntu Touch translations for language Traditional Chinese

It is not clear how they correspond to the available languages on the device. Not all languages are selectable on the phone UI. I did not crosscheck if all selectable languages have a language file here.

dpniel commented 6 years ago

The way available languages are determined is by listing all directories in /usr/share/locale-langpack and passing each through icu::Locale::getDisplayName() if the display name is empty (or "C") then the locale isn't included in the displayed list.

So i can only assume this is why some of the installed locales don't show up. There is also a workaround for pt_PT to get that to work, do we need to do the same kind of hackery for any other missing locales?

Source of locale list generation

Flohack74 commented 6 years ago

No but I was trying to add Sardinian by mocking it from the Italian package and renaming everything, and it still did not show up in this list... :) - lets talk about this later. But we got an active Sardinian group already, and they just want to select their language at phone setup, so that they can benefit from partial translation. Even if it is not an official Ubuntu language, it would be great if we can hack it like this.

dpniel commented 6 years ago

Seems QLocale can't handle sardinian

#include <QCoreApplication>
#include <QDebug>
#include <QLocale>

int main(int argc, char *argv[])
{
    QCoreApplication a(argc, argv);

    qDebug() << QLocale("sc").name();
    qDebug() << QLocale("srd").name();
    qDebug() << QLocale(QLocale::Language::Sardinian).name();
    qDebug() << QLocale(QLocale::Language::Sardinian).nativeLanguageName();
    qDebug() << QLocale::languageToString(QLocale::Language::Sardinian);

    return a.exec();
}

Output:

"C"
"C"
"en_GB"
"British English"
"Sardinian"

The fact QLocale("sc").name() returns "C" means it will never show up in the list with the current logic. It's also questionable whether Qt can support sardinian at all looking at this comment https://bugreports.qt.io/browse/QTBUG-57802?focusedCommentId=383762&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-383762

Flohack74 commented 6 years ago

Oh my, what a pity. So far a strange thing with Qt, see pt_BR ;)

Flohack74 commented 6 years ago

QLocale cannot deal with a language which is not associated with a particular country.

WTF.

dpniel commented 6 years ago

Yeah it's annoying. I was thinking that because we use gettext for most apps and not QTranslator we could probably miss that step of passing it through QLocale in system-settings/language-plugin but it's still going to raise bugs in calendar etc. What a PITA... I'm not sure what to do

Flohack74 commented 6 years ago

I am thinking of moving this to OTA-5. A clean langpack solution including suggestions from the community will take longer...

Flohack74 commented 6 years ago

See https://papad.org/p/LanguageCompareUBports for an experiment to tally what is in the language selector and what is installed.