Wolfgang Pichler wrote:
after creating directory ./locale to get rid of errors regarding
nonexistence of assumed directory (language.inc: getLanguages()) some
more errors show up
The error produced by opendir() is now suppressed. ./locale and language
files will be created by a script during installation, but that is still
work in progress.
PHP Notice: Undefined offset: 0 in /home/httpd/emilda/lib/language.inc
on line 67
management.php? The offset is now checked before accessing the language
name array (i.e. fixed =).
PHP Notice: Use of undefined constant USER_NAME - assumed 'USER_NAME'
in /home/httpd/emilda/lib/sessions.inc on line 59
A small mistake in writeLog(). Fixed.
1) btw. would try to test some translations using e.g. de (partially
translated/copied from en) so what to do _exactly_ (promise to
contribute a german translation :-) ?
Are you using ./lang/emilda.pot as template? (Or en.po, which is
basically the same thing.) I'm afraid that those files are seriously
outdated, but you can use them for testing purposes. Just keep in mind
that gettext needs an _exact_ match for the string to be translated,
i.e. even small text changes in the source code will render individual
text translations useless. Detailed explanation follows:
Translations are always made on snapshots of the source code; xgettext
is used to extract all _("strings") from the .php/.inc files. In
addition to this we need to extract some strings half-manually from
emilda.sql and the config files (we will probably create a simple script
for this purpose). The result of the merged extractions is emilda.pot, a
translation template file, the current ./lang/emilda.pot is based on an
early 1.2 snapshot.
Based on this template anyone can translate text that is used in Emilda.
The .pot file is copied to my_language_code.po, which is where the
translated strings will be entered. The syntax of a .po file is very
simple; msgid is the identifier and the text in English, msgstr is the
translated text. Gettext tries to find a msgid that matches _("this
string") and uses the msgstr if successful. Hence if the source text is
changed to _("another string") gettext won't find a match anymore.
Please see http://www.uberdose.com/php/php-and-gettext-for-i18n/ for
examples.
Finally the .po file is compiled using msgfmt, renamed emilda.mo and
placed in the ./locale/[language_code]/LC_MESSAGES folder. Emilda will
search for these directories and try to use the language files in them.
So the steps are:
[1. Extract all strings from the source code using xgettext.]
[2. Merge results into emilda.pot template.]
3. cd lang/ && cp emilda.pot [my_lang].po
4. Translate strings.
5. mkdir -p ../locale/[my_lang]/LC_MESSAGES
6. msgfmt -o ../locale/[my_lang]/LC_MESSAGES/emilda.mo [my_lang].po
7. Change language on your personal Emilda configuration page.
If this doesn't work, please check that [my_lang] locale is installed on
your system (locale -a) and that [my_lang] corresponds to that language
code. See user comments at http://fi.php.net/gettext for more help.
2) btw. i see some problem if you rely on LANG/LANGUAGE fetched from
environment since
- it is very uncommon to have locale other than en _systemwide_ under
linux !
True, but is there any other way to do this in PHP? Anyone here with
more PHP-gettext experience?
lg.w.
Regards,
--
Erik Berglund
Partner, Marketing
Oy Realnode Ab
lastname@xxxxxxxxxxxx
www.realnode.com
|