geigi / cozy

🎧 Listen to audio books 📚 on Linux
https://cozy.sh
GNU General Public License v3.0
1.09k stars 85 forks source link

User interface not translated in flatpak build #738

Closed swsnr closed 9 months ago

swsnr commented 1 year ago

Bug/Feature description

When running with flatpak run --env=LANG=de_DE --env=LC_MESSAGES=de_DE com.github.geigi.cozy I do not see a translated user interface; instead all text is in English.

The locale data exists according to flatpak:

$ flatpak info com.github.geigi.cozy.Locale
            ID: com.github.geigi.cozy.Locale
           Ref: runtime/com.github.geigi.cozy.Locale/x86_64/stable
          Arch: x86_64
        Branch: stable
        Origin: flathub
    Collection: org.flathub.Stable
  Installation: system
     Installed: 49,7 kB

        Commit: 948667de6d82f734023a41bdce9bab463ea89529066f31d75e82569e6965d241
        Parent: ea7b9445a751aea29a746ce46cd177898ccc49e49ebcba10cd2c3d6c31e6d63e
       Subject: Bump version to 1.2.1 (959b9366)
          Date: 2022-08-21 13:05:58 +0000
Subdirectories: /de,/en

Steps to reproduce

Run flatpak run --env=LANG=de_DE --env=LC_MESSAGES=de_DE com.github.geigi.cozy

System Information

geigi commented 1 year ago

Have you tried using de instead of de_DE?

swsnr commented 1 year ago

@geigi de is not a valid locale, so flatpak run --env=LANG=de --env=LC_MESSAGES=de com.github.geigi.cozy gives a Gtk warning right after start:

(com.github.geigi.cozy:2): Gtk-WARNING **: 08:58:47.556: Locale not supported by C library.
        Using the fallback 'C' locale.
['/app/bin/com.github.geigi.cozy']

The user interface remains English.

Perhaps Cozy is looking for locales in the wrong directory? I've had a similar issue recently with Zim, see https://github.com/zim-desktop-wiki/zim-desktop-wiki/pull/2194

geigi commented 1 year ago

Ok might be a possibility. As far as I can remember the flatpak packaged Cozy adopted the system language correctly but maybe it broke. Is your system language also German?

swsnr commented 1 year ago

Yes, it is. Other flatpaks (e.g. Zim with the above fix) have German text, and the language is also explicitly configured for flatpak:

$ flatpak config --system --list
languages: *unset* (default: de;en)
extra-languages: en;en_GB;de;de_DE

The locale is also installed correctly:

$ flatpak info com.github.geigi.cozy.Locale
            ID: com.github.geigi.cozy.Locale
           Ref: runtime/com.github.geigi.cozy.Locale/x86_64/stable
          Arch: x86_64
        Branch: stable
        Origin: flathub
    Collection: org.flathub.Stable
  Installation: system
     Installed: 49,7 kB

        Commit: 948667de6d82f734023a41bdce9bab463ea89529066f31d75e82569e6965d241
        Parent: ea7b9445a751aea29a746ce46cd177898ccc49e49ebcba10cd2c3d6c31e6d63e
       Subject: Bump version to 1.2.1 (959b9366)
          Date: 2022-08-21 13:05:58 +0000
Subdirectories: /de,/en

The locale data also exists in Cozy:

[📦 com.github.geigi.cozy ~]$ find -L  /app/share/locale/ -name '*.mo'
/app/share/locale/de/LC_MESSAGES/com.github.geigi.cozy.mo
/app/share/locale/de/LC_MESSAGES/libdazzle-1.0.mo
/app/share/locale/de/LC_MESSAGES/libhandy.mo
/app/share/locale/en_GB/LC_MESSAGES/libhandy.mo
swsnr commented 1 year ago

@geigi I'd also like to point out that I'm familiar with Python and flatpak, so if you could point me to the place where Cozy sets up its locales I can also try to fiddle myself 🙂

geigi commented 1 year ago

Cool! This should get you started:

gettext is initialized here

The locale_dir variable is set here (it gets inserted by meson)

Assembled path in meson

swsnr commented 1 year ago

I checked, and the locale directory is /app/share/locale. For reference, I tried a local build of Cozy (aur package), and turns out it doesn't have localized text either.

Either something's pretty wrong on my system (though all other apps have localized text), or there's some other issue in Cozy 🤔

ghost commented 1 year ago

I sent a MR for this bug.

ghost commented 1 year ago

I think, installer is not installing any localizations.

installer log

There is no "Generating po" or "Installing po" entry in the log file.

Manuel-Senpai commented 1 year ago

Hi: Both in version 1.2.1 of MX-Linux repos as .deb, as in the flatpak version it installs only in English and in the preferences there is no section to choose language.... Can it be solved in some way, since I see that the application is really translated. Best regards

renarena commented 10 months ago

I installed v1.2.1 from ppa in Ubuntu 21 - cozy is english rather then my lang...

rdbende commented 9 months ago

Instead of gettext.bindtextdomain and gettext.textdomain, locale.bindtextdomain and locale.textdomain must be used in order to make it work inside Flatpak.

I checked and this is also what most Python-based GNOME apps and even the Python GNOME app template does, so I'll drop a PR for it.