Home > other >  SwiftUI: Working with RTL language like Arabic
SwiftUI: Working with RTL language like Arabic

Time:12-15

If you have worked with RTL language like Arabic, maybe you could give me some guides on how I can display the language correctly in swiftui.

I tried something like below but it is actually not correct as they are still left aligned.

 if nativeLanguage == "Arabic" {
     HStack {
         Spacer()
         Text("مرحبا هذا نص طويل ولكنه باللغة العربية فكيف يمكن عرضه بشكل صحيح")
            .font(.system(size: 16))
            .foregroundColor(Color.gray)
          }
       } else {
           HStack {
             Text("Hello there")
               .font(.system(size: 16))
               .foregroundColor(Color.gray)
             Spacer()
           }
        }

CodePudding user response:

Additionally to a comment above

Text("someText") // assuming this one localized correctly
    .multilineTextAlignment(.leading)
    .frame(maxWidth: .infinity, alignment: .leading)
  • Related