Comments (4)
I submitted a possible solution to this in the devs discussion
http://groups.google.com/group/twig-devs/browse_thread/thread/97ccbc0afdef6326
The following isn't beautiful - but appears to work! Maybe you could
refactor?
if(count($body) > 1)
{
foreach ($body as $node) {
if ($node instanceof Twig_Node_Print) {
$n = $node->getNode('expr');
while ($n instanceof Twig_Node_Expression_Filter)
{
$n = $n->getNode('node');
}
$msg .= sprintf('%%%s%%', $n->getAttribute('name'));
$vars[] = new Twig_Node_Expression_Name($n->getAttribute('name'), $n->getLine());
} else {
$msg .= $node->getAttribute('data');
}
}
return array(new Twig_Node(array(new Twig_Node_Expression_Constant(trim($msg), $node->getLine()))), $vars);
}
else
{
$msg .= $body->getAttribute('data');
return array(new Twig_Node(array(new Twig_Node_Expression_Constant(trim($msg), $body->getLine()))), $vars);
}
from twig-extensions.
I found the same issue and I developed a temporary bugfix doing something very similar to what @alecsammon did.
Here's my fix:
protected function compileString(Twig_NodeInterface $body)
{
if ($body instanceof Twig_Node_Expression_Name || $body instanceof Twig_Node_Expression_Constant) {
return array($body, array());
}
$msg = '';
$vars = array();
if(sizeof($body))
{
foreach ($body as $node) {
if ($node instanceof Twig_Node_Print) {
$n = $node->getNode('expr');
while ($n instanceof Twig_Node_Expression_Filter) {
$n = $n->getNode('node');
}
$msg .= sprintf('%%%s%%', $n->getAttribute('name'));
$vars[] = new Twig_Node_Expression_Name($n->getAttribute('name'), $n->getLine());
} else {
$msg .= $node->getAttribute('data');
}
}
}
else
{
$msg = $body->getAttribute('data');
}
return array(new Twig_Node(array(new Twig_Node_Expression_Constant(trim($msg), $body->getLine()))), $vars);
}
from twig-extensions.
Same issue here, all the gettext functions are empty in compiled templates.
Any update soon ?
from twig-extensions.
fixed
from twig-extensions.
Related Issues (20)
- Variables in translation not escaped? HOT 10
- Deprecation Warning for Text.php & Fix HOT 1
- Translator decorator error in prod HOT 2
- Feature: Iterable test functions HOT 1
- Trans tag content with variables in them are broken for new versions of Twig.
- Attempted to load class "Twig_Extensions_Extension_Intl" HOT 1
- localized yes/no function for boolean value HOT 1
- Unexpected result of the localizeddate function HOT 1
- How to add IntlExtension with release 1.5.4 HOT 4
- Cannot combine form vars and filter HOT 5
- Please allow Twig 3 HOT 1
- Conflits with doctrine-bundle HOT 4
- Alternative for Date time_diff ? HOT 2
- Support Twig 3.0 HOT 1
- Support Symfony 5 HOT 3
- Php 7.4 preloading on v1.5.4 fails HOT 2
- [intl-extra] Japanese date format issue
- Mark as abandoned on packagist.org HOT 2
- What's the alternative solution for i18n translation which is supported by twig/twig-extension before and is not supported after upgrading to twig/twig:3 HOT 3
- Use GithubActions instead of Travis
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from twig-extensions.