8000 [Translation] debug:translation command does not show components translations · Issue #29633 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Translation] debug:translation command does not show components translations #29633

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

Closed
damienalexandre opened this issue Dec 17, 2018 · 6 comments

Comments

@damienalexandre
Copy link
Contributor

Symfony version(s) affected: 3.4 to 4.2 at least

Description

When running php ./bin/console debug:translation --all fr, translation from all bundles are read (like FrameworkBundle, TwigBundle... ) but translations from components likes validators or security are not:

  • vendor/symfony/form/Resources/translations/validators.fr.xlf
  • vendor/symfony/security-core/Resources/translations/security.fr.xlf
  • vendor/symfony/validator/Resources/translations/validators.fr.xlf

I think this is not the behavior I expected, it could be improved.

The help message on the "all" option tells:

You can display information about translations in all registered bundles in a specific locale:

So it work as expected, but someone using those components will have hidden translation in his application, and no way to read them / debug them.

How to reproduce

php ./bin/console debug:translation --all fr
# No message from the "validators" catalog is listed

Possible Solution

Symfony should use the same path resolution for the debug command and the catalog loading in Translator. The Translator is capable of reading translations from the components, so this command should act the same way.

Additional context

Happy holidays 🎄 🎅

@yceruto
Copy link
Member
yceruto commented Dec 17, 2018

Hi @damienalexandre, I agree and it's a new feature that I'm trying to add for 4.3, see #29121, reviews are welcome :)

@damienalexandre
Copy link
Contributor Author

Oh! That's exactly what I need, sorry I missed your PR 😨 Thanks a lot, as I can see you use the discovery already done in the Framework, that's very nice 👍

// Discover translation directories
$dirs = array();
if (class_exists('Symfony\Component\Validator\Validation')) {
$r = new \ReflectionClass('Symfony\Component\Validator\Validation');
$dirs[] = \dirname($r->getFileName()).'/Resources/translations';
}
if (class_exists('Symfony\Component\Form\Form')) {
$r = new \ReflectionClass('Symfony\Component\Form\Form');
$dirs[] = \dirname($r->getFileName()).'/Resources/translations';
}
if (class_exists('Symfony\Component\Security\Core\Exception\AuthenticationException')) {
$r = new \ReflectionClass('Symfony\Component\Security\Core\Exception\AuthenticationException');
$dirs[] = \dirname(\dirname($r->getFileName())).'/Resources/translations';
}

Should I close this issue?

@lyrixx
Copy link
Member
lyrixx commented Dec 17, 2018

IMHO, this is a bug fix and not a new feature

@yceruto
Copy link
Member
yceruto commented Dec 17, 2018

In that case, we can split #29121 adding these particular paths as a bugfix in 3.4?

The Resources/translations/ directory of Validation component (if installed).
The Resources/translations/ directory of Form component (if installed).
The Resources/translations/ directory of Security Core component (if installed).

Note that it'll require anyway a new constructor argument in commands to allow extra paths.

@fabpot
Copy link
Member
fabpot commented Dec 17, 2018

a new constructor arg seems like a new feature to me :)

@lyrixx
Copy link
Member
lyrixx commented Dec 18, 2018

Hmm, indeed the help says:

  --all              Load messages from all registered bundles

I thought --all means "all" 😂

@fabpot fabpot closed this as completed Feb 13, 2019
fabpot added a commit that referenced this issue Feb 13, 2019
…tor paths, Twig paths and Translator aware services paths in commands (yceruto)

This PR was merged into the 4.3-dev branch.

Discussion
----------

[FrameworkBundle][Translation] Add support for Translator paths, Twig paths and Translator aware services paths in commands

| Q             | A
| ------------- | ---
| Branch?       | master
| Bug fix?      | no
| New feature?  | yes
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #29085, #29633, #17739
| License       | MIT
| Doc PR        | TODO

Add custom (also common) Twig and Translation paths to the translation commands:
 * Custom directories configured in `twig.paths`.
 * Custom directories configured in `translator.paths`
 * The `Resources/translations/` directory of `Validation` component (if installed).
 * The `Resources/translations/` directory of `Form` component (if installed).
 * The `Resources/translations/` directory of Security Core component (if installed).

Commits
-------

31d7a09 Add support for translator paths and twig paths in translation commands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants
0