What is the Swift equivalent of NSLocalizedString for string localization?
Hi everyone! I just started learning Swift and am trying to add localization to my app. In Objective-C, I saw that the `NSLocalizedString` macro is used, but in Swift, as I understand, there are no macros.
I tried using `NSLocalizedString("key", comment: "comment")` directly in Swift, and it works, but it feels like it's not quite right. Is there a built-in equivalent in Swift that is more idiomatic for this language? For example, something like `LocalizedString("key")` or another syntax?
Here's an example of my current code:
```swift
let welcomeMessage = NSLocalizedString("welcome_message", comment: "Welcome message on the main screen")
```
It bothers me that I have to write `comment:` every time. Is there a way to simplify this? Or is this normal practice?
No answers yet.
Log in to leave an answer
Blogs
Generics in Kotlin: Why They Are Needed and How to Use Them