Repository navigation
Conversation
Both pickers have a title initializer for a LocalizedStringKey and one for a String. For a string literal Swift prefers the String overload, which builds a verbatim Text. So a title like "Pomodoro Length" never found the app's translations and always showed the English key. Mark the String initializers as disfavored, the same way SwiftUI does for Text, so literals pick the LocalizedStringKey initializer while a String value still shows as is.
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.
HPicker("Pomodoro Length", locked: [], selection: $value)showed the title untranslated. A string literal matched theStringinitializer, which builds a plainText(title)from aStringvalue, so no localization lookup happened. FocusBeats works around this with a customTextlabel (OptionsWizardView.swift:242).The
Stringinitializers ofHPickerandVPickerare now@_disfavoredOverload, the same way SwiftUI's ownText.init<S: StringProtocol>is marked. A literal now picks theLocalizedStringKeyinitializer and gets translated. AStringvariable still uses theStringinitializer and is shown as is. No call site has to change. The doc comments say which initializer does what.Considered: removing the
Stringinitializers. Rejected, because callers that pass already localizedStringvalues (CrossCraft does) would break.How this was verified
main(589e450): a test comparing the picker title withText(LocalizedStringKey)failed, the title was.verbatim("Fruit"). A control test showed the comparison really tells localized and verbatimTextapart.swift test --build-system swiftbuild, 43 tests in 13 suites passed. Also built for iOS withxcodebuild.Door two-way · Blast Radius breit (public API, re-exported by FlineDevKit)