Thanks to visit codestin.com
Credit goes to github.com

Skip to content

bin/console lint:container - Invalid definition for service "console.command.translation_lint" with "pseudo_localization" #59101

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
SindlaXYZ opened this issue Dec 5, 2024 · 0 comments

Comments

@SindlaXYZ
Copy link

SindlaXYZ commented Dec 5, 2024

Symfony version(s) affected

7.2.0

Description

I just updated my Symfony project from Symfony 7.1 to 7.2.0.
Now, when I run the command bin/console lint:container, I get this error:

[ERROR] Invalid definition for service "console.command.translation_lint": argument 1 of "Symfony\Component\Translation\Command\TranslationLintCommand::__construct()" accepts "Symfony\Contracts\Translation\TranslatorInterface&Symfony\Component\Translation\TranslatorBagInterface", "Symfony\Component\Translation\PseudoLocalizationTranslator" passed.

I tried using the --resolve-env-vars parameter: same error.
I also receive the same error in both the dev and production environments.

This is my translation.yaml file:

# config/packages/translation.yaml
framework:
    default_locale: '%locale%' # Read from parameters.locale
    enabled_locales: '%locales%' # Read from parameters.locales
    translator:
        default_path: '%kernel.project_dir%/translations'
        # This option is used when the translation key for the current locale wasn't found | default: the value of default_locale
        fallbacks:
            - '%locale%'
        providers:
        pseudo_localization:
            # replace characters by their accented version
            accents: false
            # wrap strings with brackets
            brackets: false
            # controls how many extra characters are added to make text longer
            expansion_factor: 1
            # maintain the original HTML tags of the translated contents
            parse_html: true
            # also translate the contents of these HTML attributes
            #localizable_html_attributes: ['title']

when@prod:
    framework:
        translator:
            pseudo_localization:
                accents: false
                brackets: false

If I comment out the pseudo_localization: block, the error goes away.

I encountered the same error with the translation.yaml example from https://symfony.com/doc/current/translation.html.

# config/packages/translation.yaml
framework:
    translator:
        pseudo_localization:
            # replace characters by their accented version
            accents: true
            # wrap strings with brackets
            brackets: true
            # controls how many extra characters are added to make text longer
            expansion_factor: 1.4
            # maintain the original HTML tags of the translated contents
            parse_html: true
            # also translate the contents of these HTML attributes
            localizable_html_attributes: ['title']

How to reproduce

Run the command bin/console lint:container with:

# config/packages/translation.yaml
framework:
    translator:
        pseudo_localization:
            # replace characters by their accented version
            accents: true
            # wrap strings with brackets
            brackets: true
            # controls how many extra characters are added to make text longer
            expansion_factor: 1.4
            # maintain the original HTML tags of the translated contents
            parse_html: true
            # also translate the contents of these HTML attributes
            localizable_html_attributes: ['title']

Possible Solution

No response

Additional Context

No response

@SindlaXYZ SindlaXYZ added the Bug label Dec 5, 2024
@SindlaXYZ SindlaXYZ changed the title bin/console lint:container - Invalid definition for service "console.command.translation_lint" bin/console lint:container - Invalid definition for service "console.command.translation_lint" with "pseudo_localization" Dec 5, 2024
fabpot added a commit that referenced this issue Dec 16, 2024
…ibility with the `PseudoLocalizationTranslator` (xabbuh)

This PR was merged into the 7.2 branch.

Discussion
----------

[FrameworkBundle][Translation] fix translation lint compatibility with the `PseudoLocalizationTranslator`

| Q             | A
| ------------- | ---
| Branch?       | 7.2
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Issues        | Fix #59101
| License       | MIT

Commits
-------

2695871 fix translation lint compatibility with the PseudoLocalizationTranslator
@fabpot fabpot closed this as completed Dec 16, 2024
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

4 participants