Skip to content

Adding translations#23

Merged
jpchauvel merged 2 commits intomainfrom
issue-10
Sep 5, 2025
Merged

Adding translations#23
jpchauvel merged 2 commits intomainfrom
issue-10

Conversation

@jpchauvel
Copy link
Contributor

@jpchauvel jpchauvel commented Sep 5, 2025

  • adding babel and pinning versions for dependencies
  • adding translations, fixes Add translations #10
  • adding a script to perform auto-translation

Summary by CodeRabbit

  • New Features
    • Added internationalization with automatic locale detection.
    • Provided translations for Spanish, Italian, and French.
    • Localized all user-facing texts, including the social network prompt.
  • Chores
    • Introduced tooling to extract, translate, and compile message catalogs.
    • Added and pinned dependencies required for localization.
    • Adjusted ignore rules for translation source/binary files.

@coderabbitai
Copy link

coderabbitai bot commented Sep 5, 2025

Caution

Review failed

The pull request is closed.

Walkthrough

Introduces gettext-based i18n with Babel configuration and scripts, adds translation dependencies, sets PO ignore pattern, centralizes locale and social constants, localizes user-facing strings, and updates main to use constants and i18n prompt. Adds CLI and shell scripts to extract, initialize, auto-translate, and compile translations.

Changes

Cohort / File(s) Summary
i18n tooling & config
babel.cfg, .gitignore, pyproject.toml, bin/translate.sh, bin/translate.py
Adds Babel extraction rule for Python files; switches ignore from \.mo to \.po; adds babel and translation libs; introduces shell script to extract/init/translate/compile; adds Python translator using deep-translator + polib.
Localized strings
src/edit_python_pe/strings.py
Integrates gettext with fallback, determines default locale, wraps all user-facing strings with _(), adds PROMPT_SOCIAL_NETWORK, defines supported locales (en, es, it, fr).
Constants centralization
src/edit_python_pe/constants.py
Adds locale constants and social network option tuples for reuse.
Main integration
src/edit_python_pe/main.py
Replaces hard-coded social options with constants, switches prompt to PROMPT_SOCIAL_NETWORK, updates exit call to use MESSAGE_EXIT named argument.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Dev as Developer
  participant Shell as bin/translate.sh
  participant Babel as pybabel
  participant Py as bin/translate.py
  participant GT as GoogleTranslator
  participant PO as polib

  Dev->>Shell: Run translate.sh
  Shell->>Babel: extract -F babel.cfg -o messages.pot
  Shell->>Babel: init/update -d translations -l es,it,fr
  Note right of Babel: Creates/updates messages.po
  Shell->>Py: translate.py messages.po (per locale)
  Py->>PO: Load .po file
  Py->>GT: translate(msgid, en -> target)
  GT-->>Py: translated text
  Py->>PO: Set msgstr, save
  Shell->>Babel: compile -d translations
  Babel-->>Dev: Compiled .mo files
Loading
sequenceDiagram
  autonumber
  participant App as Application
  participant Strings as strings.py
  participant GetText as gettext
  participant FS as translations/*
  App->>Strings: import constants & _()
  Strings->>GetText: translation(domain="messages", localedir="translations", languages=[default,en,es,it,fr], fallback=True)
  GetText->>FS: Load locale catalog
  FS-->>GetText: .mo (if available)
  App->>Strings: _("UI text")
  Strings-->>App: Localized string or fallback
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Assessment against linked issues

Objective Addressed Explanation
Implement gettext/Babel-based translations across the app (#10)
Provide a script to create translations using Google Translate (#10)
Add tooling to extract, init, and compile translations (#10)
Respect dependency on #12 before enabling translations (#10) Dependency details for #12 are not shown; sequencing cannot be verified.

Assessment against linked issues: Out-of-scope changes

Code Change Explanation
Add social network option constants (src/edit_python_pe/constants.py, lines 1–end) Social option tuples are unrelated to translation enablement; only locale constants align with the objective.
Replace social options in main with constants and adjust exit call (src/edit_python_pe/main.py, lines 1–end) Refactor to use constants and change exit argument is not required for adding translations.

Poem

I twitch my ears at strings that sing,
From en to es, a fluttering wing—
Babel hums, gettext replies,
PO seeds grow into MO skies.
I hop, compile—such polyglot fun!
Translate.sh runs—now everybun’s one. 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between cc8f7dc and f6ccbfd.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (8)
  • .gitignore (1 hunks)
  • babel.cfg (1 hunks)
  • bin/translate.py (1 hunks)
  • bin/translate.sh (1 hunks)
  • pyproject.toml (2 hunks)
  • src/edit_python_pe/constants.py (1 hunks)
  • src/edit_python_pe/main.py (3 hunks)
  • src/edit_python_pe/strings.py (1 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch issue-10

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@jpchauvel jpchauvel merged commit 7e73541 into main Sep 5, 2025
1 check was pending
@jpchauvel jpchauvel deleted the issue-10 branch September 5, 2025 06:25
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.

Add translations

1 participant