Comments (19)
@schmittjoh Any change of seeing this soon?
Maybe I can take a look at this tomorrow.
from jmstranslationbundle.
I think I merged something for this recently, but it's not a feature that I
am using personally.
If it's not supported yet, you'll need to digg into it, not sure when I'll
have time.
On Mon, Nov 26, 2012 at 5:00 PM, Sebastiaan Stok
[email protected]:
@schmittjoh https://github.com/schmittjoh Any change of seeing this
soon? My knowledge of Twigs internals is to weak to figure this out.—
Reply to this email directly or view it on GitHubhttps://github.com//issues/82#issuecomment-10720835.
from jmstranslationbundle.
There are no tests for this so I'm assuming its not supported.
Also looking at the https://github.com/schmittjoh/JMSTranslationBundle/blob/master/Translation/Extractor/File/TwigFileExtractor.php there is no checking for the trans_default_domain Node.
From what I can see its not hard to implement this, only edge case is when the trans_default_domain is placed after a trans block. This can be solved by pre parsing the Tree and looking for this, but this would decrease performance very badly.
So only workable is by requiring the {% trans_default_domain %} to be placed before any trans blocks.
Then this shouldn't be to hard.
from jmstranslationbundle.
Dear friends
Thanks lot for your valuable reply and hints. And I will try to fix this issue by self.
from jmstranslationbundle.
@bharatesh Does it mean your gonna provide a pull request?
from jmstranslationbundle.
Okay. Once I fix the issue. I will do that.
from jmstranslationbundle.
from jmstranslationbundle.
Come on! Please fix trans_default_domain!
from jmstranslationbundle.
I will look into it tomorrow
from jmstranslationbundle.
Twig_Error_Syntax : The function "path" does not exist in "[..]\JMSTranslationBundle\Tests\Translation\Extractor\File/Fixture/edit.html.twig" at line 8
And when I remove that one.
Twig_Error_Syntax : The function "form_enctype" does not exist in "[...]\JMSTranslationBundle\Tests\Translation\Extractor\File/Fixture/edit.html.twig" at line 8
from jmstranslationbundle.
OK, This really, really sucks!!
The Twig_NodeTraverser::traverseForVisitor() removes the parent node and there by removing the reference to the TransDefaultDomainNode and makes fixing this impossible
foreach ($node as $k => $n) {
if (false !== $n = $this->traverseForVisitor($visitor, $n)) {
//$node->setNode($k, $n);
} else {
$node->removeNode($k);
}
}
This works but (as expected) breaks a bunch of other things.
So until anyone can find solution for this I give up.
@schmittjoh Do you have any idea's ?
from jmstranslationbundle.
I might have an idea, but it requires patching Twig. Adding an set/getParent() for the Twig_Node and giving it old instance ($n) before it changed. Will test tomorrow,
from jmstranslationbundle.
Well that was an optimistic thought... I will contact Fabian about this issue later.
from jmstranslationbundle.
Hi sstok..
Sorry did not available on weekend. May I know what kind of functionality is expected from extractor, when it faces
{% trans_default_domain "app" %}
I guess it should ignore it right? Since it has nothing to do with extraction of keys. Clarify and will proceed.
from jmstranslationbundle.
I'd suggest to take a look at how Symfony processes that node. It should be possible to emulate the same behavior.
from jmstranslationbundle.
Well with Symfony 2.1 I'm not getting any errors, but that was not the point.
The 'trans_default_domain' was designed for setting the default translation domain for the entire template.
When Twig traverses the AST it walks to all the Nodes and "removes" the parent by setting a new one and there by removing the actually reference of what it was. When I remove the trans_default_domain parser for Twig it works, but fails to compile successful.
Before the trans_default_domain in the traverseForVisitor() is executed the AST is OK, after this is its changed and no longer has the reference the to the TransDefaultDomain Node.
from jmstranslationbundle.
I've had a look at this, the thing is that Symfony2 itself creates a temporary variable for the default domain, and then adds that variable to translation calls.
That behavior is ok if the translation domain is a dynamic expression, but if it is just a static string, it could easily be inlined just as if you had written that string directly in the translation call.
So, if you'd like support for this, you need to submit something to Symfony2 itself which inlines the static string into the translation call (instead of always inlining a dynamic variable). Then, extraction via this bundle will automatically work.
Thus, I'm closing this now as it needs to be fixed upstream.
from jmstranslationbundle.
Hi. Regarding fixing this issue.
I came across an if condition in JMS/TranslationBundle/Translation/Extractor/File/TwigFileExtractor.php (on line 51 as per my copy) .
if (null !== $domainNode = $node->getNode('domain')) {
$domain = $domainNode->getAttribute('value');
}
May I know why its here. Because if I use {% trans_default_domain "app" %} then above if condition executes and throws an
exception.
[LogicException]
Attribute "value" does not exist for Node "Twig_Node_Expression_Name".
since its trying to get attributes for "value" (that is not present).
And if I don't use {% trans_default_domain "app" %} then it will never executes if statement.
On removing if condition it works fine with {% trans_default_domain "app" %} . I tried to understand it but got no success in understanding its purpose.
Can any body explain.
from jmstranslationbundle.
+1
from jmstranslationbundle.
Related Issues (20)
- The format "yaml~" does not exist. HOT 2
- Requirement of nikic/php-parser does not match packgist page HOT 1
- Twig 3 support HOT 3
- Symfony 5 dependencies update HOT 4
- New major release HOT 1
- 1.5 => simplexml_load_file() expects parameter 1 to be a valid path, object given HOT 8
- ExtractTranslationCommand unlink() expects parameter 1 to be a valid path, object given HOT 1
- jms/translation-bundle (1.5.2) HOT 4
- XliffLoader depends on state of libxml_disable_entity_loader HOT 2
- strtolower() expects parameter 1 to be string, object given HOT 3
- KNP/DoctrineBehavior - Translation Entities error on translation:extract command
- Notice: Undefined property: PhpParser\Node\Expr\Closure::$items
- Support for intl-icu translation files HOT 3
- Notice: Trying to get property 'key' of non-object
- All Form Constraint options are extracted without checking if it's a message or not
- Error ArrayStructureDumper
- Command conflict with framework bundle
- Compatibility with Symfony6 HOT 5
- String interpolation deprecation notices with PHP 8.2 HOT 2
- Is this a known error ? HOT 2
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 jmstranslationbundle.