Localisation

http://www.dummies.com/programming/macintosh/how-to-localize-an-ios-app-in-swiftui/

  1. String Interpolation
let value = 40

struct ContentView: View {
    var body: some View {
        Text("bookings: \(value)")
            .fontWeight(.bold)
    }
}
//inside localizabble.strings "bookings: %lld" = "Buchungen: %lld";

If we have 1 value give “Key %lld” = “use %lld in any order”

if we have 2 value give key “Key %@ %lld” = “use 2 %@ %lld in any order”

2. if we don’t want to give %@ or @lld in key will have to use NSLocalizedString like below

value = 40 

Text(String(format: NSLocalizedString("bookingss:", comment: ""), value))

"bookingss:" = "Buchungen:  sandesh %lld french";

3. To make variable or dynamic value localised make it LocalizedStringKey

        let name: LocalizedStringKey = "name"

Text(name) //inside localizabble.strings "name" = "sandesh sardar";

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s