The `locales-launch` remote part


#1

This remote part ships the locales-launch launcher to your snap, this launcher fixes Glibc locales support and allows GNU Gettext-based internationalization(I18N) to work.

example of gettext support

How to use?

Essential

Merge the following snapcraft recipe:

parts:
  locales-launch:

and prepend locales-launch to the snap application command chain:

apps:
  _app_name_:
    command: locales-launch _original_app_command_chain_

That’s all you have to do, but if you want to directly embed the full set of pre-compiled locale data without generating them at runtime once per installation per locale and don’t care about the snap size increase by ~7MiB, override the stage-packages key to stage the locales-all package:

parts:
  locales-launch:
    stage-packages:
    - locales-all

The launcher will automatically use the in-snap locale data if found.

GNU Gettext-specific fixes

Due to the fact that the gettext library doesn’t support locating the localization data from a non-fixed location, additional modifications may be required to make I18N work.

For example for software using the GNU build system the following modification is usually necessary:

parts:
  _part_name_:
    configflags:
    - --datarootdir=/snap/$SNAPCRAFT_PROJECT_NAME/current/share

    organize:
      snap/$SNAPCRAFT_PROJECT_NAME/current: /

NOTE

This launcher is not necessary if the snap target is a GUI application and you’re using the desktop-* remote part and the desktop-launch launcher. This remote part is primarily for CLI applications.

The implementation

You may also run snapcraft define locales-launch to verify the actual implementation being used.

Snaps that uses locale-launch

Credits

This part will not have great success without James Henstridge’s research and Sebastien Bacher’s initial implementation.

Reference

Happy snapcrafting!


Lack of compiled locales breaks gettext based localisation
Python apps
Call for testing: youtube-dl
#2

Awesome, thanks for this!

I just tried it out with a python snap and it fixes the locale issues!

Can you add a link to a snap using this? Do you want to make this post into a wiki so others can help maintain this doc?


#3

Sure, I was originally using this to fix the GNU Hello snap.

It is now converted to a wiki.