Skip to content

Add Copy from a Similar Locale batch action#4152

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

Add Copy from a Similar Locale batch action#4152
MundiaNderi wants to merge 7 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

codecov-commenter commented May 11, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 70.33898% with 35 lines in your changes missing coverage. Please review.
✅ Project coverage is 80.56%. Comparing base (718eb0d) to head (961084d).
⚠️ Report is 1 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.

@MundiaNderi MundiaNderi self-assigned this May 11, 2026
@MundiaNderi MundiaNderi requested review from eemeli and mathjazz May 11, 2026 20:30

@mathjazz mathjazz left a comment

Copy link
Copy Markdown
Collaborator

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

MundiaNderi commented May 19, 2026

Copy link
Copy Markdown
Collaborator Author

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

@mathjazz mathjazz left a comment

Copy link
Copy Markdown
Collaborator

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?

@mathjazz

mathjazz commented Jun 8, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the update!

  • It looks like I cannot copy from source locale? Nothing happens when I click the Copy as auggestions button when Source locale is selected.
  • Source locale is also not present in the dropdown, so I cannot switch back to it.
  • When the string has an approved translation, we should just add a suggestion, not reject the existing translation.

There are also a few CSS improvements I'd like to make, but I can push these directly.

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