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

[ bsd3, i18, i18n, i18n-text, library, text ] [ Propose Tags ] [ Report a vulnerability ]

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.


[Skip to Readme]

Modules

[Index] [Quick Jump]

Downloads

Maintainer's Corner

Package maintainers

For package maintainers and hackage trustees

Candidates

  • No Candidates
Versions [RSS] 0.1.0.0, 0.1.0.1, 0.1.0.2, 0.1.0.3, 0.2.0.0, 0.2.0.1
Change log CHANGELOG.md
Dependencies base (>=4 && <5), bytestring, containers, directory, filepath, haskell-gettext, template-haskell, text, th-lift-instances [details]
License BSD-3-Clause
Author Christoph Bauer
Maintainer mail@christoph-bauer.net
Category i18n, Text
Home page https://github.com/chrbauer/gettext-th
Bug tracker https://github.com/chrbauer/gettext-th/issues
Uploaded by ChristophBauer at 2022-09-10T20:04:20Z
Distributions NixOS:0.2.0.1
Reverse Dependencies 1 direct, 0 indirect [details]
Downloads 354 total (17 in the last 30 days)
Rating (no votes yet) [estimated by Bayesian average]
Your Rating
  • λ
  • λ
  • λ
Status Docs available [build log]
Last success reported on 2022-09-10 [all 1 reports]

Readme for gettext-th-0.2.0.1

[back to package description]

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.