Reputation: 534
I'm trying to install gettext on debian, it works perfectly on Wamp on my local computer, but not on the server. I did this for the install:
apt-get install -V gettext
I launch this:
# apt-cache search --names-only gettext
libgettext-ant-tasks-java - Java classes for internationalization (i18n) - Ant tasks
gettext-base - GNU Internationalization utilities for the base system
gettext-doc - Documentation for GNU gettext
gettext-el - Emacs po-mode for editing gettext .po files
gettext - GNU Internationalization utilities
libgettext-activerecord-ruby-common - GetText localization for Ruby programs using ActiveRecord
libgettext-activerecord-ruby1.8 - GetText localization for Ruby programs using ActiveRecord
libgettext-activerecord-ruby1.9.1 - GetText localization for Ruby programs using ActiveRecord
libgettext-activerecord-ruby - GetText localization for Ruby programs using ActiveRecord
libgettext-commons-java - Java classes for internationalization (i18n)
libgettext-rails-ruby-doc - Gettext support for Rails 2.3
libgettext-rails-ruby1.8 - Gettext support for Rails >= 2.3
libgettext-rails-ruby - Gettext support for Rails >= 2.3
libgettext-ruby-util - Gettext utilities for ruby (dummy package)
libgettext-ruby1.8 - Gettext for ruby1.8
libgettext-ruby1.9.1 - Gettext for ruby1.9.1
libintl-gettext-ruby1.8 - Gettext wrapper for Ruby 1.8
libintl-gettext-ruby - Gettext wrapper for Ruby
liblocale-gettext-perl - Using libc functions for internationalization in Perl
liblocale-maketext-gettext-perl - Perl module bridging gettext and Maketext localization frameworks
libgettext-ocaml-dev - OCaml internationalization library
libgettext-ocaml - OCaml internationalization shared library
php-gettext - read gettext MO files directly, without requiring anything other than PHP
smarty-gettext - Gettext plugin enabling internationalization in Smarty
my phpinfo():
GetText Support enabled
My php code:
putenv("LANG=nl_NL");
setlocale(LC_ALL, "nl_NL");
bindtextdomain("greetings", "./locale/");
textdomain("greetings");
echo _("Hello World");
greetings.po:
msgid "Hello World"
msgstr "Hallo Wereld"
greetings.mo in:
locale/nl_NL/LC_MESSAGES/
Other informations:
PHP Version 5.3.3-7+squeeze3
I followed a lot of tutorials, but none of them works, the last one was http://www.aota.net/forums/showthread.php?threadid=10615
Normally it should output "Hallo Wereld", but it is still "Hello World". I restarted the server and the translation has been made since a while so it's not a cache problem.
Thank you very much.
Upvotes: 0
Views: 1219
Reputation: 3012
Effectivly, a solution is to add ".utf-8" after your language name.
Another solution may be to add "locales" without ".utf8" to your debian.
I noticed this result in an OVH server (hosting company), on which your first configuration is working:
$ locale -a
en_GB
en_GB.iso88591
en_GB.iso885915
en_GB.utf8
fr_FR
fr_FR.iso88591
fr_FR.iso885915
fr_FR.utf8
and in my debian (synology) server, only:
$ locale -a
en_GB.utf8
fr_FR.utf8
Upvotes: 0
Reputation: 534
Ok I just discovered how to make it.
So on Debian we do:
dpkg-reconfigure locales
then we pick the languages we need.
and the code must have exactly the same writing then the when we type # locale -a (.utf8 if you chose that one)
putenv('LC_ALL=nl_NL.utf8');
setlocale(LC_ALL, "nl_NL.utf8");
bindtextdomain("greetings", "./locale");
textdomain("greetings");
echo gettext("Hello World");
Strange but it works.
Upvotes: 1
Reputation: 33175
An idea: Try using the full path in bindtexdomain(...)
without a trailing slash.
Edit/Try #2:
Try running unset LANG
and restarting Apache.
Upvotes: 1