Git Product home page Git Product logo

jmstranslationbundle's Introduction

jmstranslationbundle's People

Contributors

abm-dan avatar aeterno00 avatar alexka avatar arnaud-lb avatar artursvonda avatar azine avatar benjamin-hubert avatar bvleur avatar cdfre avatar cmfcmf avatar deguif avatar dlsniper avatar emodric avatar franmomu avatar gnat42 avatar goetas avatar jaspur avatar nonlux avatar nyholm avatar peetersdiet avatar qkdreyer avatar schmittjoh avatar skwi avatar soullivaneuh avatar sustmi avatar theratg avatar tkleinhakisa avatar vansante avatar vincentlanglet avatar vinitou avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jmstranslationbundle's Issues

Content of desc filter not dumped

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

How to use @Ignore?

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

Advanced translations depending on variables gender, number, etc...

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:

  1. The developer passes to the translation function the gender and the number of each variable, the gender and number of the subject and of the user who is seeing the message
  2. Using the translation tool, the translator is then able to specify (for his/her language) if the translation depends on the gender/number of some variable, on the gender of the subject of the sentence and/or on the gender of the user who is seeing the message.
  3. When the translator specifies this, the same message is copied (depending on the number of permutations) into several messages and he/she is now able to provide a specifc translation for each case.

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

Regarding Forcing Translator to look into a perticular directory

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.

Definition of source-language

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:

  • There should be a way to define source-language`.
  • If the extracted language is equal to the defined 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?

Translation_domain on forms

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

One case where @Desc before doesn't work

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.

Translation.loader dependency

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?

Example of JMS\TranslationBundle\Annotation\Ignore

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()));

}

WebUI: Update fail without domain "message" (Bug fix include)

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)

Can't run tests

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

Twig Error when launch extract command

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 ",")....

Ids on xliff entries on generation

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

Empty meaning and wrong description in Message while dumping

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

Problem with WebUi

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

@Ignore gets ignored for plain text form field labels

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

Duplicated extraction on Inherited Validation Constraints of different bundles classes.

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.

Not so helpfull error message

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.

The twig 'desc' filter does not work with the 'transchoice' filter

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") }}

yml and linebreaks

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?

Wrong php code generated when using |trans with parameters in twig

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.

illegal XLIFF file format due to jms:reference-file elements

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 :-)

Translator chokes on numerical IDs

The translator / extractor chokes on numerical IDs. The steps to replicate this are quite simple:

  1. Have a file that has a numerical translation key, ie. in a Twig template: {{ 1 | trans }}

  2. Run the translation:extract command with --output-format=yml

  3. In the messages file a new line like 1: '1' # FIXME will be added

  4. ...everything fine so far

  5. 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.

Keep empty strings

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'

Extract empty_values of form field choice/entity type

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

Issue running script for extracts from the cli and website

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

Extract options/second_options labels of form field repeated type

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

Regarding inclusion of Multiple domains

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

extractors: [alias_of_the_extractor]

It will give an error of alias_of_the_etractor is not found. Please give me some hint here as well.

non-existent service config_factory

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

Position of @Desc in PHP

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

Incorrect translation when multiple @Desc for the same key on the same file

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.

Please remove dependency on the DI Bundle

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

error in 'clean' install (used to work before)

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

translation:extract --bundle=XXXBundle => grabbing messages from all bundles

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 ;-)

OS ordering seems to be causing git merge conflicts

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

Invalid WebUI configurations

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.

can't tag service jms_translation.file_vistor or not working

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

Inconsistent defaults between translation:extract and translation:update

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).

Fatal Error when exporting translations

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.

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.