17 thoughts on “Quick Tricks for iOS

  1. JAE-KYONG Post author

    Localize Your Apps to Support Multiple Languages — iOS Localization in SwiftUI

    or

    You can do it simply by using: String(localized: “YOUR_LOCALIZED_KEY”)

    If your localized key is programmatically generated, you must store it in a variable that conforms to “LocalizationValue” like this:

    let localizedKey = String.LocalizationValue(stringLiteral: yourLocalizedVar)

    Then you can use String(localized: localizedKey) to get your localized text content.

    Mahdi BM’s solution has a problem because Swift returns only the language code even if you use variants of a language like Spanish, Portuguese, and so many others. The language code for both examples will always return ES and PT, but the names of folders with the localized keys will be different: PT can be ‘pt-PT’ or ‘pt-BR’, Spanish can be ‘es’ or ‘es-419’ (Latin America) and these cases will cause your app to crash. Locale is also a terrible idea to get this reference because it’s composed by both current language and region, both can be from different places, example, if the user is from Japan but is in the US, the user’s locale will very likely be jp_US@japaneseCalendar.

    Reply
  2. JAE-KYONG Post author

    https://designcode.io/swiftui-handbook-visual-editor-in-xcode

    https://www.hackingwithswift.com/quick-start/swiftui/how-to-enable-pull-to-refresh

    https://www.hackingwithswift.com/forums/swift/hacking-arend-with-json-invalid-key-containing-a-space-no-snakes-or-camels/23905

    https://www.kodeco.com/books/swift-cookbook/v1.0/chapters/3-handle-custom-keys-missing-values-while-decoding-in-swift

    https://www.hackingwithswift.com/guide/ios-swiftui/5/2/key-points

    https://www.swiftyplace.com/blog/chy7hvne#:~:text=The%20table%20allows%20the%20selection,available%20to%20customize%20its%20behavior.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *