### Add ApplangaSwiftUI to Podfile Source: https://github.com/applanga/sdk-swiftui/blob/main/README.md Add this line to your Podfile to include the ApplangaSwiftUI library. For UI tests requiring screenshots, also add 'pod 'ApplangaUITest''. ```ruby pod 'ApplangaSwiftUI' ``` -------------------------------- ### Enable Applanga Localization for LocalizedStringKey Source: https://github.com/applanga/sdk-swiftui/blob/main/README.md To use Applanga with existing LocalizedStringKey usages, create a type alias before your App object. This ensures all subsequent LocalizedStringKey instances are localized by the SDK without further code changes. ```swift typealias LocalizedStringKey = ApplangaLocalizedStringKey @main struct SomeApp: App { } ``` -------------------------------- ### Localize SwiftUI Components with LocalizedStringKey Source: https://github.com/applanga/sdk-swiftui/blob/main/README.md After setting up the LocalizedStringKey type alias, SwiftUI components using it will be automatically localized by the Applanga SDK. ```swift Text(LocalizedStringKey("text_title1")) Toggle(LocalizedStringKey("text_title2"), isOn: $toggle) Label(ApplangaLocalizedStringKey("text_title3")) ``` -------------------------------- ### Enable Applanga Show ID Mode for Screenshot Capturing Source: https://github.com/applanga/sdk-swiftui/blob/main/README.md To accurately capture screenshots for localization with SwiftUI, enable the Applanga show ID mode by passing `enableShowIdMode: true` to your `ApplangaUITest` instance. This displays strings by their IDs instead of their localized text. ```swift let app = XCUIApplication() let applangaUITest = ApplangaUITest(app: app, enableShowIdMode: true) app.launch() ``` -------------------------------- ### Enable Global Code Localization in SwiftUI App Source: https://github.com/applanga/sdk-swiftui/blob/main/README.md Add this import statement before your App object to enable global localization for your SwiftUI app. No need to import in every View file. ```swift import ApplangaSwiftUI @main struct SomeApp: App { } ``` -------------------------------- ### Localize SwiftUI Text, TextField, and Button Source: https://github.com/applanga/sdk-swiftui/blob/main/README.md Use Applanga dashboard key names directly as arguments for SwiftUI components like Text, TextField, and Button. The SDK automatically localizes these keys. ```swift Text("text_title1") TextField("text_field_title1", text: $text, axis: .horizontal) Button("button_title1") {} ``` -------------------------------- ### Attributed String Interpolation and Formatting Source: https://github.com/applanga/sdk-swiftui/blob/main/README.md Applanga supports string interpolation and format arguments for attributed strings, similar to normal strings. The SDK generates keys and formats the localized value accordingly. ```swift let count: Int = 1 Text(AttributedString(localized: "text_attributed\(count)", options: options, including: scope)) ``` -------------------------------- ### Trigger Applanga Content Update Source: https://github.com/applanga/sdk-swiftui/blob/main/README.md Call the `Applanga.update` method within your app's lifecycle, typically in `.onAppear`, to trigger an update of localized content. A success callback is provided. ```swift @main struct SomeApp: App { var body: some Scene { WindowGroup { ZStack { } .onAppear { Applanga.update { success in } } } } } } ``` -------------------------------- ### SwiftUI Attributed String Localization Source: https://github.com/applanga/sdk-swiftui/blob/main/README.md Use the AttributedString initializer with `localized` as the first argument for Applanga localization. The SDK supports various options and scopes, and localized values can include native attributes. ```swift Text(AttributedString(localized: "text_attributed1", options: options, including: scope)) ``` -------------------------------- ### SwiftUI String Interpolation Localization Source: https://github.com/applanga/sdk-swiftui/blob/main/README.md Applanga SDK supports string interpolation in SwiftUI, generating localization keys based on the format. The localized value is then formatted with the provided variables. ```swift let number = 5 Text("text_interpolation\(number)") ``` ```swift let number = 55.0 TextField("text_interpolation\(number, specifier: \"%.2f\")", text: $text) ``` ```swift let textValue = "SomeText" TextField("text_interpolation_\(textValue)_1", text: $text) ``` ```swift let positionValue1 = "PositionValue1" let positionValue2 = "PositionValue2" TextField("text_interpolation_\(positionValue1)_\(positionValue2)_1", text: $text) ``` -------------------------------- ### Localize Attributed Strings with String.LocalizationValue Source: https://github.com/applanga/sdk-swiftui/blob/main/README.md To localize attributed strings created with String.LocalizationValue, extend String to use ApplangaLocalizationValue. This allows the SDK to handle localization for these strings. ```swift extension String { typealias LocalizationValue = ApplangaLocalizationValue } @main struct SomeApp: App { } Text(AttributedString(localized: String.LocalizationValue("text_attributed4"), options: options, including: scope)) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.