Masse
Masse

Reputation: 4344

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

Upvotes: 1

Views: 935

Answers (2)

Gallaecio
Gallaecio

Reputation: 3847

setenv("LANGUAGE", languagecode);

If languagecode is "fr", and you have an "fr/LC_MESSAGES/.mo" file in the directory pointed to by bindtextdomain, it should work.

Upvotes: 0

Sander Marechal
Sander Marechal

Reputation: 23216

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.

Upvotes: 1

Related Questions