Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

SwiftUI: Working with RTL language like Arabic

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()
           }
        }

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Additionally to a comment above

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

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading