php-translation / symfony-bundle

Symfony integration for Translations
MIT License
327 stars 94 forks source link

Command "translation:extract" is not defined. #185

Closed crabnky closed 6 years ago

crabnky commented 6 years ago

Hi, I'm using Symfony 4. I installed bundle with: composer require php-translation/symfony-bundle Here is the output:

> composer require php-translation/symfony-bundle
Using version ^0.5.0 for php-translation/symfony-bundle
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)

Prefetching 6 packages 🎶
  - Connecting (100%)
  - Downloading (100%)

Package operations: 7 installs, 0 updates, 0 removals
  - Installing nikic/php-parser (v3.1.3): Loading from cache
  - Installing php-translation/extractor (1.4.0): Loading from cache
  - Installing webmozart/assert (1.2.0): Loading from cache
  - Installing nyholm/nsa (1.1.0): Loading from cache
  - Installing php-translation/common (0.2.3): Loading from cache
  - Installing php-translation/symfony-storage (0.4.0): Loading from cache
  - Installing php-translation/symfony-bundle (0.5.0): Loading from cache
Writing lock file
Generating autoload files
ocramius/package-versions:  Generating version class...
ocramius/package-versions: ...done generating version class
Symfony operations: 1 recipe (92e6704c0567c1ffebee8daf3b2c6369)
  -  IGNORING  php-translation/symfony-bundle (>=0.4): From github.com/symfony/recipes-contrib:master
Executing script cache:clear [OK]
Executing script assets:install --symlink --relative public [OK]

As the recipe was ignored I manually added bundle to /config/bundles.php:

return [
    Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
    Symfony\Bundle\WebProfilerBundle\WebProfilerBundle::class => ['dev' => true, 'test' => true],
    Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
    Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true],
    Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true],
    Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true],
    Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle::class => ['all' => true],
    Doctrine\Bundle\DoctrineBundle\DoctrineBundle::class => ['all' => true],
    Doctrine\Bundle\MigrationsBundle\DoctrineMigrationsBundle::class => ['all' => true],
    Translation\Bundle\TranslationBundle::class => ['all' => true],
];

and manually copied files from recipe config to /config folder. But when I tried to extract messages I got:

  Command "translation:extract" is not defined.

  Did you mean this?
      translation:update

None of the bundle commands are available. :( Am I doing something wrong?

Nyholm commented 6 years ago

Thank you for this issue.

It is fixed in master. I was about to tag 0.6.0 yesterday but Travis was down.. Rechecking now

Nyholm commented 6 years ago

Could you try again with 0.6.0

crabnky commented 6 years ago

Hmm, I removed the bundle from the system (reverted back composer files and removed from vendors) and executed again composer require php-translation/symfony-bundle. The 0.6.0 version was picked up, but the recipe was ignored as it was with 0.5.0 version. Should I try to apply recipe manually as I did before?

bocharsky-bw commented 6 years ago

Hey @crabnky ,

I just tried to install the new v6.0.0 version and Flex rolled changes for me from this recipe: https://github.com/symfony/recipes-contrib/tree/master/php-translation/symfony-bundle/0.4 . So probably you just not fully removed it or removed it incorrectly. Don't forget that Flex tracking installed recipes in symfony.lock - probably you forget about this file when removing the bundle.

Also, keep in mind that this is a recipe from contrib repo, so you need to allow Flex to roll up these changes during composer require

Cheers!

mvrhov commented 6 years ago

I don't use the flex, however this works in non flex symfony4 installation

crabnky commented 6 years ago

OK, with my last composer update the flex was updated to 1.0.66 - not sure if this matters, but I just tried to install the bundle (0.6.1 version was picked up) and all went fine.

> composer require php-translation/symfony-bundle
Using version ^0.6.1 for php-translation/symfony-bundle
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Package operations: 7 installs, 0 updates, 0 removals
  - Installing nikic/php-parser (v3.1.3): Loading from cache
  - Installing php-translation/extractor (1.4.0): Loading from cache
  - Installing webmozart/assert (1.2.0): Loading from cache
  - Installing nyholm/nsa (1.1.0): Loading from cache
  - Installing php-translation/common (0.2.3): Loading from cache
  - Installing php-translation/symfony-storage (0.4.0): Loading from cache
  - Installing php-translation/symfony-bundle (0.6.1): Downloading (100%)
Writing lock file
Generating autoload files
ocramius/package-versions:  Generating version class...
ocramius/package-versions: ...done generating version class
Symfony operations: 1 recipe (5161898ff635a941ae9efaa0349fc372)
  -  WARNING  php-translation/symfony-bundle (>=0.4): From github.com/symfony/recipes-contrib:master
    The recipe for this package comes from the "contrib" repository, which is open to community contributions.
    Do you want to execute this recipe?
    [y] Yes
    [n] No
    [a] Yes for all packages, only for the current installation session
    [p] Yes permanently, never ask again for this project
    (defaults to n): y
  - Configuring php-translation/symfony-bundle (>=0.4): From github.com/symfony/recipes-contrib:master
Executing script cache:clear [OK]
Executing script assets:install --symlink --relative public [OK]

Some files may have been created or updated to configure your new packages.
Please review, edit and commit them: these files are yours.

And now all translation commands in the console are available. Thanks!