Search code examples
c++cgettext

Gettext and locales


I heard from a relatively trustworty source that gettext doesn't require system locales for it to work. But I have tried a few tutorials, and unless I have locale-gen'd (in arch) fi_FI.utf8, I can't get any translations to show.

root@junior:~/programming/Projects/Cpp/web/test# LANG=fi_FI.utf8 bin/hello 
Hello world!
This is package: web-cms
root@junior:~/programming/Projects/Cpp/web/test# sed -i 's/#fi_FI.UTF-8/fi_FI.UTF-8/' /etc/locale.gen && locale-gen
Generating locales...
  en_GB.UTF-8... done
  en_US.UTF-8... done
  fi_FI.UTF-8... done
Generation complete.
root@junior:~/programming/Projects/Cpp/web/test# LANG=fi_FI.utf8 bin/hello 
Terve maailma
Tämä on paketti: web-cms

Solution

  • Did you hear right? As far as I know, you do need system locales for gettext to work. However, you do not need to install all the translations for those system locales just to make your "hello world" work.