Skip to content

feat: add Python brace localization format#207

Open
Anty0 wants to merge 1 commit into
mainfrom
jirikuchynka/cli-python-brace-format
Open

feat: add Python brace localization format#207
Anty0 wants to merge 1 commit into
mainfrom
jirikuchynka/cli-python-brace-format

Conversation

@Anty0

@Anty0 Anty0 commented Jun 16, 2026

Copy link
Copy Markdown
Member

Related issue tolgee/tolgee-platform#3589

Summary

  • Add the PO_PYTHON_BRACE localization format (Python str.format() / gettext python-brace-format) to push and pull, mirroring the existing PO_PYTHON. It maps to the platform export messageFormat: PYTHON_BRACE and import format PO_PYTHON_BRACE (added to tolgee-platform in #3589).
  • schema.json, src/options.ts and src/utils/mapExportFormat.ts updated; src/utils/mapImportFormat.ts needs no change (its default passthrough already forwards the matching PO_PYTHON_BRACE import format).
  • Add an e2e round-trip test and PO fixtures: {count:d} (file) ⇄ {count, number} (stored ICU), which exercises the actual converter rather than a placeholder that looks identical in ICU.
  • Regenerate the OpenAPI schema (src/client/internal/schema.generated.ts, src/schema.d.ts) against tolgee-platform main; this adds PYTHON_BRACE/PO_PYTHON_BRACE and syncs unrelated schema drift accumulated since the last regeneration.

Summary by CodeRabbit

  • New Features

    • Introduced support for the PO_PYTHON_BRACE localization format, enabling translation workflows with Python-style brace placeholders for plural handling (e.g., {count:d} syntax).
  • Tests

    • Added end-to-end tests validating push/pull operations for the new format with sample translations in English and French.

Add the PO_PYTHON_BRACE format (Python str.format() / gettext
python-brace-format) to push and pull, mirroring the existing PO_PYTHON.
It maps to platform export messageFormat PYTHON_BRACE and import format
PO_PYTHON_BRACE. Regenerate the OpenAPI schema against tolgee-platform
main, which adds the new format values and syncs unrelated drift.
@coderabbitai

coderabbitai Bot commented Jun 16, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: b525fdd2-d312-4b31-ab4d-cabf0ce2df38

📥 Commits

Reviewing files that changed from the base of the PR and between ff265a6 and a9f8ef3.

📒 Files selected for processing (9)
  • schema.json
  • src/client/internal/schema.generated.ts
  • src/options.ts
  • src/schema.d.ts
  • src/utils/mapExportFormat.ts
  • test/__fixtures__/differentFormatsProject/po-python-brace.json
  • test/__fixtures__/differentFormatsProject/po-python-brace/en.po
  • test/__fixtures__/differentFormatsProject/po-python-brace/fr.po
  • test/e2e/formats.test.ts

Walkthrough

Adds PO_PYTHON_BRACE as a new supported localization format. The format enum is extended in schema.json and src/schema.d.ts, the CLI --format option gains the new choice, and mapExportFormat maps it to format: 'PO' with messageFormat: 'PYTHON_BRACE'. English and French fixture .po files and an e2e test are added.

Changes

PO_PYTHON_BRACE Format Support

Layer / File(s) Summary
Schema, type, and CLI option contract
src/schema.d.ts, schema.json, src/options.ts
Adds PO_PYTHON_BRACE to the Format TypeScript union type, the JSON schema format enum, and the FORMAT_OPT CLI choices list.
Format mapping implementation
src/utils/mapExportFormat.ts
Adds a switch case that maps PO_PYTHON_BRACE{ format: 'PO', messageFormat: 'PYTHON_BRACE' }.
E2E fixtures and test case
test/__fixtures__/differentFormatsProject/po-python-brace.json, test/__fixtures__/differentFormatsProject/po-python-brace/*.po, test/e2e/formats.test.ts
Adds fixture config, English and French .po translation files, and an e2e test verifying push/pull round-trip behavior including the {count:d}{count} placeholder transformation.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~5 minutes

Possibly related PRs

  • tolgee/tolgee-cli#184: Follows the same pattern of adding new format values — extends src/options.ts, schema.json, src/schema.d.ts, and the mapExportFormat switch — for APPLE_SDK and ANDROID_SDK formats.

Suggested reviewers

  • JanCizmar

Poem

🐇 A new format hops into the warren today,
PO_PYTHON_BRACE is now here to stay!
The schema enum grows by just one small line,
The switch case maps it — oh, how divine.
Push and pull the .po files with glee,
{count:d} transforms for you and for me! 🎉

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'feat: add Python brace localization format' clearly and concisely describes the main change: introducing support for a new Python brace localization format to the codebase.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch jirikuchynka/cli-python-brace-format

Comment @coderabbitai help to get the list of available commands and usage tips.

@Anty0 Anty0 requested a review from dkrizan June 16, 2026 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant