Mark localized strings untranslatable

String catalog is a great new feature to organize strings in one place. What would you recommend how to handle extracted Strings which need not be translated in different languages

Replies

In general, strings that don't require localization should not be marked as localizable in code. By default, UI strings in SwiftUI are localizable. You can opt-out a string in SwiftUI by using Text(verbatim:) to indicate that a string does not require localization. For all other code, you can avoid wrapping the string in String(localized:), NSLocalizedString, etc. Unfortunately, there isn't currently a way to opt-out a string from localization in a localized interface builder file.

If your workflow requires the ability to mark strings as "do not translate" before sending out to your localizers, please use Feedback Assistant to file an enhancement request.

@Frameworks Engineer Please note that Xcode does not mark strings that were subsequently opted-out as stale. For example, if a string key was extracted from Text("do_not_localize") and made it into the catalog, changing the code to Text(verbatim: "do_not_localize") does not mark the string as stale. In other words, marking string as "untranslatable", at least with Text(verbatim:) does not "downgrade" a string. I've reported this with a sample project in FB12418887 (but I got it wrong initially).

In the string catalog, links from keys to places where they are extracted would be helpful. I have keys like %@ and %1$@ %2$@ that I'd like to mark verbatim, but don't know where the sources are.

Wow, not be able to opt-out strings from interface builder files is really a problem! It often happens to add elements in IB, UILabels for example, whose content is populated via code. We really need a way for specify that a particular IB item should not be localized.

What is the recommended approach to handle these cases?

  • I have filled out the enhancement request FB13084630.

  • Ta!

Add a Comment

String appears in localization catalog:

Text("Prefill Address")

String is emitted from localization catalog:

let prefillAddress = "Prefill Address"
Text(prefillAddress)