when a string catalog entry is missing

using String Catalog, missing locale entries don't fall back to source language. for example,

    "%lld videos" : {
      "comment" : "Label for a number of videos",
      "extractionState" : "manual",
      "localizations" : {
        "en" : {
          "variations" : {
            "plural" : {
              "one" : {
                "stringUnit" : {
                  "state" : "translated",
                  "value" : "%(count)lld video"
                }
              },
              "other" : {
                "stringUnit" : {
                  "state" : "translated",
                  "value" : "%(count)lld videos"
                }
              }
            }
          }
        },

this allows us to use Text(.videos(count: 1)) in English and it'll produce "1 video" as expected but when the locale is French for example, it'll produce "1" instead, until "fr" entry will be added. this is extremely inconvenient. what's the proper workaround?

Hello and thanks for bringing this up!

When a localized string is not available in one language, the behavior is to fall back to the defaultValue and then the key at runtime: String(localized: "key", defaultValue: "default value", comment: "…") will show "default value", and String(localized: "key", comment: "…") will show "key" if no localizations can be found.

That said, we're aware that showing 1 at runtime is not ideal and treat it as a known bug. Once fixed, the key will be shown at runtime, 1 videos in this case.

In general however, it's preferred to not show mixed languages (showing a single English string in an otherwise French app can be confusing). You can use the build setting BUILD_ONLY_KNOWN_LOCALIZATIONS (https://developer.apple.com/documentation/xcode-release-notes/xcode-26_4-release-notes#Localization) to exclude a language from building in case it's not fully translated yet.

thanks for the response! I'll try BUILD_ONLY_KNOWN_LOCALIZATIONS to see how it works. that said, we're not mixing up languages. it's just that some of French entries weren't completed yet. in the Project Editor, French is added and most of strings are fully translated but when a new item is later added, its French version won't be translated until done. in those cases, I want the app to use the original English version until French entry will be added shortly. is it any workaround other than ignoring all existing French entries by BUILD_ONLY_KNOWN_LOCALIZATIONS flag?

Just for extra clarification, the build setting BUILD_ONLY_KNOWN_LOCALIZATIONS builds languages included in the list of languages as denoted in your project settings. You can use the - button to remove languages only from the list, and keep their content in the project.

As far as workarounds, you can change how you load the string from using Text(.videos(count: 1)) to Text(LocalizedStringResource("%lld videos", defaultValue: "\(count) videos")), and this should fall back to \(count) videos at runtime.

Alternatively, you can use the English values for French in your String Catalog, and select "Mark for Review", so that you don't forget to change them later.

when a string catalog entry is missing
 
 
Q