thielepaul / photoprism-mobile

Flutter App for PhotoPrism
GNU General Public License v3.0
898 stars 69 forks source link

[Feature Request] Multi-Language Support #59

Open ollimaz opened 4 years ago

ollimaz commented 4 years ago

Hi,

What about translating the app into more languages. See: https://flutter.dev/docs/development/accessibility-and-localization/internationalization

I could support by translating into German - if needed -

Edit: For now just add the language which are supported by photoprism too?

skyeskie commented 4 years ago

So, went ahead and tried a couple different options for a localization framework.

easy_localization:

Dart package

Looks like one of the better packages for Flutter. Fairly clean code. It'd need a little work to pull from the main photoprism project.

Sample: https://github.com/skyeskie/photoprism-mobile/tree/easy_localization

          BottomNavigationBarItem(
            icon: Icon(Icons.photo),
            title: const Text('Photos').tr(),
          ),

flutter_intl

CLI + VSCode + JetBrains

Has plugins for some refactoring help, but main positive here is integration with https://localizely.com/ (free open source option) for a UI for translators. The code itself is a little messy to use (requiring a BuilderContext to access translations).

Sample: https://github.com/skyeskie/photoprism-mobile/tree/flutter_intl

          BottomNavigationBarItem(
            icon: const Icon(Icons.photo),
            title: Text(S.of(context).photos),
          ),

Gettext equivalents

No actual text extraction. Just ports of the NPM packages to read the gettext formats.

Sample (haven't done full branch):

          BottomNavigationBarItem(
            icon: const Icon(Icons.photo),
            title: Text(gt.gettext('Photos')),
          ),

Only option that'd directly take po or mo files from the main project. Also, under the flutter package, looks like it has options to compile into dart files directly. However, looks like the flutter part is abandoned, not known how complete.


One of the things to consider - where should we keep the translations?

Something unified would keep consistent messaging and enable displayable text to be sent in the server API responses. However, it'd be a bit of a hassle to add new strings for translations.

Also, several of these frameworks have more advanced options than a simple text lookup. Those aren't used on the main photoprism UI, but that might be something to look into.