MyNixOS website logo
Description

gettext-th can internationalise a haskell program without runtime dependencies.

The gettext project provides a library and tools for internationalization and localization of software. gettext-th allows you to use the gettext tooling without adding any runtime dependencies because texts are exchanged at compile time. But this also means that you have an application per language.

gettext-th

The gettext project provides a library and tools for internationalization and localization of software. Haskell has already support for gettext. It is possible either to use the C-library with FFI (hgettext) or to use a pure Haskell implementation (haskell-gettext).

With gettext the executables and the translations are separated and the language strings are looked up at runtime. The loadCatalog of gettext-haskell has to read the translations at runtime with IO.

This is difficult if you transpile your haskell code to javascript, which runs in a browser. To close this gap gettext-th moves the lookup of messages to compile time. A similar approach was taken for angular-i18n for performance reasons. This of course has some drawbacks (less flexible and one program per language) and some benefits (simple and performant).

Theoretically gettext-th could also choose between runtime and compile time lookups.

Warning

gettext-th will use IO at compile time and will write a file.

How to use it

See for an example in example/hello.

To use gettext-th in your app use it and compile it. It will fail, but it will create the file po/messages.pot. Run in the po folder:

msginit
msgfmt en_US.po

With that the program compiles. And you can update en_US.po again.

Now copy en_US.po to de_DE.po, translate the messages and run msgfmt de_DE.po. If you recompile (maybe run cabal clean first) the output of your app is in german.

Metadata

Version

0.2.0.1

Platforms (75)

    Darwin
    FreeBSD
    Genode
    GHCJS
    Linux
    MMIXware
    NetBSD
    none
    OpenBSD
    Redox
    Solaris
    WASI
    Windows
Show all
  • aarch64-darwin
  • aarch64-genode
  • aarch64-linux
  • aarch64-netbsd
  • aarch64-none
  • aarch64_be-none
  • arm-none
  • armv5tel-linux
  • armv6l-linux
  • armv6l-netbsd
  • armv6l-none
  • armv7a-darwin
  • armv7a-linux
  • armv7a-netbsd
  • armv7l-linux
  • armv7l-netbsd
  • avr-none
  • i686-cygwin
  • i686-darwin
  • i686-freebsd
  • i686-genode
  • i686-linux
  • i686-netbsd
  • i686-none
  • i686-openbsd
  • i686-windows
  • javascript-ghcjs
  • loongarch64-linux
  • m68k-linux
  • m68k-netbsd
  • m68k-none
  • microblaze-linux
  • microblaze-none
  • microblazeel-linux
  • microblazeel-none
  • mips-linux
  • mips-none
  • mips64-linux
  • mips64-none
  • mips64el-linux
  • mipsel-linux
  • mipsel-netbsd
  • mmix-mmixware
  • msp430-none
  • or1k-none
  • powerpc-netbsd
  • powerpc-none
  • powerpc64-linux
  • powerpc64le-linux
  • powerpcle-none
  • riscv32-linux
  • riscv32-netbsd
  • riscv32-none
  • riscv64-linux
  • riscv64-netbsd
  • riscv64-none
  • rx-none
  • s390-linux
  • s390-none
  • s390x-linux
  • s390x-none
  • vc4-none
  • wasm32-wasi
  • wasm64-wasi
  • x86_64-cygwin
  • x86_64-darwin
  • x86_64-freebsd
  • x86_64-genode
  • x86_64-linux
  • x86_64-netbsd
  • x86_64-none
  • x86_64-openbsd
  • x86_64-redox
  • x86_64-solaris
  • x86_64-windows