Created
February 7, 2018 22:20
-
-
Save nfreear/cee98d29dfa2f317296afafcd512a586 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 | |
/** | |
* Twig-translate-function.php | |
* | |
* @link https://twig.symfony.com/doc/1.x/advanced.html#filters | |
*/ | |
$twig = new Twig_Environment($loader); | |
$twig->addFunction(new \Twig_SimpleFunction('translate', function ($str) { | |
return gettext( $str ); | |
})); | |
?> | |
# | |
#: example.twig | |
# | |
{# <?php fake php #} | |
{# Trans: Was: 'Assignments' #} | |
<p>{{ translate('My assignments') }}</p> | |
# | |
#: bash | |
# | |
xgettext --default-domain=messages -p ./lang -L PHP --keyword=translate -cTrans: --force-po templates/*/*.twig | |
# End. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment