Inherit the environment locale in presentations - #502
Open
vincentborko wants to merge 1 commit into
Open
Conversation
vincentborko
added a commit
to vincentborko/skip-ui
that referenced
this pull request
Jul 31, 2026
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 #501.
.environment(\.locale, …)set on an ancestor did not reach the content of a.sheetor.fullScreenCover: the presented content resolvedTextcatalog keys, and reported@Environment(\.locale), in the device locale.localeis the only environment value not held in one of our own composition locals — it reads and writes Compose'sLocalConfiguration. Presented content composes in a separate Android window, andProvideAndroidCompositionLocalsre-providesLocalConfigurationthere from the platform, discarding the ancestor's override. Everything stored in our own composition locals — including customEnvironmentKeys,layoutDirection, andtimeZone— crosses the boundary correctly; #501 has the measurements.The setter now records the override in our own composition local as well, and the getter prefers it over
LocalConfiguration.LocalConfigurationis still written, so Android resource resolution keeps following the locale within the same window.Design note
The alternative is to re-provide the presenter's
LocalConfigurationinside each presentation window, which would additionally fix Compose-native resource lookups (stringResource, Material date pickers) inside sheets. I did not take it: it has to be repeated at every window-creating call site — sheets, covers, alerts, confirmation dialogs, menus, popups — and overriding the wholeConfigurationrisks clobbering the dialog window's own metrics, whichSheetPresentationreads for detent insets. Happy to switch if you would rather close that gap in one place.Testing
testSheetInheritsLocaleFromPresenterasserts that aTextcatalog key inside a.sheetresolves against the presenter's locale. Verified it fails without the source change (Failed to assert the following: (Text + EditableText = [Terminé])) and passes with it.swift testpasses: 94 tests, 0 failures, native and transpiled.Also verified on an Android emulator with a Skip Lite app whose device language is
en-USand which sets.environment(\.locale, Locale(identifier: "fr"))once at the root..sheetand.fullScreenCovercontent reporteden_USand rendered the base-language string before the change; both reportfrand render the French string after it.Skip Fuse UI needs no companion change:
\.localeis bridged throughEnvironmentValues.builtinBridged/setBuiltinBridged, which read and write this same property.Skip Pull Request Checklist:
swift testlocalewas lost;ProvideAndroidCompositionLocalswas confirmed to provideLocalConfigurationby disassemblingui-android; and the new test was confirmed to fail without the source change before the PR was opened.