Skip to main content

Separate Machine Identifiers From Localizable Labels in App Strings

2026-12-04

Separate Machine Identifiers From Localizable Labels in App Strings

A release build fails lint because Polish strings.xml still contains app_name after you marked the default row translatable="false". Or a String Catalog review queue fills with Aa, •, and OK glyphs that were never meant for a translator. Or a design-token pipeline emits font family names as Android <string> entries and Studio asks for missing translations of Inter_Bold.

They fail for the same reason: machine identifiers and localizable labels share one file format. Translators, Lint, extraction tools, and TMS sync treat every entry as copy unless you mark the machine ones as non-translatable or keep them out of the localization files.

This guide covers Android, iOS/SwiftUI, and shared resource pipelines. It is not about detecting hard-coded UI copy still sitting in source, and it is not about giving translators context for ambiguous UI words. Those articles assume the string should be translated. Here the job is to keep stable identifiers out of that path.

The short answer

  1. Split every string-shaped value into two buckets: user-facing labels that change by locale, and machine identifiers that must stay byte-stable.
  2. On Android, mark the second bucket with translatable="false" in the default values/strings.xml (or keep them in a dedicated donottranslate.xml), and never reintroduce those keys in locale files.
  3. On iOS/SwiftUI, put non-copy in Text(verbatim:) (or an equivalent non-extracted API) before you enable SwiftUI string extraction into a String Catalog.
  4. In generators and design-token pipelines, emit the untranslatable flag at source so Lint never sees token names as missing translations.
  5. Add a CI check that fails when a locale file contains a key the default file marked non-translatable, or when a catalog entry looks like an identifier rather than a sentence.

What belongs in each bucket

Localizable labels are words a person reads: button titles, empty states, error copy, accessibility labels, plurals, and store-facing text. They move through extraction, review, and a TMS.

Machine identifiers are values your code, backend, or another system must recognize later: API field names, analytics event keys, deep-link path segments, enum storage raw values, feature flags, font resource names, design-token names, single-glyph placeholders, and brand trademarks you refuse to alter. Translating them does not help a user. It breaks lookups, signatures, and round-trips.

A useful test: if a translated value would break a switch, URL routing, or a server decode, treat it as an identifier. Keep it out of the translator's queue even when the characters look like English words.

Case folding for protocol tokens is a related trap covered in the locale-sensitive case conversion article. This article stops earlier: do not hand the token to the localization pipeline at all.

Android: translatable="false" and the Translations Editor

Android's Translations Editor documents an Untranslatable column for rows you do not want translated. Selecting it writes translatable="false" on the corresponding line in the default values/strings.xml. Google's own example uses it for a product name:

<resources>
  <string name="app_name" translatable="false">EasyApp</string>
  <string name="action_settings">Settings</string>
</resources>

Use the same attribute for analytics keys, scheme hosts, and any other stable token you still store as a string resource for convenience:

<string name="analytics_event_purchase" translatable="false">purchase_completed</string>
<string name="deeplink_host" translatable="false">app.example</string>

Prefer a dedicated file such as values/donottranslate.xml when a module has dozens of machine strings. Lint and the Translations Editor honor the attribute; the filename is only a team convention that makes review easier.

Why locale files still break the build

The Stack Overflow question “is translated here but not found in default locale” with translatable="false" has tens of thousands of views. Authors mark the default row untranslatable, yet locale packs still contain the key, and Lint reports that the translation exists without a matching default entry. The usual cause is not a missing default string. It is a leftover locale row after a TMS export, a merged branch, or a tool that does not understand the flag.

Android's TranslatedButNotFoundInDefault lint often fires because a locale file still holds a key that default strings.xml marked translatable="false", usually after a TMS sync, not because the default key is missing. Fix it by deleting the key from every values-*/strings.xml, not by removing translatable="false" from the default file. Then fix the export filter so the next sync cannot recreate those rows.

Cross-platform resource libraries keep rediscovering the same gap. moko-resources #331 asks for translatable="false" (or a donottranslate.xml convention) so shared strings can opt out. AndroidLocalizationer #44 makes the same request of an IntelliJ plugin. stringbridge #5 lists translatable="false" as required parser work for Android strings.xml. Treat the flag as part of the interchange format, not as an Android Studio-only checkbox.

Generators must emit the flag

Design-token and font-name string resources look like ordinary UI copy to Android Lint unless the generator emits translatable="false", so style pipelines must mark machine values at emit time rather than relying on translator notes. In style-dictionary #893, the Android string template produced resource names and similar tokens as ordinary <string> entries. Android Studio and Lint then complained about missing translations for values that were never copy. The proposed fix was to emit translatable="false" in the template, with a pointer to the Translations Editor untranslatable docs.

If your pipeline builds strings.xml from tokens, Figma exports, or a shared JSON dictionary, add the attribute in the emitter. A translator comment that says "do not translate" is weaker: many TMS tools still bill the word, and Lint never sees the comment.

iOS and SwiftUI: Text(verbatim:) before you extract

SwiftUI's Text("Hello") is localizable by default. Text(verbatim:) takes a string that should appear exactly as written and stay out of extraction. Use it for symbols, unit tests that assert exact glyphs, debug overlays, and any label that is actually an identifier on screen (for example a raw feature-flag name shown only in internal builds).

// Localizable copy
Text("purchase_success_title", bundle: .main)

// Machine or non-copy text
Text(verbatim: "Aa")
Text(verbatim: featureFlag.rawValue)

Turning on SwiftUI Text extraction without a Text(verbatim:) cleanup pass dumps glyphs, single letters, and other non-copy into the catalog, which is why large apps keep the extractor off until that audit finishes. WordPress-iOS tracked this in #25700: the build-free String Catalog lane can extract Text("…") via xcstringstool extract --SwiftUI-Text, but the team left it off by default because the app had about 94 Text("…") literals and only 16 Text(verbatim:). Enabling extraction would send single glyphs such as Text("Aa") and Text("A") to translators as garbage until those literals were converted to Text(verbatim:).

For any app migrating to String Catalogs, extract after you classify literals, not before. For strings that must stay in the catalog for layout reasons but must not be translated, mark them as non-translatable in the catalog editor rather than hoping reviewers skip them.

Shared keys, enums, and format placeholders

Three patterns keep leaking identifiers into localization files:

  1. Enum raw values stored as strings. If case premium = "premium_plan" is also your analytics key, do not place "premium_plan" in Localizable.xcstrings or strings.xml as the user-facing title. Keep a separate localized title resource (premium_plan_title) and leave the raw value in code.
  2. Format keys that look like sentences. A key such as error_%@ or a TMS entry whose source text is an API path will come back "translated" into a locale-shaped path that your router does not recognize. Prefer positional formatters with a human source string, as in the message formatting guide, and keep the path in a non-translated constant.
  3. Brand and legal tokens. Product names often stay untranslated on purpose. Android's Untranslatable column exists for that case. Mirror the policy on iOS with a non-translatable catalog state or Text(verbatim:) for on-screen marks that must not vary.

When you hand strings to a vendor, export only the localizable bucket. A pre-flight script that drops translatable="false" rows and catalog entries marked non-translatable cuts the vendor quote and keeps deep links working on the first export that would have included them.

A practical classification checklist

Run this once per module, then keep it in CI:

  1. List every key in default strings.xml / the String Catalog.
  2. Tag each key label or identifier in a short spreadsheet or CODEOWNERS-adjacent doc.
  3. For every identifier, confirm the platform exclusion is present (translatable="false", Text(verbatim:), or catalog non-translatable).
  4. Grep locale directories for those keys and delete leftovers.
  5. Grep generators for <string name= / catalog inserts and require the exclusion flag in the template.
  6. Add a unit test or lint rule: no locale file may contain a key marked untranslatable in default resources.

Pseudo-check for Android in CI:

python3 tools/check_untranslatable_leak.py --default app/src/main/res/values \
  --locales 'app/src/main/res/values-*'

The script itself can stay project-specific. The rule should not. Tools that parse Android resources for conversion, such as the ones behind stringbridge #5, only stay safe when the flag travels with the string.

If you already ship through a TMS, add one more export assertion: the uploaded source file must contain zero keys that the default resources mark untranslatable. Teams that only delete leftovers from values-fr after Lint fails will see the same keys return on the next vendor drop. Filter at export, then keep the CI leak check as the backstop.

Ship the split, then keep it closed

Marking untranslatable rows costs less than debugging a locale that rewrote an analytics key or a catalog full of glyphs. Classify labels versus identifiers, emit translatable="false" and Text(verbatim:) at the source, strip those keys from locale packs and vendor exports, and fail CI when they leak back in. After that, every remaining string in the localization workflow is meant for a human.