Skip to content

Add Copy from a Similar Locale batch action#4152

Open
MundiaNderi wants to merge 4 commits into
mozilla:mainfrom
MundiaNderi:simplify-2255
Open

Add Copy from a Similar Locale batch action#4152
MundiaNderi wants to merge 4 commits into
mozilla:mainfrom
MundiaNderi:simplify-2255

Conversation

@MundiaNderi
Copy link
Copy Markdown
Collaborator

Fixes #2255

Enables translators working on closely related locales (eg en-GB and en-ZA) to reuse approved translations from one locale as a starting point in another as suggestions.

How to test / how I tested:

  • Added test_copy_from_similar_locale in pontoon/batch/tests/test_utils.py
  • Manually tested by copying from sl into af on the tutorial project — 1 string copied and confirmed as approved=False in the database

Steps to reproduce

  • Navigate to a project under a locale that has no approved translations (e.g. af/tutorial)
  • Select one or more strings
  • In the batch actions panel, enter a source locale code (e.g. sl) under "Copy From a Similar Locale"
  • Click the button. Strings approved in the source locale should appear as suggestions in the target locale

@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented May 11, 2026

Codecov Report

❌ Patch coverage is 71.42857% with 20 lines in your changes missing coverage. Please review.
✅ Project coverage is 79.52%. Comparing base (4cbb284) to head (7bc9b69).
⚠️ Report is 9 commits behind head on main.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Enables translators working on closely related locales (eg en-GB and en-ZA)
to reuse approved translations from one locale as a starting point in another
as suggestions.

Fixes mozilla#2255
@MundiaNderi MundiaNderi self-assigned this May 11, 2026
@MundiaNderi MundiaNderi requested review from eemeli and mathjazz May 11, 2026 20:30
Copy link
Copy Markdown
Collaborator

@mathjazz mathjazz left a comment

Choose a reason for hiding this comment

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

Thanks for the patch!

I haven't closely looked at the code yet. I'd suggest we make some changes to the UI:

Please change the section title and use the locale selector instead of the input box:
Image

Please note that Source locale should be the default option.

Please also update the docs:
https://pontoon.mozilla.org/docs/localizer/translate/?h=batch#performing-batch-actions-on-strings

Question: is it only possible to add suggestions to strings that don't have any existing translations? If yes, why?

@MundiaNderi
Copy link
Copy Markdown
Collaborator Author

MundiaNderi commented May 19, 2026

Thanks for the patch!

I haven't closely looked at the code yet. I'd suggest we make some changes to the UI:

Please change the section title and use the locale selector instead of the input box: Image

Please note that Source locale should be the default option.

Please also update the docs: https://pontoon.mozilla.org/docs/localizer/translate/?h=batch#performing-batch-actions-on-strings

Question: is it only possible to add suggestions to strings that don't have any existing translations? If yes, why?

Yes, it's only possible to copy to strings that don't already have an active translation, because of the unique constraint on (entity_id, locale_id, active).

@mathjazz mathjazz self-requested a review May 20, 2026 05:14
Copy link
Copy Markdown
Collaborator

@mathjazz mathjazz left a comment

Choose a reason for hiding this comment

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

Approved by mistake.

@mathjazz
Copy link
Copy Markdown
Collaborator

Yes, it's only possible to copy to strings that don't already have an active translation, because of the unique constraint on (entity_id, locale_id, active).

The warning on top of the Batch actions editor panel says changes will be applied to all strings, which is what other actions do, too. So I'd keep that behaviour, and adapt active translations as needed.

@mathjazz
Copy link
Copy Markdown
Collaborator

Thanks for the udpate! Could you please make the locale selector and dropdown look & feel aligned with the locale selector used elsewhere, e.g. in the Setttings and Search pages?

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.

Simplify translation process for similar locales

3 participants