Created
March 15, 2010 00:48
-
-
Save jwpage/332379 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class Gettext_Twig_Extension extends Twig_Extension | |
{ | |
public function getFilters() | |
{ | |
return array( | |
't' => new Twig_Filter_Function('gettext'), | |
); | |
} | |
} | |
/* | |
$twig = new Twig_Environment(...); | |
$twig->addExtension('Gettext_Twig_Extension.class.php'); | |
{{ 'MY_USERNAME'|t }} can now be used in templates to display the gettext string associated with the "MY_USERNAME" key. | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment