Documentation: Resources/doc
Code License: Resources/meta/LICENSE
Documentation License: Resources/doc/LICENSE
Puts the Symfony2 Translation Component on steroids
Home Page: http://jmsyst.com/bundles/JMSTranslationBundle
Documentation: Resources/doc
Code License: Resources/meta/LICENSE
Documentation License: Resources/doc/LICENSE
Hello all,
After struggling few hours with the bundle I get this error and don't know how to solve or what do I have to check.
Any idea ?
I followed the instructions on Installation: AOP DI Metadata Installed.
You have requested a non-existent service "config_factory".
in kernel.root_dir/bootstrap.php.cache at line 202
}
if (self::EXCEPTION_ON_INVALID_REFERENCE === $invalidBehavior) {
throw new ServiceNotFoundException($id);
}
}
at Container ->get ('config_factory', '1')
in kernel.root_dir/cache/dev/jms_diextra/controller_injectors/JMSTranslationBundleControllerTranslateController.php at line 19
at TranslateController__JMSInjector ::inject (object(appDevDebugProjectContainer))
at call_user_func (array('JMS\TranslationBundle\Controller\TranslateController__JMSInjector', 'inject'), object(appDevDebugProjectContainer))
in kernel.root_dir/cache/dev/classes.php at line 9358
at ControllerResolver ->createController ('JMS\TranslationBundle\Controller\TranslateController::indexAction')
in kernel.root_dir/cache/dev/classes.php at line 4084
at ControllerResolver ->getController (object(Request))
in kernel.root_dir/cache/dev/classes.php at line 3895
at HttpKernel ->handleRaw (object(Request), '1')
in kernel.root_dir/cache/dev/classes.php at line 3875
at HttpKernel ->handle (object(Request), '1', true)
in kernel.root_dir/cache/dev/classes.php at line 4852
Ty
When i define 2 uses of a key on the same file, depending on the order of the annotation Desc
a <target>
will not be translated.
Considering always the same file and different methods:
If used on this order:
class Test extends Controller
{
public function firstAction() {
throw $this->createNotFoundException(
$this->get('translator')->trans('a.message')
);
}
public function secondAction() {
throw $this->createNotFoundException(
/** @Desc("The Message Description.") */
$this->get('translator')->trans('a.message')
);
}
}
After export i will get this:
<trans-unit resname="a.message">
<source>The Message Description.</source>
<target state="new">The Message Description.</target>
</trans-unit>
But, if used on this order:
class Test extends Controller
{
public function firstAction() {
throw $this->createNotFoundException(
/** @Desc("The Message Description.") */
$this->get('translator')->trans('a.message')
);
}
public function secondAction() {
throw $this->createNotFoundException(
$this->get('translator')->trans('a.message')
);
}
}
Then, after export i will get this:
<trans-unit resname="a.message">
<source>The Message Description.</source>
<target state="new">a.message</target>
</trans-unit>
The expected behavior would be to use the one time defined (@Desc
), ignoring if it was used again but not defined, correct?
If use different @Desc
for each key, i will get the expected RuntimeException
during the export execution.
The generated yml files have invalid comments for translations with line breaks.
example:
# Desc: Lorem ipsum dolor sit amet,
consectetur adipisici elit, sed eiusmod tempor incidunt ut labore
et dolore magna aliqua.
description: "Lorem ipsum dolor sit amet, \nconsectetur adipisici elit, sed eiusmod tempor incidunt ut labore \net dolore magna aliqua." # FIXME
This breaks the yml file.
Is there by the way a option to disable the creation of these comments?
the ordering on xliff entries should be explicitly made non OS specific so that there should not be git merge conflicts
could you please take a PR or suggest the best way on this?
thanks
someone mentioned this http://www.php.net/manual/en/function.strcasecmp.php#107016
instead of this https://github.com/schmittjoh/JMSTranslationBundle/blob/master/Model/MessageCollection.php#L107
from https://github.com/schmittjoh/JMSTranslationBundle/blob/master/Translation/FileWriter.php#L57-60
This is the scenario: I have a base class and and extending class to define an Person -> Employee using the Mapped Superclasse strategy (http://docs.doctrine-project.org/en/2.0.x/reference/inheritance-mapping.html#mapped-superclasses).
An example code:
// Acme\GeneralBundle\Entity\Person.php
/** @ORM\MappedSuperclass */
abstract class Person {
/**
* @ORM\Column(type="string")
* @Assert\NotBlank(message = "person.name.empty")
*/
protected $name;
}
// Acme\CompanyBundle\Entity\Employee.php
/** @ORM\Entity() */
class Employee extends Person {
/**
* @ORM\Column(type="string")
* @Assert\NotBlank(message = "employee.sector.empty")
*/
protected $sector;
}
The problem:
If extract the translation messages separately (by bundles) i end up with a duplicated person.name.empty
, one at each bundle.
So, executing:
translation:extract en -b AcmeGeneralBundleBundle
translation:extract en -b AcmeCompanyBundleBundle
Will generate:
<!-- Acme\GeneralBundle\Resources\translations\validators.en.xliff -->
<body>
<trans-unit id="..." resname="person.name.empty">
<source>person.name.empty</source>
<target state="new">person.name.empty</target>
</trans-unit>
</body>
<!-- Acme\CompanyBundle\Resources\translations\validators.en.xliff -->
<body>
<trans-unit id="..." resname="person.name.empty">
<source>person.name.empty</source>
<target state="new">person.name.empty</target>
</trans-unit>
<trans-unit id="..." resname="employee.sector.empty">
<source>employee.sector.empty</source>
<target state="new">employee.sector.empty</target>
</trans-unit>
</body>
If i extract all the messages at one pass (not by bundle, translation:extract en --dir=./src/ --output-dir=./app/Resources/translations
) it will not duplicate, but all the messages will end up in the same place, but this is a horrible mess.
It's important remember that Symfony (as of 2.1.3) resolves the hierarchy and if i delete the duplicated entry at Acme\CompanyBundle
it will get the correct message from Acme\GeneralBundle
.
The twig code below:
{% set message = 'resetting.request.invalid_username'|trans({'%username%': invalid_username})|desc("The account with email address "%username%" does not exist.") %}
produces next php code.
$context["message"] = ((($this->env->getExtension('translator')->trans("resetting.request.invalid_username", array()) == "resetting.request.invalid_username")) ? (strtr((("The account with email address " % $this->getContext($context, "username")) % " does not exist."), array("%username%" => $this->getContext($context, "invalid_username")))) : ($this->env->getExtension('translator')->trans("resetting.request.invalid_username", array("%username%" => $this->getContext($context, "invalid_username")))));
Which is clearly wrong. The $this->getContext($context, "username"))
in the middle of strtr call is totally redundant.
This results in Variable "username" does not exist in foot.html.twig at line 12
being thrown by twig.
I'm running twig 1.10 and this bundle from master.
Right now it seems like we have an inconsistent state.
The method all() is still used in the Updater but not present anymore in the MessageCatalogue
In XliffDumper Message->getMeaning() returns NULL and Message->getDesc() returns the id to be translated.
Tested with fresh project and latest sources.
Test twig template:
{{ "demo.test" | trans | desc("desc.test") | meaning("meaning.test") }}
Value of Message->getDesc() is demo.test
Expected:
Message->getDesc() => desc.test
Message->getMeaning() => meaning.test
Hi,
if you have ever seen the Facebook translation tool (http://www.facebook.com/?sk=translations), you can get an idea of what I mean:
To give an example, we have the message
{user} wrote on {friend}'s wall for his birthday
The variable {user} can be a string that can be of any gender/number (in English this doesn't matter for the translation, but in Italian I would translate the verb differently), and depending on {friend}'s gender the message could be adjusted (his birthday/her birthday in English, doesn't matter in Italian).
I'm still thinking of what could be the best strategy to deal with this, but it's clear that this should be done at translation-time because it's very specific for each language in which you are going to translate the message.
One possible implementation is with filters (see https://github.com/ai/r18n).
It's also clear that right now current symfony's translations have a real minimalistic approach and is not even able to deal with messages that depends on more that one variable (Eg. There are {n} apples on {n} trees).
Any suggestion is welcome
Hi,
sorry to bother you again here, but I'm in a kind of a hurry. :|
I've implemented your bundle and after stumbling upon a minor issue [1], I've got a more severe one. I'm using Twig and added the desc filter to my templates. It's working as I'd expect it in the on-the-fly dev environment, but it's not using the value of the desc parameter at all when I extract the translation. O_O
My config:
jms_translation:
configs:
app:
dirs: [%kernel.root_dir%, %kernel.root_dir%/../src]
output_dir: %kernel.root_dir%/Resources/translations
output_format: yml
excluded_names: [*TestCase.php, *Test.php]
excluded_dirs: [cache, data, logs]
Example from Twig:
{{ 'button.delete'|trans|desc('Löschen') }}
The dumped YAML file just contains:
button:
add: button.add # FIXME
cancel: button.cancel # FIXME
delete: button.delete # FIXME
I also tried a XLIFF dump and the source nodes are also not filled correctly. :(
I'll buy you a beer or two, if you ever come to Braunschweig. :D
Cheers
Matthias
[1] https://groups.google.com/forum/#!topic/symfony2/3a1WCZYK9Us
The twig translation code:
{{ 'Email to %email%'|trans('%email%': email) }}
The error:
[Twig_Error_Syntax]
Arguments must be separated by a comma. Unexpected token "punctuation" of value ":" ("punctuation" expected with value ",")....
xliff entries ids are currently numbered with an increasing index 1, 2, 3, 4, etc
could this be changed to unique ids with sha1 or md5 algorithms?
would you take a PR on this? i hope you don't ignore me, thanks
If anybody know how to force translator to look in to a particular directory. For example
I have two folders in
app/Resources/translations/shoppingcart
app/Resources/translations/startpage
I want to force translator to look into specific folder. At present it looks only at translations folder and catches first hit.
Any hint or suggestions is most welcome.
Hello, the tags for the jms_translation.loader.xliff_loader and jms_translation.dumper.xliff_dumper services need to be changed to xlf from the current xliff in order to accomodate the symfony master change that switched from xliff to xlf.
when tagging custom extractor class i get:
Custom Extractors: main.translation_extractor
but something is wrong when registering a service and tagging it with - { name: jms_translation.file_visitor }
when i run containerebug it shows up
but when i try to run it through the cli php app/console translations:extract -app en --enable-extractor=alias
it gives the exception:
[JMS\TranslationBundle\Exception\InvalidArgumentException]
There is no extractor with alias "main.translation_extractor". Available extractors: # none #
but right before it said Custom Extractors: main.translation_extractor
so it does not make sense
please thanks add some info how you run the phpunits
Hi,
I managed to setup JMSTranslationBundle version 1.0.0-DEV with symfony 2.0.12.
I tried extracting content for translation in XLIFF format. This content has to be translated with SDL Trados.
At the moment, JMS includes <jms:reference-file>
elements at the very beginning of every <trans-unit>
element. But the thing is that XLIFF 1.2 specs define that the elements inside a <trans-unit>
should be in a specific order:
One
<source>
element, followed by
Zero or one<seg-source>
element, followed by
Zero or one<target>
element, followed by
Zero, one or more<context-group>
,<count-group>
,<prop-group>
,<note>
,<alt-trans>
elements, in any order, followed by
Zero, one or more non-XLIFF elements.All child elements of
<trans-unit>
pertain to their sibling<source>
element.
While for backward compatibility reasons no order is enforced for the elements before the non-XLIFF elements, the recommended order is the one in which they are listed here.
In other words, placing <jms:reference-file>
elements at the end of trans-units should make XLIFF files compatible with computer-aided translation tools like SDL Trados.
Another common issue is that CAT tools like Trados want that source-language and target-language file attributes bear the full language-country attribute rather than a single language attribute.
For more information on XLIFF spec, see http://docs.oasis-open.org/xliff/v1.2/os/xliff-core.html#trans-unit
Thanks for your hard work :-)
First of all thanks a lot for those all developers who contributed to build this great tool. Very powerful and works like a charm.
Now my Question 1 is:
in config.yml I defined following configurations
shoppingcart:
dirs: [%kernel.root_dir%/../src/MyDays/testBundle/Resources/views/ShoppingCart, %kernel.root_dir%/../src/MyDays/extendedBundle/Resources/views/ShoppingCart]
output_dir: %kernel.root_dir%/Resources/translations/shoppingcart
ignored_domains: [messages]
domains: [shoppingcart]
excluded_names: [*TestCase.php, *Test.php]
excluded_dirs: [cache, data, logs]
#extractors: [alias_of_the_extractor]
keep: Yes
I accept that now translation messages to be available in shoppingcart.en.xlif on using below command
php app/console translation:extract de --config=shoppingcart
Command executes normally but fail to generate xlif file. If any body know any solution or hints.
Thanks in advance.
Question2:
if I comment out
It will give an error of alias_of_the_etractor is not found. Please give me some hint here as well.
Hi,
I'm trying to extract messages with JMSTranslationBundle in standalone and also in conjunction with JMSI18nRoutingBundle.
The whole process works (I effectively get the generated files) except that when I try to limit the extraction to one single bundle I always get the messages from all bundles.
I tried :
app/console translation:extract fr --enable-extractor=jms_i18n_routing --bundle=MSWUserBundle
and even :
app/console translation:extract fr --enable-extractor=jms_i18n_routing --bundle=MSWUserBundle --dir=./src/MSW/UserBundle/
and still have the messages from all my other bundles (MSWCoreBundle at the moment) in the .yml generated files (so that each message from one bundle is duplicated in each other).
On my routing file for this bundle, I don't have any reference to other bundles (I only have references to FOSUserBundle like :
fos_user_security:
resource: "@FOSUserBundle/Resources/config/routing/security.xml"
But in my app/config/routing.yml of course I have :
CoreBundle:
resource: "@MSWCoreBundle/Resources/config/routing.yml"
UserBundle:
resource: "@MSWUserBundle/Resources/config/routing.yml"
So it seems that your extract command grabs all the messages from ALL the bundles (going back up to app/config/routing.yml) and then put all the messages to the bundle translation files (specified with --bundle= parameter), by ignoring the --dir=... parameter of the command that is supposed to limit the message extraction scope to one single bundle directory recursively, according to your documentation.
Any idea ? How I grab the messages only for one bundle then ?
Many thanks ;-)
FileExtractor creates a new PHPParser_Parser object, but does not give any argument to its constructor, when PHPParser_Parser expects an object of type PHPParser_Lexer.
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
Hi,
I'm having an issue running the extractor command line :
php app/console translation:extract ar_IQ --config=routing --output-format=xliff
(or on any other country )
I get the following error :
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate 32 bytes) in /Users/.../www/vendor/symfony/src/Symfony/Component/Routing/Loader/AnnotationFileLoader.php on line 94
I created my custom extractor but i have the same problem with the original jms_i18n_routing .
And when i try to do the same thing in my website using services :
$cf = $this->container->get("jms_translation.config_factory");
$updater = $this->container->get("jms_translation.updater");
$config = $cf->getConfig('routing',$entity->getLocale());
$updater->process($config);
I have the following error :
Fatal error: Maximum execution time of 30 seconds exceeded in /Users/.../www/vendor/doctrine-common/lib/Doctrine/Common/Annotations/PhpParser.php on line 137
I don't know what it is due to ...
My routes translation files are generated in app/Resources/translations/ folder with 777 permissions
Here is the config i use in my config.yml :
jms_translation:
configs:
routing:
dirs: [%kernel.root_dir%, %kernel.root_dir%/../src]
output_dir: %kernel.root_dir%/Resources/translations
domain: [routes]
excluded_names: [*TestCase.php, *Test.php]
excluded_dirs: [cache, logs]
extractors: [by_i18n_routing]
Here is my deps file :
[symfony]
git=git://github.com/symfony/symfony.git
version=v2.0.15
[twig]
git=git://github.com/fabpot/Twig.git
version=v1.8.2
[monolog]
git=git://github.com/Seldaek/monolog.git
version=1.0.2
[doctrine-common]
git=git://github.com/doctrine/common.git
version=2.1.4
[doctrine-dbal]
git=git://github.com/doctrine/dbal.git
version=2.1.7
[doctrine]
git=git://github.com/doctrine/doctrine2.git
version=2.1.7
[swiftmailer]
git=git://github.com/swiftmailer/swiftmailer.git
version=v4.1.7
[assetic]
git=git://github.com/kriswallsmith/assetic.git
version=v1.0.3
[twig-extensions]
git=git://github.com/fabpot/Twig-extensions.git
[SensioFrameworkExtraBundle]
git=git://github.com/sensio/SensioFrameworkExtraBundle.git
target=/bundles/Sensio/Bundle/FrameworkExtraBundle
version=origin/2.0
[JMSSecurityExtraBundle]
git=git://github.com/schmittjoh/JMSSecurityExtraBundle.git
target=/bundles/JMS/SecurityExtraBundle
version=origin/1.0.x
[SensioDistributionBundle]
git=git://github.com/sensio/SensioDistributionBundle.git
target=/bundles/Sensio/Bundle/DistributionBundle
version=origin/2.0
[SensioGeneratorBundle]
git=git://github.com/sensio/SensioGeneratorBundle.git
target=/bundles/Sensio/Bundle/GeneratorBundle
version=origin/2.0
[AsseticBundle]
git=git://github.com/symfony/AsseticBundle.git
target=/bundles/Symfony/Bundle/AsseticBundle
version=v1.0.1
[JMSI18nRoutingBundle]
git=git://github.com/schmittjoh/JMSI18nRoutingBundle.git
target=bundles/JMS/I18nRoutingBundle
[JMSTranslationBundle]
git=git://github.com/schmittjoh/JMSTranslationBundle.git
target=bundles/JMS/TranslationBundle
[php-parser]
git=git://github.com/nikic/PHP-Parser.git
version=v0.9.1
[JMSDiExtraBundle]
git=git://github.com/schmittjoh/JMSDiExtraBundle.git
target=bundles/JMS/DiExtraBundle
version=1.0.0
[JMSAopBundle]
git=git://github.com/schmittjoh/JMSAopBundle.git
target=bundles/JMS/AopBundle
[metadata]
git=git://github.com/schmittjoh/metadata.git
version=1.1.0
[cg-library]
git=git://github.com/schmittjoh/cg-library.git
[n3bStreamresponse]
git=https://github.com/liuggio/Symfony2-StreamResponse.git
target=n3b/src/n3b/Bundle/Util/HttpFoundation/StreamResponse
[phpExcel]
git=https://github.com/liuggio/PHPExcel.git
target=phpexcel
[liuggioExcelBundle]
git=http://github.com/liuggio/ExcelBundle.git
target=/bundles/liuggio/ExcelBundle
[doctrine-migrations]
git=http://github.com/doctrine/migrations.git
[DoctrineMigrationsBundle]
git=http://github.com/doctrine/DoctrineMigrationsBundle.git
target=/bundles/Symfony/Bundle/DoctrineMigrationsBundle
version=origin/2.0
[BazingaFakerBundle]
git=git://github.com/willdurand/BazingaFakerBundle.git
target=bundles/Bazinga/Bundle/FakerBundle
[Faker]
git=git://github.com/fzaninotto/Faker.git
target=faker
[KnpMenu]
git=git://github.com/KnpLabs/KnpMenu.git
[KnpMenuBundle]
git=git://github.com/KnpLabs/KnpMenuBundle.git
target=bundles/Knp/Bundle/MenuBundle
[FOSJsRoutingBundle]
git=git://github.com/FriendsOfSymfony/FOSJsRoutingBundle.git
target=/bundles/FOS/JsRoutingBundle
[gedmo-doctrine-extensions]
git=git://github.com/l3pp4rd/DoctrineExtensions.git
target=gedmo-doctrine-extensions
[DoctrineExtensionsBundle]
git=git://github.com/stof/StofDoctrineExtensionsBundle.git
target=bundles/Stof/DoctrineExtensionsBundle
Thanks a lot for your help ... if you have any question, tell me !
Ghislain
I have no message in the default "message" domaine.
When i use the translator UI, i've got an error on ajax update query:
There is no domain with name "messages".
Bug fix:
In Translation/Updater.php in updateTranslation()
use ->get($id, $domain) instead of ->get($id)
Hello,
I've tried to run the tests in order to fix the bug in using the CDATA node type for the translations but all I got is:
I've ran this against Symfony2 master but when looking at the 2.0 branch I've noticed that the IcuResFileLoader isn't there as well.
Please advise
PHPUnit 3.6.5 by Sebastian Bergmann.
Configuration read from /var/www/pizokel/vendor/bundles/JMS/TranslationBundle/phpunit.xml
Fatal error: Class 'Symfony\Component\Translation\Loader\IcuResFileLoader' not found in /tmp/JMSTranslationBundle/FunctionalTestDebugProjectContainer.php on line 1549
Call Stack:
0.0002 639024 1. {main}() /usr/bin/phpunit:0
0.0047 1250864 2. PHPUnit_TextUI_Command::main() /usr/bin/phpunit:44
0.0047 1251736 3. PHPUnit_TextUI_Command->run() /usr/share/php/PHPUnit/TextUI/Command.php:125
0.1485 11672856 4. PHPUnit_TextUI_TestRunner->doRun() /usr/share/php/PHPUnit/TextUI/Command.php:187
0.1526 12233856 5. PHPUnit_Framework_TestSuite->run() /usr/share/php/PHPUnit/TextUI/TestRunner.php:325
0.1527 12238184 6. PHPUnit_Framework_TestSuite->run() /usr/share/php/PHPUnit/Framework/TestSuite.php:705
0.1527 12238920 7. PHPUnit_Framework_TestSuite->runTest() /usr/share/php/PHPUnit/Framework/TestSuite.php:745
0.1527 12238920 8. PHPUnit_Framework_TestCase->run() /usr/share/php/PHPUnit/Framework/TestSuite.php:772
0.1528 12238920 9. PHPUnit_Framework_TestResult->run() /usr/share/php/PHPUnit/Framework/TestCase.php:748
0.1538 12340000 10. PHPUnit_Framework_TestCase->runBare() /usr/share/php/PHPUnit/Framework/TestResult.php:649
0.1539 12380952 11. PHPUnit_Framework_TestCase->runTest() /usr/share/php/PHPUnit/Framework/TestCase.php:801
0.1540 12383104 12. ReflectionMethod->invokeArgs() /usr/share/php/PHPUnit/Framework/TestCase.php:939
0.1540 12383160 13. JMS\TranslationBundle\Tests\Functional\ExtractCommandTest->testExtract() /usr/share/php/PHPUnit/Framework/TestCase.php:939
0.1877 16071568 14. Symfony\Component\Console\Application->run() /var/www/pizokel/vendor/bundles/JMS/TranslationBundle/Tests/Functional/ExtractCommandTest.php:54
0.1877 16071568 15. Symfony\Bundle\FrameworkBundle\Console\Application->doRun() /var/www/pizokel/vendor/symfony/src/Symfony/Component/Console/Application.php:106
0.2054 17832072 16. Symfony\Component\Console\Application->doRun() /var/www/pizokel/vendor/symfony/src/Symfony/Bundle/FrameworkBundle/Console/Application.php:77
0.2064 17832072 17. Symfony\Component\Console\Command\Command->run() /var/www/pizokel/vendor/symfony/src/Symfony/Component/Console/Application.php:193
0.2070 17835120 18. JMS\TranslationBundle\Command\ExtractTranslationCommand->execute() /var/www/pizokel/vendor/symfony/src/Symfony/Component/Console/Command/Command.php:237
0.2088 17981120 19. Symfony\Component\DependencyInjection\Container->get() /var/www/pizokel/vendor/bundles/JMS/TranslationBundle/Command/ExtractTranslationCommand.php:79
0.2088 17981744 20. FunctionalTestDebugProjectContainer->getJmsTranslation_UpdaterService() /var/www/pizokel/vendor/symfony/src/Symfony/Component/DependencyInjection/Container.php:253
0.2357 20789688 21. Symfony\Component\DependencyInjection\Container->get() /tmp/JMSTranslationBundle/FunctionalTestDebugProjectContainer.php:732
0.2357 20790328 22. FunctionalTestDebugProjectContainer->getJmsTranslation_LoaderManagerService() /var/www/pizokel/vendor/symfony/src/Symfony/Component/DependencyInjection/Container.php:253
0.2400 21137776 23. Symfony\Component\DependencyInjection\Container->get() /tmp/JMSTranslationBundle/FunctionalTestDebugProjectContainer.php:696
0.2400 21138400 24. FunctionalTestDebugProjectContainer->getTranslation_Loader_ResService() /var/www/pizokel/vendor/symfony/src/Symfony/Component/DependencyInjection/Container.php:253
Hi,
Maybe I'm wrong but it looks like the extract method doesn't look for the translation_domain.
Here what I did
$builder->add ( 'email', 'email', array('label' => 'Email', 'translation_domain' => 'bo') );
The Email tag is written in the messages.fr.xliff instead of bo.fr.xliff
Thank you
This bundle is a godsend.
Any plans to implement inline editing via https://github.com/tuupola/jquery_jeditable or similar? This would drastically simplify the translation process.
Is there a way to translate messages from validation.yml file ? ( http://symfony.com/doc/current/book/validation.html#getters )
For example constraint:
Domeny\CertyfikatyBundle\Model\CMS\NewsComment:
properties:
name:
- NotNull: { message: "Należy podać imię i nazwisko" }
is not visible in any of translation files. Am I doing something wrong ?
You can set the caption for the empty value element in select boxes generated by choice/entity form field types by just setting it to a string:
<?php
$builder->add('states', 'choice', array(
'empty_value' => 'Choose an option',
));
This could be extracted by the bundle.
Be aware: empty_values
can also be set to FALSE
so that no option is generated at all. Possible solution would be to force the user to use @Ignore
or to automatically check for the boolean value.
<?php
$builder->add('states', 'choice', array(
'empty_value' => false,
));
Doc: http://symfony.com/doc/2.0/reference/forms/types/choice.html#empty-value
Cheers
Matthias
I found a use case where having PHPDoc before trans doesn't work,. This seems to be a bug in the php-parser component.
Having the code below the none of the nodes contain that phpdoc.
$this->translator
/** @Desc("Translation between") */
->trans('text.between', array(), 'baz');
According to the component change log the whole comment stuff was revamped in 0.9.2 so this should be looked when upgrading. If it still won't work, then the component still doesn't handle this case.
When I try the export to translation files:
php app/console translation:extract fr --dir=./src/ --output-dir=./app/Resources/translations
[ErrorException]
Catchable Fatal Error: Argument 1 passed to PHPParser_Parser::__construct() must be an instance of PHPParser_Lexer, none given, called in /applocation/vendor/bundles/JMS/TranslationBundle/Translation/Extractor/FileExtractor.php on line 56 and defined in /applocation/vendor/php-parser/lib/PHPParser/Parser.php line 903
I got the following message:
[ErrorException]
Catchable Fatal Error: Argument 1 passed to PHPParser_Parser::__construct() must be an instance of PHPParser_Lexer, none given, called in /home/oc/www/dev/vendor/bundles/JMS/TranslationBundle/Translation/Extractor/FileExtractor.php on line 56 and defined in /home/oc/www/dev/vendor/php-parser/lib/PHPParser/Parser.php line 903
when executing this command:
app/console translation:extract en --enable-extractor=jms_i18n_routing --dir=./src/ --output-dir=./app/Resources/translations
I installed this bundle using deps file.
What do you thing about use the "framework.session.cookie_domain" to store the "hl" cookie?
Or offer the possibility to set this value in config .yml in "jms_i18n_routing" part
When executing the translation:extract command (e.g. translation:extract de --bundle=AcmeDemoBundle) the target is not translated, but the same as the source.
Hey Johannes,
I've stumbled once again over one of your great bundles and gave it a try. I've now got an issue with the extraction of form labels. I've got a form with n checkboxes where each checkbox gets its not-to-translate label from the database.
The extractor now complains that the label is no string. How/Where do I need to add the ignore annotation? It's not mentioned in the doc and a couple of tries didn't work out.
Cheers
Matthias
I'm using Symfony master and I need the WebUI. It worked so far without any problems, but now
I get this RuntimeException: Cannot dump definitions which have method calls. If I remove the jms_translation from configuration, it works fine, but I have no webUI.
Update: it doesn't work anyway when JMSTranslationBundle is on.
After installing the bundle I reveive teh following exception:
The service "jms_translation.updater" has a dependency on a non-existent service "translation.loader".
Can you help me what could be the reason and how to solve it?
The repeated field type, doesn't use the standard "label" property, because it has two labels.
Those two labels are inside 'options' and 'second_options'.
Also there is the 'invalid_message' that should be translatable too.
<?php
$builder->add('password', 'repeated', array(
'type' => 'password',
'invalid_message' => 'password-do-not-match',
'first_options' => array('label' => 'password'),
'second_options' => array('label' => 'repeat-password')
));
Doc: http://symfony.com/doc/current/reference/forms/types/repeated.html
Cheers
Alberto
According to the example in the readme file the descfilter should work with transchoice.
However, this is not working. One problem lays in file DefaultApplyingNodeVisitor:51 where the code only tests for 'trans' which results in the runtime exception in line 56 beeing thrown.
However, just allowing 'transchoice' in line 51 as well does not solve the issue as after that any call to the template results in an Exception: 'An exception has been thrown during the rendering of a template ("Unable to choose a translation.")'
I think there is some additional handling required for injecting the translation into the nodes in the transchoice case.
The used example code:
{% set count = 0 %}
{{ "text.apples_remaining"|transchoice(count)|desc("{0} There is no apple|{1} There is one apple|]1,Inf] There are %count% apples") }}
The extract command should be able to produce a compatible symfony2 xliff format. So this bundle is not mandatory to use the xliff file.
The translator / extractor chokes on numerical IDs. The steps to replicate this are quite simple:
Have a file that has a numerical translation key, ie. in a Twig template: {{ 1 | trans }}
Run the translation:extract
command with --output-format=yml
In the messages file a new line like 1: '1' # FIXME
will be added
...everything fine so far
Now run the extraction again, and this time the command will throw an exception:
[JMS\TranslationBundle\Exception\RuntimeException]
You can only merge messages with the same id. Expected id "1", but got "1".
While translating numbers seems quite silly, the problem is that the whole extraction process goes awry.
The issue is caused by this part in Model/Message.php
:
public function mergeExisting(Message $message)
{
if ($this->id !== $message->getId()) {
throw new RuntimeException(sprintf('You can only merge messages with the same id. Expected id "%s", but got "%s".', $this->id, $message->getId()));
}
....
The extracted message's ID ($this->id
) is a String
, while the existing message's ID ($message->getId()
) is an int
. Now, the obvious fix would be just use !=
to compare, but this may very well have other implications.
The default output for the commands are different, i don't see a reason for this.
Verification:
The command php app/console translation:update --help
outputs:
--output-format Override the default output format (default: "yml")
The command php app/console translation:extract --help
outputs:
--default-output-format The default output format (defaults to xliff).
Hey again,
I just stumbled upon a bug again. We had some issues on deploying to my customers server so that I wrote a small debug script for testing their mail server. I made a simple MailType for wrting mails, which doesn't need translation.
So I marked the form field labels to be ignored by the extraction:
<?php
$builder
->add('to', 'email', array(
'label' => /** @Ignore */ 'An',
'attr' => array('class' => 'medium')
))
;
Nevertheless the label gets extracted by the console command and added to my messages.de.yml
:
An: An # FIXME
This shouldn't happen? The @Ignore
works fine in all other (more complex) situations.
Cheers
Matthias
Am I wrong or Symfony 2.1 has FormBuilderInterface instead of FormBuilder?
You should look for FormBuilderInterface too and keep FormBuilder for compatibility..
Cheers
Alberto
Can you give me an example of how to use this annotation?
I have a line of code that brings a "PHPParser_Node_Expr_MethodCall" when running the extract algorithm and don't how exactly how to use this annotation:
use JMS\TranslationBundle\Annotation\Ignore;
class MyController extends Controller
{
public function someAction() {
/**
* @Ignore
*/
$sheet->setCellValue("E".($i+2),$this->get('translator')->trans($issue->getType()));
}
On the generated xliff file of an extract, the source-language is always source-language="en"
.
I'm developing my app in pt_BR (so it should be the source-language, right?), my config.yml:
framework:
default_locale: pt_BR
translator: { fallback: pt_BR }
So, if i extract using:
php app/console translation:extract pt_BR
php app/console translation:extract fr
php app/console translation:extract en
I get respectively (example):
<file date="2012-11-08T15:11:54Z" source-language="en" target-language="pt_BR" datatype="plaintext" original="not.available">
<file date="2012-11-08T15:26:38Z" source-language="en" target-language="fr" datatype="plaintext" original="not.available">
<file date="2012-11-08T15:26:43Z" source-language="en" target-language="en" datatype="plaintext" original="not.available">
So, 2 points:
source-language
, there should be an target-language
(as in the en example)?I believe that there should be a new configuration parameter, as nor default_locale
or fallback
have the meaning for a "Strings are in X locale".
As each bundle can be written in different "source-languages" maybe the option should be defined when the extraction happens?
Hi,
I'm trying to set up web ui. I've followed description and installed all required bundles, but when I'm trying to run bin/vendors install I receive error:
Fatal error: Call to undefined method Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition::setInfo() in /media/projects/vendor/bundles/JMS/DiExtraBundle/DependencyInjection/Configuration.php on line 65
If i change a translation to an empty string, the value is overwritten.
example 1:
my:
example:
key: ''
Without @desc / | desc in code / twig and the option "--keep", the result is:
my:
example:
key: my.example.key
example 2:
my:
example:
# Desc: Mein Beispiel Schlüssel
key: ''
The result is:
my:
example:
# Desc: Mein Beispiel Schlüssel
key: 'Mein Beispiel Schlüssel'
Hi,
The DI bundle seems nice enough, but it adds way more extra config than needed for this bundle to work. It would be great if you removed the dependency so that it became easier to install this bundle.
Regards,
Tarjei
Today started using the JMSTranslationBundle and got this not so helpful error.
[PHPParser_Error]
Unexpected token '.' on line 13
Exception trace:
() at [...]\vendor\nikic\php-parser\lib\PHPParser\Parser.php:1003
PHPParser_Parser->parse() at [...]\vendor\jms\translation-bundle\JMS\TranslationBundle\Translation\Extractor\FileExtractor.php:145
JMS\TranslationBundle\Translation\Extractor\FileExtractor->extract() at [...]\vendor\jms\translation-bundle\JMS\TranslationBundle\Translation\ExtractorManager.php:129
JMS\TranslationBundle\Translation\ExtractorManager->extract() at [...]\vendor\jms\translation-bundle\JMS\TranslationBundle\Translation\Updater.php:233
JMS\TranslationBundle\Translation\Updater->setConfig() at [...]\vendor\jms\translation-bundle\JMS\TranslationBundle\Translation\Updater.php:124
JMS\TranslationBundle\Translation\Updater->process() at [...]\vendor\jms\translation-bundle\JMS\TranslationBundle\Command\ExtractTranslationCommand.php:113
JMS\TranslationBundle\Command\ExtractTranslationCommand->execute() at [...]\vendor\symfony\symfony\src\Symfony\Component\Console\Command\Command.php:239
Symfony\Component\Console\Command\Command->run() at [...]\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:193
Symfony\Component\Console\Application->doRun() at [...]\vendor\symfony\symfony\src\Symfony\Bundle\FrameworkBundle\Console\Application.php:78
Symfony\Bundle\FrameworkBundle\Console\Application->doRun() at [...]\vendor\symfony\symfony\src\Symfony\Component\Console\Application.php:106
Symfony\Component\Console\Application->run() at [...]\Admin\app\console:22
I traced the error using the debugger, but it would be very helpful to include the file path that has the syntax error in the message as well.
Symfony2 translation module provides an option to set the default domains in the templates. As given in http://symfony.com/doc/current/book/translation.html
Such as {% trans_default_domain "app" %} this option is very handy. But extractor throw exception for this. Is there any way to bypass this.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.