[PHPTAL] i18n - question
lbedubourg
lbedubourg at motion-twin.com
Mon Nov 13 11:33:39 CET 2006
Le vendredi 10 novembre 2006 à 17:43 +0100, Anniyka Wandersmann a
écrit :
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
>
>
> Hello, I do have the following till now, but I only got "Welcome" instead
> of "Herzlich Willkommen". I tried a lot, but till now, nothing. Any idea?
>
> http://www.wandersmann.net/sadtec
>
> index.html
> - -----------------<snip>----------------------
> <?xml version="1.0"?>
> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
> "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
> <html xmlns="http://www.w3.org/1999/xhtml">
> <head>
> <meta http-equiv="refresh" content="0;
> URL=http://www.wandersmann.net/sadtec/links/index.php"/>
> </head>
> <body>
> Weiterleitung:<a
> href="http://www.wandersmann.net/sadtec/links/index.php">Hier
> klicken</a>
> </body>
> </html>
> - -----------------</snip>----------------------
>
> conflink.php
> - -----------------<snip>----------------------
> define ('LANG_PATH',
> '/long/absolute/path/to/lang/');
> - -----------------</snip>----------------------
>
> - -----------------<snip>----------------------
> >ls -l links
> insgesamt 0
> lrwxrwxrwx 1 wandersmann webuser 9 2006-11-10 13:33 admin.php -> index.php
> lrwxrwxrwx 1 wandersmann webuser 13 2006-11-10 13:34 index.php -> ../sadtec.php
> - -----------------<snip>----------------------
>
> Do not wonder, it will be explained in length in a few days, only the i18n
> is left now ...
>
> out of sadtec.php:
> - -----------------<snip>----------------------
> require_once ('conflink.php');
> include_once (CONFIG_PATH . '/config.php');
> // Starting TAL
> require_once ('PHPTAL.php');
> require_once ('PHPTAL/GetTextTranslator.php');
> $tr = new PHPTAL_GetTextTranslator();
> // set language to use for this session (first valid language will
> // be used)
> $tr->setLanguage('de_DE');
> // register gettext domain to use
> $tr->addDomain('sadtec', '../' . LANG_PATH);
> // specify current domain
> $tr->useDomain('sadtec');
> $template = new PHPTAL('../' . TEMPLATES_PATH . TEMPLATE . '/index.xhtml');
> include_once ('../' . TEMPLATES_PATH . TEMPLATE . '/header.php' );
> // tell PHPTAL to use our translator
> $template->setTranslator($tr);
I assume you execute the template after this line and not in
header.php...
> lang/de/LC_MESSAGES/sadtec.po
> - -----------------<snip>----------------------
> >less sadtec.po
> msgid "Welcome\n"
I am not sure gettext supports "\n" at the end of your msgid, "Welcome"
may not be the same as "Welcome\n", just a guess ?
PHPTAL / I18N trim keys to avoid confusion (tabs, spaces, \r\n, etc.).
Best regards
Laurent
More information about the PHPTAL
mailing list