Skip to content
Discussion options

You must be logged in to vote

Hi @RuslanARmore, you may not even need to involve TCA in this at all. You can change the language for your entire SwiftUI application using the \.locale environment value (see here).

Paste this into a playground to see how it works:

import PlaygroundSupport
import SwiftUI

struct ContentView: View {
  @State var locale = Locale.current
  @State var isPresented = false

  var body: some View {
    NavigationStack {
      VStack {
        Button {
          self.isPresented = true
          self.locale = Locale(identifier: "en")
        } label: {
          Text("English")
        }
        Button {
          self.isPresented = true
          self.locale = Locale(identifier: "zh")
        }

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@nmccann
Comment options

@RuslanARmore
Comment options

Answer selected by RuslanARmore
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants