Skip to content

[Translation] autowiring LocaleAwareInterface does not have the current locale #48499

@kbond

Description

@kbond

Symfony version(s) affected

6.1.x

Description

When autowiring LocaleAwareInterface into a service, if the locale has been changed via, say routing, LocalAwareInterface::getLocale() returns the default locale.

How to reproduce

  • change your application's locale (in any way except using LocaleSwitcher)
  • inject LocaleAwareInterface into a service/controller and look at getLocale() - it will be your app's default locale

Possible Solution

LocaleAwareInterface is an alias for LocaleSwitcher which is also LocaleAware but it doesn't look like it's modified when the locale is changed elsewhere.

I can work on a fix but wanted to clarify that this, is indeed, a bug.

Additional Context

#46045

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions