Skip to content

Current locale must be one of the kernel.enabled_locales#71

Merged
paullla merged 3 commits into
Locastic:masterfrom
maxhelias:fix-only-enabled-locales
Jul 6, 2026
Merged

Current locale must be one of the kernel.enabled_locales#71
paullla merged 3 commits into
Locastic:masterfrom
maxhelias:fix-only-enabled-locales

Conversation

@maxhelias

Copy link
Copy Markdown
Contributor

No description provided.

@maxhelias

Copy link
Copy Markdown
Contributor Author

@paullla Can you take a look? :)

paullla added 2 commits July 6, 2026 13:52
Apply the enabled_locales check to the ?locale= query param as well:
previously only the Accept-Language path was restricted, so any raw
query value still reached the doctrine listener and could be persisted
as a translation locale. A non-enabled query locale now falls back to
the default locale.

Pin the default locale first when negotiating the Accept-Language
header: getPreferredLanguage() returns the first element of the list
when nothing matches, so without pinning the fallback silently becomes
whatever is listed first in framework.enabled_locales instead of
kernel.default_locale.

Default the new constructor argument to [] so direct instantiation and
decoration keep working; an empty list (Symfony's default when
framework.enabled_locales is not configured) keeps the previous
accept-anything behavior. Documented in the README.
@paullla

paullla commented Jul 6, 2026

Copy link
Copy Markdown
Member

Thanks @maxhelias, and sorry for the long wait on this. The change was right, it just needed three adjustments: the same check on the ?locale= query param path (the primary way this bundle selects a locale, and the raw value could end up persisted as a translation locale), pinning the default locale during Accept-Language negotiation (getPreferredLanguage() returns the first list element when nothing matches, so the fallback would silently become the first entry of enabled_locales instead of kernel.default_locale), and a default for the new constructor argument so direct instantiation keeps working. Since the PR allows maintainer edits, I pushed those on top of your commit along with a master merge and a README note.

@paullla paullla merged commit 6897690 into Locastic:master Jul 6, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants