Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Oct 7, 2025

Overview

This PR adds automated translation validation that checks for common translation issues in ARB files. As requested in #5903, the validation is non-blocking and serves as informational annotations on translation pull requests rather than blocking CI/CD.

Problem

Translation files can have several common issues that are difficult to catch manually:

  • Brand names like "Open Food Facts" being translated when they should remain unchanged
  • Technical terms like "Nutri-Score" and "NOVA" being translated
  • Broken or malformed URLs
  • Missing required keys in translation files

These issues affect consistency and quality but shouldn't necessarily block translation updates, as some may be intentional based on language requirements.

Solution

Added a GitHub Action workflow that automatically validates translations and posts results as PR comments:

  1. Validation Script (.github/scripts/validate_translations.py): Python script that validates:

    • App name consistency: app_name should always be "Open Food Facts" (not translated)
    • Brand term preservation: Terms like Nutri-Score, NOVA, Open Food Facts, Open Products Facts, Open Beauty Facts, and Open Pet Food Facts should be preserved
    • URL validation: All URLs should be properly formatted and not broken
    • File completeness: All ARB files should have required keys
  2. GitHub Workflow (.github/workflows/translation-validation.yml):

    • Triggers automatically when translation files (.arb) are modified in PRs
    • Runs the validation script
    • Posts/updates a comment on the PR with validation results
    • Never blocks or fails the PR

Non-Blocking Behavior

The workflow always succeeds but posts informative comments on PRs with validation results:

## 🔍 Translation Validation Report

This is an automated check of translation quality. Issues found are informational and don't block the PR.

### ⚠️ App Name Should Not Be Translated

The `app_name` key should always be `"Open Food Facts"` (not translated).

Found 120 file(s) with translated app_name:

  - `app_fr.arb`: "Informations sur les aliments ouverts"
  - `app_es.arb`: "Datos alimentarios abiertos"
  ...

This approach allows:

  • Translation updates to proceed without blocking
  • Reviewers to make informed decisions about translation quality
  • Gradual improvement of translations over time
  • Human judgment on language-specific requirements

Files Added

  • .github/workflows/translation-validation.yml - GitHub Action workflow that runs on translation PRs
  • .github/scripts/validate_translations.py - Python validation script

Benefits

  • ✅ Automatic validation on all translation PRs (including Crowdin PRs)
  • ✅ Results posted as PR comments for easy review
  • ✅ Non-blocking - never fails the build
  • ✅ Auto-updates when PR is synchronized
  • ✅ No need to check CI logs or test output

Example Output

The workflow posts a detailed report directly on the PR, making it easy for reviewers to spot issues:

### ⚠️ Brand Term "Nutri-Score" Should Be Preserved

Found 38 translation(s) where "Nutri-Score" was not preserved:

  - `app_fi.arb`: `product_improvement_add_category`
    - English: "Add a category to calculate the Nutri-Score."
    - Translation: "Lisää luokka laskeaksesi Nutri-pisteytyksen."
  ...

Future Enhancements

The validation script makes it easy to add new validation rules as needed. The modular structure allows adding checks for:

  • New brand terms or product names
  • Additional required keys
  • Language-specific validation rules
  • Custom URL patterns

Fixes #5903

Original prompt

This section details on the original issue you should resolve

<issue_title>Translation tests</issue_title>
<issue_description>Can you write tests for the translation files:

  • app_name is always Open Food Facts
  • strings containing Nutri-Score, Green-Score, NOVA, Open Food Facts, Open Products Facts, Open Beauty Facts, Open Pet Food Facts, Open Prices have translations that also contain those terms
  • that no urls are broken in translations

Those test should not be blocking. I would more see it as annotations on translations pull requests.
Translations files are located at: packages/smooth_app/lib/l10n/app_xx.arb</issue_description>

Comments on the Issue (you are @copilot in this section)

Fixes #7024

💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.

Copilot AI changed the title [WIP] Add tests for translation files in smooth app Add non-blocking translation validation tests for ARB files Oct 7, 2025
Copilot AI requested a review from teolemon October 7, 2025 09:22
Copilot finished work on behalf of teolemon October 7, 2025 09:22
@teolemon
Copy link
Member

teolemon commented Oct 7, 2025

@copilot I was expecting a Github action solution rather than a dart solution.

Copy link
Contributor Author

Copilot AI commented Oct 7, 2025

@copilot I was expecting a Github action solution rather than a dart solution.

I've replaced the Dart test solution with a GitHub Action approach (commit c7a7785).

The new solution:

  • Creates a Python validation script (.github/scripts/validate_translations.py)
  • Adds a workflow (.github/workflows/translation-validation.yml) that:
    • Triggers on PRs that modify translation files
    • Runs the validation script
    • Posts/updates a comment on the PR with validation results

This will automatically comment on Crowdin translation PRs with informational warnings about app_name translations, brand term preservation, and URL validation - without blocking the PR.

Copilot AI changed the title Add non-blocking translation validation tests for ARB files Add GitHub Action for non-blocking translation validation on PRs Oct 7, 2025
Copilot finished work on behalf of teolemon October 7, 2025 11:33
@github-actions github-actions bot added the GitHub label Oct 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: 💬 To discuss and validate

Development

Successfully merging this pull request may close these issues.

Translation tests Replace the exclamation mark by a store

2 participants