Git Product home page Git Product logo

Comments (19)

sstok avatar sstok commented on June 23, 2024

@schmittjoh Any change of seeing this soon?

Maybe I can take a look at this tomorrow.

from jmstranslationbundle.

schmittjoh avatar schmittjoh commented on June 23, 2024

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.

sstok avatar sstok commented on June 23, 2024

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.

bharatesh avatar bharatesh commented on June 23, 2024

Dear friends

Thanks lot for your valuable reply and hints. And I will try to fix this issue by self.

from jmstranslationbundle.

sstok avatar sstok commented on June 23, 2024

@bharatesh Does it mean your gonna provide a pull request? 😄

from jmstranslationbundle.

bharatesh avatar bharatesh commented on June 23, 2024

Okay. Once I fix the issue. I will do that.

from jmstranslationbundle.

sstok avatar sstok commented on June 23, 2024

👍

from jmstranslationbundle.

antonmedv avatar antonmedv commented on June 23, 2024

Come on! Please fix trans_default_domain!

from jmstranslationbundle.

sstok avatar sstok commented on June 23, 2024

I will look into it tomorrow 😄 should be an easy fix.

from jmstranslationbundle.

sstok avatar sstok commented on June 23, 2024

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.

sstok avatar sstok commented on June 23, 2024

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.

sstok avatar sstok commented on June 23, 2024

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.

sstok avatar sstok commented on June 23, 2024

Well that was an optimistic thought... I will contact Fabian about this issue later.

from jmstranslationbundle.

bharatesh avatar bharatesh commented on June 23, 2024

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.

schmittjoh avatar schmittjoh commented on June 23, 2024

I'd suggest to take a look at how Symfony processes that node. It should be possible to emulate the same behavior.

from jmstranslationbundle.

sstok avatar sstok commented on June 23, 2024

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.

schmittjoh avatar schmittjoh commented on June 23, 2024

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.

bharatesh avatar bharatesh commented on June 23, 2024

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.

xmon avatar xmon commented on June 23, 2024

+1

from jmstranslationbundle.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.