In SwiftUI (although this question may apply to a wider domain than that),
If you are localizing your app with the latest methods, then you are using String Catalogs (Localizable.xcstrings)
Normally (as they seem to not mention any other option in this video), strings are automatically “picked up” in your codebase and put in your string catalog, to if you had:
Text("this is some string about an arbitrary thing that could be an any length that begins with any letter")
in your code, you would see a new entry in your string catalog with a key AND value of “this is some string about an arbitrary thing that could be an any length that begins with any letter”.
Now, I don’t happen to like that and I prefer to have a manual custom key like “main_add_link_label” because that just makes more sense to me for many many reasons.
So that’s what I’ve done so far, but then I ran into the issue of something like this:
Text("(numSessions) Sessions")
Where there is interpolation involved.
I understand how this would work if I were content to leave the code alone and have this one automatically tracked, but…
What is the proper way to have implement and access custom key that involves interpolation when using string catalogs?
Do we still need to use something like:
Text(String(format: NSLocalizedString("session_count", comment: ""), numSessions))
? Hopefully something nicer is possible.