Skip to content

Folded components bake translations (__()) in the locale of the first compiling request #221

Description

@mr-riabov

Summary

Components compiled with @blaze(fold: true) evaluate translation helpers (__(), trans(), @lang) at compile time, so the translated string is baked into the compiled view in the locale of whichever request compiled it first. The compiled-view cache is shared across locales, so every later request gets that same language until views are cleared.

Reproduction (Blaze v1.0.19, Flux)

  1. Multilingual app (uk and ru locales), compiled views cleared.
  2. First request renders a page containing <flux:sidebar.toggle /> with app()->getLocale() === 'uk'.
  3. Next request renders the same view with locale ru.

Expected: the toggle's aria-label is the ru translation of Toggle sidebar.
Actual: it is still the uk string — and it stays that way for all users and locales until view:clear / the next deploy. Reversing the order bakes ru into uk pages.

We found 23 Flux stubs affected this way (directly or through folded children), including input, select (selected, No results found), input/file, pillbox, pagination, date-picker.

Cause

Folder::checkProblematicPatterns() (src/Folder/Folder.php) rejects folding for request-dependent code (session(, auth(), request(), $errors, @csrf, old(, …), but not for translation helpers, which depend on the request locale in the same way.

Suggestion

Treat __(, trans(, trans_choice(, @lang as problematic patterns (refuse to fold / throw InvalidBlazeFoldUsageException), or include the current locale in the fold cache key. Our current workaround is overriding the affected Flux stubs without fold: true.

Activity

  1. ganyicz commented on Oct 23, 2026

    @ganyicz
    Collaborator

    Thanks for reporting @mr-riabov

    This will be fixed in the next release

  2. ganyicz commented on Oct 25, 2026

    @ganyicz
    Collaborator

    Reopening this as I found issues with the approach in the original PR, will revisit later.

  3. rspahni commented on Oct 29, 2026

    @rspahni

    @ganyicz - for the record, I reported the same issue on the Flux repo (livewire/flux#2851). If pursued here, can be closed there, or vice versa.

  4. iruoy commented on Nov 19, 2026

    @iruoy

    Two data points from today, with Blaze v1.0.21 and Flux v2.22.0:

    • Still reproducible on v1.0.21. Rendering <flux:sidebar.toggle /> under nl and then under en in the same process gives the Dutch aria-label both times. In the other order it stays English. A plain {{ __('Toggle sidebar') }} in the same template follows the locale, and with BLAZE_ENABLED=false both do.
    • 51 folded Flux views now call __(), up from the 23 counted above. Among them are modal, pagination, select/*, input/clearable, input/copyable, input/viewable, command/*, the date and time pickers, editor/* and sidebar/toggle, sidebar/collapse and sidebar/search.

    I've opened #245 with a possible fix: it leaves a component unfolded when it translates while being folded.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions