Obsoleted: This is now being superseded by The locales-launch launcher: Fix Glibc locales in the snap runtime
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.
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 use locale-launch
- (previously) Lin-Buo-Ren/hello-snap: Unofficial Snap Packaging for GNU Hello - patch
- (previously) htop (maxiberta/htop-snap): The
htop
utility packaged as a snap - patch
Credits
This part will not have great success without James Henstridge’s research and Sebastien Bacher’s initial implementation.
Reference
- Lack of compiled locales breaks gettext based localisation - snapcraft - snapcraft.io
- Remote (reusable) parts - doc - snapcraft.io
Happy snapcrafting!