Localization in SwiftUi

Explain Localization in SwiftUi and How it Work with many languages i.e(Arabic,English) ?
The Text and Button elements in SwiftUI are automatically localisable.

Code Block
Text("Hello World!")

or with a variable
Code Block
let hello = LocalizedStringKey("Hello")


Add Localizable.strings to your project.

Code Block
English
"Hello World!" = "Hello World!";
"Hello" = "Hello";
German
"Hello World!" = "Hallo Welt!";
"Hello" = "Hallo";


You can take a look at this video because it gives an example of adding localizations to a SwiftUI project (around 50:00 in the video).
https://developer.apple.com/videos/play/wwdc2020/10119/
However, instead of manually dragging .strings files into the project, you can use the export feature of Xcode by clicking on Editor -> Export for Localization... button in the top bar menu.
Indeed most string literals that you pass to SwiftUI views and view modifiers are localizable automatically because they take a LocalizedStringKey as an argument. If you are using Editor > Export for Localization… as suggested above, you'll want to use Text objects for your strings so they are included in the exported xcloc. Most/all SwiftUI API that accepts a LocalizedStringKey also accepts a Text.

Since you mention Arabic, support for Right-to-Left UI layout should be handled for you in SwiftUI. If you are explicitly specifying frames for your text views, you'll want to make sure your text doesn't clip even in languages that typically end up having longer strings than English.

You can find out more about the Export process here. See all articles under "Localize your app".
Localization in SwiftUi
 
 
Q