The locales-launch launcher: Fix Glibc locales in the snap runtime

This stage snap ships the locales-launch launcher to your snap, this launcher fixes Glibc locales support and allows snapped application to work properly in a non-English locale.

How to use

Merge the following snapcraft part recipe:

  # Stage snap for fixing the Glibc locales
  # https://forum.snapcraft.io/t/the-locales-launch-stage-snap/10296
  locales-launch:
    source: https://github.com/Lin-Buo-Ren/locales-launch.git
    source-tag: v1.0.0
    plugin: dump
    stage-packages:
    # For localedef(1)
    - libc-bin

    # For locale data used by localedef(1)
    - locales

    # All pre-generated locale data
    # DISABLED: Lots of duplicate data will be included in snap when this is staged, unless the target machine has no resource to generate them in runtime otherwise not using it
    #
    #   Lack of compiled locales breaks gettext based localisation - snapcraft - snapcraft.io
    #   https://forum.snapcraft.io/t/lack-of-compiled-locales-breaks-gettext-based-localisation/3758
    #
    #- locales-all

    stage:
      - bin/locales-launch
      - etc/locale.alias
      - usr/bin/localedef
      - usr/share/doc/locales
      - usr/share/i18n
      - usr/share/locale

In the apps stanza, insert bin/locales-launch into the command chain:

apps:
  _app_name_:
    # The command to run the application, the value should be a *relative path* to an executable file rooted from the `prime` directory
    command: bin/locales-launch "${SNAP}"/bin/_app_command_

if you’re using the full adapter:

apps:
  _app_name_:
    # The environment adapter style to use, `command-chain` is only supported
    adapter: full

    # The command to run the application, the value should be a *relative path* to an executable file rooted from the `prime` directory
    command: bin/_app_command_
    command-chain:
    - bin/locales-launch

Snaps that use this stage snap

The implementation

Lin-Buo-Ren/locales-launch-snap: A stage snap that fixes Glibc locales support


Happy snapcrafting!

This launcher has dropped the stage snap design for convenience of version pinning, the stage snap will still work but please update your snapcraft.yaml for the current implementation, thank you!