Skip to content

fix(i18n): compile fuzzy translations into the backend .mo files#41648

Open
rusackas wants to merge 1 commit into
masterfrom
fix/i18n-serve-fuzzy-backend
Open

fix(i18n): compile fuzzy translations into the backend .mo files#41648
rusackas wants to merge 1 commit into
masterfrom
fix/i18n-serve-fuzzy-backend

Conversation

@rusackas

@rusackas rusackas commented Jul 2, 2026

Copy link
Copy Markdown
Member

SUMMARY

The main Dockerfile compiled backend translations with a bare pybabel compile, which omits #, fuzzy entries — so fuzzy (machine-generated and other draft) translations fell back to English on the backend. This is inconsistent with every other translation build path in the repo:

  • the frontend build (superset-frontend/scripts/po2json.sh) runs po2json --fuzzy, which includes fuzzy entries;
  • flask fab babel-compile — used by the RELEASING images (RELEASING/Dockerfile.from_*_tarball) and scripts/translations/generate_mo_files.sh — runs pybabel compile -f internally (see flask_appbuilder/cli.py).

So the production image was the only path dropping fuzzy translations. This PR adds --use-fuzzy to the Dockerfile's pybabel compile, making the backend serve fuzzy translations consistently with the frontend and the other backend build paths.

Motivation: we're running an AI-assisted backfill across the language catalogs (fuzzy-marked, pending native-speaker review — see the de/lv/fi/es/sk/th/uk/cs PRs). With this change, those draft translations (and any other #, fuzzy entries) are shown in the UI on both frontend and backend rather than falling back to English while awaiting review. #, fuzzy remains the "needs review" marker; reviewers de-fuzz to confirm.

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

Backend-compiled catalogs (BUILD_TRANSLATIONS=true):

  • Before: #, fuzzy entries excluded → English fallback in server-rendered strings.
  • After: #, fuzzy entries included → translated string served (matching the frontend).

TESTING INSTRUCTIONS

# fuzzy entry is included with --use-fuzzy, excluded without it
pybabel compile --use-fuzzy --statistics -d superset/translations

Build the image with --build-arg BUILD_TRANSLATIONS=true and confirm a #, fuzzy backend string renders translated rather than in English.

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
  • Introduces new feature or API
  • Removes existing feature or API
The main Dockerfile compiled backend translations with a bare `pybabel compile`,
which omits `#, fuzzy` entries — so fuzzy (machine-generated and other draft)
translations fell back to English on the backend. This was inconsistent with
every other translation build path in the repo:

- the frontend build (`po2json --fuzzy`) includes fuzzy entries;
- `flask fab babel-compile` (used by the RELEASING images and
  scripts/translations/generate_mo_files.sh) runs `pybabel compile -f`.

Add `--use-fuzzy` to the Dockerfile's `pybabel compile` so the production image
serves fuzzy translations consistently with the frontend and the other backend
build paths. This makes the AI backfill effort (and any other draft
translations) visible in the UI rather than falling back to English while they
await native-speaker review. Docs updated to match.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@dosubot dosubot Bot added doc:developer Developer documentation i18n Namespace | Anything related to localization labels Jul 2, 2026
@bito-code-review

bito-code-review Bot commented Jul 2, 2026

Copy link
Copy Markdown
Contributor

Code Review Agent Run #24cb17

Actionable Suggestions - 0
Review Details
  • Files reviewed - 1 · Commit Range: 7756ca8..7756ca8
    • Dockerfile
  • Files skipped - 1
    • docs/developer_docs/contributing/howtos.md - Reason: Filter setting
  • Tools
    • Whispers (Secret Scanner) - ✔︎ Successful
    • Detect-secrets (Secret Scanner) - ✔︎ Successful

Bito Usage Guide

Commands

Type the following command in the pull request comment and save the comment.

  • /review - Manually triggers a full AI review.

  • /pause - Pauses automatic reviews on this pull request.

  • /resume - Resumes automatic reviews.

  • /resolve - Marks all Bito-posted review comments as resolved.

  • /abort - Cancels all in-progress reviews.

Refer to the documentation for additional commands.

Configuration

This repository uses Superset You can customize the agent settings here or contact your Bito workspace admin at evan@preset.io.

Documentation & Help

AI Code Review powered by Bito Logo

