schmittjoh / JMSTranslationBundle

Puts the Symfony2 Translation Component on steroids
http://jmsyst.com/bundles/JMSTranslationBundle
426 stars 292 forks source link

command translation:extract not found #505

Open PaddyLock opened 5 years ago

PaddyLock commented 5 years ago
Q A
Bundle version 1.4.3
Symfony version v4.2.1
PHP version 7.2.10

Expected behavior

Should be able to run extraction with this command

php bin/console translation:extract en --config=app --output-format=xliff --enable-extractor=jms_i18n_routing

Actual behavior

 Command "translation:extract" is not defined.

 Do you want to run "translation:update" instead?  (yes/no) [no]:
 > 

Steps to reproduce

use following config

jms_translation:
    configs:
        app:
            dirs: ["%kernel.root_dir%", "%kernel.root_dir%/../src/"]
            output_dir: "%kernel.root_dir%/../translations/"
            extractors: []

also installed jms/i18n-routing-bundle 3.0.2 with following config

jms_i18n_routing:
    default_locale: en
    locales: "%languages%"
    strategy: prefix_except_default

then run the command above.

Also if I run

php bin/console list

I only see translation:update

could there be a conflict in the namespace?

linaori commented 5 years ago

@PaddyLock do you have the mopa bootstrap bundle? I was looking for people with a similar issue. This bundle doesn't load the command in a specific case: https://github.com/schmittjoh/JMSTranslationBundle/blob/7bdd5e2feae5c794af1306a408671a998bb84ca5/DependencyInjection/JMSTranslationExtension.php#L36-L38

The mopa bootstrap bundle requires the mopa/composer-bridge: https://github.com/phiamo/MopaBootstrapBundle/blob/419bb11abd5940e0957ca6ed254aec0ae402e382/composer.json#L29

This bridge requires the symfony class-loader and thus causes the class loader to exist and not load this command https://github.com/phiamo/MopaComposerBridge/blob/58661a5c588ce9c3eff7d36c4030f6caa4de1ae2/composer.json#L20

If that's not the case, find out why the class loader is installed and try to remove it.

Question for the maintainers: Is this case really necessary to not load the command if the classloader is loaded?

PaddyLock commented 5 years ago

@linaori Yes I do have mopa bootstrap bundle installed.

I ended up using this package instead

And use this to extract

php bin/console translation:extract app en

However, there is also the built in symfony extractor in the docs

I'm not sure which method is recommended now, I haven't looked at this for a while.