On 12.06.2009, at 23:15, michal wrote:

Let me clear what I want.
My application consist of many files(pages) so I decide to store my translation in separate json files. One translation file for one www page. Every time I load page, translation is taken from json file and loaded into application and
$tpl-> object. Than I can use it inside xhtml(template).

I try to understand the translation system in PHPTAL. PHP part of t. system is
not clear for me.

What I want is to have easy to use ,fast translation system with many
tranlation files, because one file with translation would slow down application.

If speed is concern, then you should really look at gettext:
• gettext lookup is even slightly faster than PHP's native arrays! [1]
• mod_php caches .mo files in memory, so that beats loading of anything from disk. • even when .mo files are loaded, they don't need nearly as much processing as conversion of JSON to PHP objects.

[1] 
http://mel.melaxis.com/devblog/2006/04/10/benchmarking-php-localization-is-gettext-fast-enough/


However you should first ensure that translation speed really affects your application (i.e. prototype & profile), because it may not be the case.

1. Do you have code of simple working application using translation system.

I've written hCard validator using PHPTAL and gettext:
http://code.google.com/p/hcardvalidator/

(it's not most beautiful code ever written, but works :)

2. Do I have to use .po files if I use i18n:translate tags?

No. You can write your own translation service. It's roughly like this:

class MyTranslator extends PHPTAL_TranslationService {
        function translate($original, $htmlescape=true)
        {
                $translated = // translate here

                if ($htmlescape) return htmlspecialchars($translated);
                return $translated;
        }
}

$phptal->setTranslator(new MyTranslator());

--
regards, Kornel




_______________________________________________
PHPTAL mailing list
PHPTAL@lists.motion-twin.com
http://lists.motion-twin.com/mailman/listinfo/phptal

Reply via email to