Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Position of @Desc in PHP #16

Closed
althaus opened this issue Dec 20, 2011 · 5 comments · Fixed by #76
Closed

Position of @Desc in PHP #16

althaus opened this issue Dec 20, 2011 · 5 comments · Fixed by #76

Comments

@althaus
Copy link

althaus commented Dec 20, 2011

Hey,

would it be hard to support the following positioning:

<?php
/** @Desc("Ein Nutzer mit dieser E-Mail-Adresse ist bereits als Projektmitglied eingeladen. Der Zugang wurde noch nicht vom Nutzer bestätigt.") */
$message = $this->get('translator')->trans('project.flash.member.email');
?>

This doesn't get extracted, but I would prefer to not put the annotation before the service call as this uglifies the code.

Could this be implemented or is this somehow limited by the parser?

Cheers
Matthias

@schmittjoh
Copy link
Owner

It could be implemented, but it might be a bit more complicated than the current implementation.

Feel free to write up a patch though.

@althaus
Copy link
Author

althaus commented Dec 20, 2011

Ok... I'll take a look at the code if I can spare some time.

Other things which came up:

Similar to the above the position of @desc for form labels would be nice as

<?php
'label' => 'form.field.label', /** @Desc My Label */
?>

but this prolly doesn't make much sense as the annotation would be after the element an not before?

Second one:
empty_values for choice form fields could be extracted as these can be fed with strings.

@schmittjoh
Copy link
Owner

Could you open a separate issue for the choice values possibly with an
example?

On Tue, Dec 20, 2011 at 6:10 PM, Matthias Althaus <
reply@reply.github.com

wrote:

Ok... I'll take a look at the code if I can spare some time.

Other things which came up:

Similar to the above the position of @desc for form labels would be nice as

<?php
'label' => 'form.field.label', /** @Desc My Label */
?>

but this prolly doesn't make much sense as the annotation would be after
the element an not before?

Second one:
empty_values for choice form fields could be extracted as these can be
fed with strings.


Reply to this email directly or view it on GitHub:

#16 (comment)

@althaus
Copy link
Author

althaus commented Dec 20, 2011

Could you open a separate issue for the choice values possibly with an example?

Created #17 for this.

@mvrhov
Copy link
Contributor

mvrhov commented Jan 7, 2012

I've also bumped on this today. And did a failing testcase first as I thought it's a bug. Here is the diff for it.

--- a/lib/vendor/bundles/JMS/TranslationBundle/Tests/Translation/Extractor/File/DefaultPhpFileExtractorTest.php
+++ b/lib/vendor/bundles/JMS/TranslationBundle/Tests/Translation/Extractor/File/DefaultPhpFileExtractorTest.php
@@ -58,6 +58,11 @@ class DefaultPhpFileExtractorTest extends BasePhpFileExtractorTest
         $message->addSource(new FileSource($path, 76));
         $expected->add($message);

+        $message = new Message('text.var.assign');
+        $message->setDesc('The var %foo% should be assigned.');
+        $message->addSource(new FileSource($path, 82));
+        $expected->add($message);
+
         $this->assertEquals($expected, $catalogue);
     }
--- a/lib/vendor/bundles/JMS/TranslationBundle/Tests/Translation/Extractor/File/Fixture/Controller.php
+++ b/lib/vendor/bundles/JMS/TranslationBundle/Tests/Translation/Extractor/File/Fixture/Controller.php
@@ -75,4 +75,10 @@ class Controller
     {
         $arr['foo']->trans('text.array_method_call');
     }
-}
\ No newline at end of file
+
+    public function assignToVar()
+    {
+        /** @Desc("The var %foo% should be assigned.") */
+        $err = $this->translator->trans('text.var.assign', array('%foo%' => 'fooVar'));
+    }
+}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants