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

JMS Translation Bundle does not extract keys from controllers in Symfony2 - getTranslationMessages() #239

Closed
crauliuc opened this issue May 8, 2015 · 5 comments

Comments

@crauliuc
Copy link

crauliuc commented May 8, 2015

I am using JMS Translation Bundle in my Symfony 2 project.

All translations in the twig files are working great. If I write new keys that need to be translated and run the extract command from command line they get extracted and I can then set appropriate values.

My question is this: I have some messages / keys in the Symfony2 controllers that need to be first extracted and then translated by me. I am writing them like this:

$translator = $this->get('translator');
$message = $translator->trans('FavTrans.No_trans_found');
When I run the extract command now the new translation key doesn't get created and I can't edit it or add translation to it. The command that I run is below.

php app/console translation:extract en ro fr --dir=./src/Smart/Bundle/AdminBundle/Controller/ --output-dir=./app/Resources/translations --output-format=xliff --domain=SmartAdminBundle --keep

Can anyone help? Either telling me that my extract command is wrong, or am I doing the translation in the controller in an unapropriate way?

@ghost
Copy link

ghost commented Nov 10, 2015

same here....

@vikbert
Copy link

vikbert commented May 24, 2016

maybe you should set translation domain to your translation which you used in controller.
$translator->trans('FavTrans.No_trans_found', array(), 'your_translation_domain');

then extract via JMS all translations, generally you should get a new translation file generated named "your_translation_domain.xliff"(if export format .xliff used)

@Nyholm
Copy link
Collaborator

Nyholm commented Aug 4, 2016

Im closing this because of inactivity. Feel free to reopen this or create a new issue.

@Nyholm Nyholm closed this as completed Aug 4, 2016
@JuliusKoronci
Copy link

Just run into this issue..you need the domain in the controller $this->get('translator.default')->trans('trans.key',[],'messages')

@rileyrg
Copy link

rileyrg commented Jun 28, 2017

I dont suippose anyone here knows how to extract from a mysql database? eg eyecolor.name : varchar(30) might hold, for instance, "colour.red". I dont want JSM removing all my colour.* codes in the xlf files I hand created when I do an extract - "keep" option isnt good enough as that leaves old unused codes around. How can I tag an xlf file so extract does NOT empty it if there are no codes in the twig/controllers?

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

No branches or pull requests

5 participants