Fix translations for sites with an explicit lang#221
Open
mynetx wants to merge 1 commit into
Open
Conversation
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
mynetx
force-pushed
the
fix/multisite-lang-translations
branch
from
July 6, 2026 08:22
7e82c59 to
a18da66
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When generating a multisite install, the generator sets the app locale to the site's short locale. Statamic's own
Localizemiddleware uses the site'slanginstead, which falls back to the short locale when not explicitly set.So a site configured with an explicit lang — e.g. locale
de_CH, langde_CH, with translations inlang/de_CH.json— renders fine when served normally, but during a static build Laravel looks forde.jsonand the raw translation keys end up in the generated HTML.This makes the generator match the middleware and use
$site->lang(). Sites without an explicit lang behave exactly as before.This also explains #166: when the short-locale lookup misses the site's translation files, Laravel serves the fallback locale's strings instead — so pages come out in the wrong language (or a mix, when only some keys fall back) rather than as raw keys. Reproduced on
4.xwith afr_FRsite and PHP lang groups: the live site renders the French strings, the static build renders the English fallback. With this fix the static build matches the live site.Fixes #202
Fixes #166