in project.pbxproj I changed developmentRegion to ar to force arabic language and RTL layout in entire app, everything looks good except Menu view content in this example:
import SwiftUI
struct ContentView: View {
@State private var selectedTime: Int = 0
var body: some View {
Form {
Picker("", selection: $selectedTime) {
Text("صباحاً").tag(0)
Text("مساءً").tag(1)
}
.labelsHidden()
.pickerStyle(SegmentedPickerStyle())
Menu {
Button("السبت", action: {})
Button("الأحد", action: {})
Button("الاثنين", action: {})
Button("الثلاثاء", action: {})
Button("الاربعاء", action: {})
Button("الخميس", action: {})
Button("الجمعة", action: {})
} label: {
Label("اليوم", systemImage: "calendar")
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
.preferredColorScheme(.dark)
}
}
the buttons’ labels inside Menu is flipped
any help is appreciated, thank you
2
Answers
Just add
Here, is the complete code which works
The only way you can achieve this is change the language through settings and restart the app.
Add any language you need in the project settings settings:
You must add the
settings.bundle
:Delete useless settings if needed
Important notes
18 August 2021
)BUT!
exit()
code if the language is notar
Development note
The simulator constantly caches the settings. So you may face issues that prevent you from seeing the current settings. Try test the flow in test projects and implement the result in the actual one.