Repository navigation
fix(Culture): reset cached formats when culture settings change - #1344
Merged
Merged
Conversation
Culture setters only dropped part of the default culture's cache, so formats, expressions and templates used before the call kept the previous settings. All setters now reset the cache, as setCulture already did. Document culture scopes for content that needs a different culture. Fixes #1342
mstijak
force-pushed
the
fix/culture-per-subtree
branch
from
October 25, 2026 22:23
4bfaa1a to
5390cf2
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.
Fixes #1342. Alternative to #1343.
Problem
With culture-sensitive formatting enabled, formatters, compiled expressions and compiled templates are cached on the default culture, and each holds the
NumberCulture/DateTimeCultureit was built with.setDefaultTimezone,setDefaultCurrency,setNumberCultureandsetDateTimeCulturedropped at most the culture object, so formats used before the call kept the previous settings, even in widgets created after the call. OnlysetCulturereset the whole cache.Dropping just
dateTimeCultureandformatCache, as suggested in the issue, is not enough: compiled templates such as{date:datetime}capture their formatter and are cached on the culture too.Fix
A module-level
updateDefaultCulture(changes)applies the changes, resets the default culture's cache and callsCulture.invalidateCache(). All setters use it, includingsetCultureandsetDefaultDateEncoding.invalidateCache()itself is unchanged.Content rendered after a setter call uses the new settings. Widgets that already exist are not updated, same as with
setCulturebefore.Docs
concepts/localization.mdx:RestatewithcreateCulture(...)for content that needs a different culture, timezone or currency, and how to switch it with aContentResolverTests
Culture.spec.ts:setDefaultTimezoneafter first use (12:00→21:00); every setter leaves the default culture's cache empty. Both fail without the fix.Restate.spec.tsx: detached Restates render in their own culture.Format.valueand a compiled{d:datetime;HHmmN}template both followsetDefaultTimezone(not in the suite, because culture-sensitive formatting can't be switched off).