@github-actions github-actions Bot added doc Namespace | Anything related to documentation and removed i18n Namespace | Anything related to localization labels Jul 2, 2026
@netlify

netlify Bot commented Jul 2, 2026

Copy link
Copy Markdown

Deploy Preview for superset-docs-preview ready!

Name Link
🔨 Latest commit 7756ca8
🔍 Latest deploy log https://app.netlify.com/projects/superset-docs-preview/deploys/6a45ac8d7b404e000822e3b9
😎 Deploy Preview https://deploy-preview-41648--superset-docs-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

Comment thread Dockerfile
COPY superset/translations/ /app/translations_mo/
RUN if [ "${BUILD_TRANSLATIONS}" = "true" ]; then \
pybabel compile -d /app/translations_mo | true; \
pybabel compile --use-fuzzy -d /app/translations_mo | true; \

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggestion: Using a pipe to true is a shell logic bug: it masks pybabel compile failures and can also trigger a broken-pipe termination if pybabel writes output, leading to silently missing or incomplete .mo files while the Docker build still succeeds. Replace the pipeline with proper error handling (or explicit || true only if failure is truly acceptable) so compile errors are not hidden by accident. [logic error]

Severity Level: Critical 🚨
- ❌ Docker image may ship without updated translation `.mo` files.
- ⚠️ Translation compilation failures are hidden during Docker build.
- ⚠️ Debugging broken translations harder due to masked errors.
Steps of Reproduction ✅
1. In `/workspace/superset/docker-compose.yml` set `BUILD_TRANSLATIONS=true` (env entries
at lines 46 and 197 from Grep) and build the Superset image using
`/workspace/superset/Dockerfile`, which defines the `python-translation-compiler` stage at
lines 13–27 with `ARG BUILD_TRANSLATIONS` (line 15) and the RUN block at lines 24–27.

2. Introduce an invalid or malformed `.po` file under `superset/translations/` (copied
into the image by `COPY superset/translations/ /app/translations_mo/` at `Dockerfile` line
23) so that `pybabel compile --use-fuzzy -d /app/translations_mo` would normally exit with
a non-zero status.

3. Run `docker build` (or `docker compose build`) so the RUN command at `Dockerfile` lines
24–27 executes: `if [ "${BUILD_TRANSLATIONS}" = "true" ]; then pybabel compile --use-fuzzy
-d /app/translations_mo | true; fi; rm -f /app/translations_mo/*/*/*.[po,json]`. Because
of the pipeline, the shell returns the exit status of `true` (always 0), masking any
`pybabel compile` failure, and the Docker build layer still succeeds.

4. Start a container from the built image and access any backend-rendered page that relies
on compiled translations; observe missing or English-fallback strings due to failed `.mo`
compilation, while the earlier Docker build reported success, demonstrating that piping
`pybabel compile` into `true` silently hides translation compilation errors.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** Dockerfile
**Line:** 144:144
**Comment:**
	*Logic Error: Using a pipe to `true` is a shell logic bug: it masks `pybabel compile` failures and can also trigger a broken-pipe termination if `pybabel` writes output, leading to silently missing or incomplete `.mo` files while the Docker build still succeeds. Replace the pipeline with proper error handling (or explicit `|| true` only if failure is truly acceptable) so compile errors are not hidden by accident.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎
@bito-code-review

Copy link
Copy Markdown
Contributor

The flagged issue is correct. Piping pybabel compile to true masks any compilation errors, which can lead to silent failures where the Docker build succeeds despite missing or incomplete translation files.

To resolve this, you should remove the pipe to true and allow the command to exit with its native status. If you want to ensure the build continues even on failure, you should explicitly handle the error or use || true only if you have verified that failure is acceptable in that specific context.

Proposed Fix

In Dockerfile, update the RUN command to remove the pipe:

RUN if [ "${BUILD_TRANSLATIONS}" = "true" ]; then \
        pybabel compile --use-fuzzy -d /app/translations_mo; \
    fi; \
    rm -f /app/translations_mo/*/*/*.[po,json]

There are no other comments in this pull request to address.

Dockerfile

RUN if [ "${BUILD_TRANSLATIONS}" = "true" ]; then \
        pybabel compile --use-fuzzy -d /app/translations_mo; \
    fi; \
    rm -f /app/translations_mo/*/*/*.[po,json]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

doc:developer Developer documentation doc Namespace | Anything related to documentation size/S

2 participants