We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
We can add something in the lines of:
public struct LocText<S>: View where S: StringsProtocol, S.RawValue == String { public let key: S @Environment(\.locale) var locale: Locale public var body: some View { return Text(NSLocalizedString(key.rawValue, tableName: locale.identifier, comment: "")) } } public extension LocText where S == Strings { init(_ key: Strings) { self.key = key } } struct LocText_Library: LibraryContentProvider { var views: [LibraryItem] { [ LibraryItem(LocText(.todo), title: "Localized Text", category: .control) ] } } struct CustomLocaleModifier: ViewModifier { @State var locale: Locale = Locale(identifier: "en") func body(content: Content) -> some View { content .environment(\.customLocale, locale) .onPreferenceChange(CustomLocaleKey.self) { value in locale = value } } } struct CustomLocaleKey: EnvironmentKey, PreferenceKey { static var defaultValue: Locale = Locale(identifier: "en") static func reduce(value: inout Locale, nextValue: () -> Locale) { value = nextValue() } } extension EnvironmentValues { var customLocale: Locale { get { self[CustomLocaleKey.self] } set { self[CustomLocaleKey.self] = newValue } } }
The text was updated successfully, but these errors were encountered:
z-turk3
hhrvoic
kvaljeva
nikolamajcen
jabou
goranbrl
No branches or pull requests
We can add something in the lines of:
The text was updated successfully, but these errors were encountered: