Prompt
How do I handle string extraction and publishing for localization?
Latest observation
A solid localization workflow usually has two parts:
- Extract strings into a source file / catalog
- Publish those strings for translators and ship translated builds back into the app
Here’s a practical way to handle it.
1) Mark translatable strings in code
Don’t hardcode user-facing text directly in UI. Wrap it in localization functions/macros so it can be found later.
Examples:
_("Save")tr("Save")NSLocalizedString("save_button_title", comment: "Save button title")
Good keys are:
- stable
- descriptive
- not the English text itself if you expect wording to change
2) Extract strings automatically
Use a tool in your build process to scan source files and extract all translatable strings into a catalog or template file.
Common outputs:
.pot/.pofiles for gettext.stringsfiles for Apple platforms.json,.yaml, or.arbdepending on framework
Best practices:
- run extraction in CI or as a build step
- keep source language strings in one place
- include developer comments for context
3) Add translator context
Translators need more than the text itself.
Include:
- comments explaining meaning
- screenshots or UI context
- placeholders info like
{count}or%s - plural rules if needed
Example:
#. Button label on the checkout page
msgid "Pay now"
msgstr ""
4) Use a translation platform or review process
Instead of emailing files around, publish extracted strings to a system like:
- Weblate
- Crowdin
- Lokalise
- POEditor
- Transifex
This lets translators:
- see context
- translate in-browser
- review history
- handle multiple languages safely
5) Merge translated strings back into the app
After translation:
- download updated locale files
- validate syntax/placeholders
- compile or bundle them with your release
Make sure your app handles:
- missing translations by falling back to source language
- locale formatting for dates, numbers, currencies
- right-to-left layouts if relevant
6) Automate the pipeline
A typical CI flow looks like:
- Developer changes UI text
- Extraction runs and updates template/catalog
- Catalog is pushed to translation platform
- Translators update strings
- CI pulls translated files
- Tests check placeholders and missing keys
- App ships with localized resources
7) Validate before release
Check for:
- missing translations
- broken placeholders
- truncation in UI
- pluralization mistakes
- encoding issues
Example workflow
If you’re using gettext:
- code uses
_() xgettextextracts strings tomessages.pot- translators work on
fr.po,de.po, etc. msgfmtcompiles them into.mofiles- app loads the correct locale at runtime
Good publishing conventions
When publishing strings to translators:
- export only new or changed strings
- preserve stable keys
- include source text, comments, and screenshots
- use consistent punctuation and capitalization
- avoid concatenating strings in code
If you tell me your stack — for example Android, iOS, React, Flutter, Python, or gettext — I can give you a concrete extraction/publishing setup and example commands.