[Phpmyadmin-devel] phpMyAdmin with gettext

Michael Keck sfnet at michaelkeck.de
Thu Mar 18 09:13:13 CET 2010


The developer of Twig have made an i18n-extension.
Download the latest Twig Sanpshot: git://github.com/fabpot/Twig.git

Or use this code-snippet (what I've done):

class Gettext_Twig_Extension extends Twig_Extension
   public function getFilters()
        return array(
            't' => new Twig_Filter_Function('gettext'),
$twig = new Twig_Environment(...);
{{ 'MY_USERNAME'|t }} can now be used in templates to display the
gettext string associated with the "MY_USERNAME" key.

Am 15.03.2010 13:29, schrieb Tomas Srnka:
> Hi,
> could you please publish the filter somewhere? There is a message in
> TWIG's mailing list without any reply regarding gettext and I'm
> planning to use TWIG+gettext in my own project.
> Thank you!
> Best regards,
> Tomas Srnka
> On Mon, Mar 15, 2010 at 12:29 PM, Michael Keck <sfnet at michaelkeck.de
> <mailto:sfnet at michaelkeck.de>> wrote:
>     Hi Michal,
>     I've found a solution and it worked for me now:
>     I've contacted the developer of TWIG and he gives me a sample
>     filter for
>     gettext. So I can use in templates as an expample {{ 'Welcome to
>     phpMyAdmin'|t }}.
>     I know, that phpMyAdmin should still work without javascript.
>     Javascript
>     should only be a feature. But if user want to use javascript, this
>     should be secure enough.
>     I guess with you, that with wrong encoding/charset in browser settings
>     also text in pages may be displayed wrong, but phpMyAdmin still works.
>     Perhabs I will see 'L?schen' instead of 'Löschen', but it still works.
>     But it's different in javascript (I've written many javascripts in
>     past):
>     With wrong encoding/charset in browser settings, you'll get 'Löschen'
>     (or something other terrible for javascript like 'ä' for the letter
>     'ä') for the string 'Löschen',  which crashes all used javascripts.
>     With my "bulletproof"-suggestion (using 'L\u00F6schen' instead of
>     'Löschen'),  only the text is displayed wrong (I will see
>     'L\u00F6schen'
>     or 'L?schen' instead 'Löschen'), but javascript still working.
>     Regards
>     Michael
>     ------------------------------------------------------------------------------
>     Download Intel® Parallel Studio Eval
>     Try the new software tools for yourself. Speed compiling, find bugs
>     proactively, and fine-tune applications for parallel performance.
>     See why Intel Parallel Studio got high marks during beta.
>     http://p.sf.net/sfu/intel-sw-dev
>     _______________________________________________
>     Phpmyadmin-devel mailing list
>     Phpmyadmin-devel at lists.sourceforge.net
>     <mailto:Phpmyadmin-devel at lists.sourceforge.net>
>     https://lists.sourceforge.net/lists/listinfo/phpmyadmin-devel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.phpmyadmin.net/pipermail/developers/attachments/20100318/a860d415/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 291 bytes
Desc: OpenPGP digital signature
URL: <http://lists.phpmyadmin.net/pipermail/developers/attachments/20100318/a860d415/attachment.sig>

More information about the Developers mailing list