Page MenuHomePhabricator

Priority language notice still appears when already translating to the priority language
Closed, ResolvedPublicBUG REPORT

Description

Steps to Reproduce:

  1. Create a page and mark it for translation.
  2. Set the priority translation to French.
  3. Open the page, and click on "Translate this page".
  4. If your language is English, the page will open with "Translate to English" selected and you will see the notice as shown in the image below.
  5. Change the language switcher to French which is the priority language.

mediawiki-bug-translate_2019-01-13.png (201×1 px, 39 KB)

Actual Results:

The notice regarding "Translating to English is not a priority...." still appears.

Expected Results:

The notice should disappear after you select the priority language and should reappear if you change the language from the priority language to a non-priority language.

Event Timeline

abi_ triaged this task as Lowest priority.Feb 25 2019, 3:47 PM
abi_ created this task.
Nikerabbit renamed this task from Priority language notice still appears when already translating to the priority language. to Priority language notice still appears when already translating to the priority language.Feb 28 2019, 8:07 AM

Change 493370 had a related patch set uploaded (by Abijeet Patro; owner: Abijeet Patro):
[mediawiki/extensions/Translate@master] Fix invalid display of priority language notice

https://gerrit.wikimedia.org/r/493370

This patch is now ready for review. Below are a few doubts and observations made during testing / development,

Doubt

If the priority language is also the source language for the page, the priority language notice appears when translating to any other language like it should but shifting the target language to the priority language shows the following notice

The source language of this group is English. Please select another language to translate into.

I think this is OK or should we not allow translators to set the source language as the priority language? Please confirm.

Observations

  1. When Prevent translations to languages other than the priority languages is selected when marking page for translation, and the translator selects a priority language other than the target language, why show the message list at all, since we are anyways not allowing them to save the translations?
  2. Also when we prevent them from saving the translation, we first navigate to the next message and only if the user opens the previous message can they see the error - Saving the translation failed:
  3. The priority notice is also displayed when message documentation is selected as the target language. I think we can avoid showing the notice in such cases.

Test Cases


Terms used

Terms used across the test cases,

  • Priority language - The priority language set for the page.
  • Target language - The language to which the page is currently being translated to.

Test cases below,

TC #1 - Target language and priority language are different

  • Assume your language is en-US.
  • Create a new page.
  • Mark it for Translation with fr as priority.
  • Click on the Translate this page.

Expected Behavior: You should see the Priority language translation notice.

TC #2 - Refreshing the page should maintain state

Follow up from TC #1

  • Refresh the page

Expected Behavior: You should still see the Priority language translation notice.

TC #3 - Target language and priority language are same

Follow up from TC #2

  • Change the target language to fr

Expected Behavior: Priority language notice should no longer be displayed.

TC #4 - Refreshing the page should maintain state

Follow up from TC #3

  • Refresh the page

Expected Behavior: Priority language notice should not appear.

TC #5 - Going from priority language to non-priority language should show the notice

Follow up from TC #4

  • Change the target language to en-GB

Expected Behavior: Priority language notice should be displayed.

TC #6 - Priority notice between message groups.

Follow up from previous test cases.

  • Create another page with a priority language set as FR.
  • Start translating the page. You will see the non-priority language notice.
  • Change the message group to the previously created page.

Expected Behavior: Priority language notice should be displayed.

Other stuff

  1. Tested to ensure that normal translations were working properly by translating a page and saving the translations.
  2. Tested to ensure that when *Prevent translations to languages other than the priority languages* was checked, translations were being properly restricted.

Automated tests

Tried to add automated QUnit tests for this change, but faced the following issues,

While writing test cases for the mw.translate.changeLanguage function but came across a couple of major issues.

  1. Tried lot of approches to fix the problem with the ajax call being made in the DOM Ready from ext.translate.special.translate.js file, but could not find a way to do this. Kept getting an error from testrunner.js - WARN: 'Pending requests does not match jQuery.active count'. This initial ajax call screws up the ajax counters under testrunner.js.
  2. Once we circumvent the above problem, we'll have problems with state.messageList, which is initialized on DOM Ready as a MessageTable. On changeLanguage, the changeSetting method is called on state.messageList. Since during a QUnit run, state.messageList is null, this also crashes the test. This can be fixed by checking if its not null before calling changeSetting in ext.translate.special.translate.js.

I think this is OK or should we not allow translators to set the source language as the priority language? Please confirm.

Currently translations to the the source language are globally disabled: https://github.com/wikimedia/mediawiki-extensions-Translate/blob/master/api/ApiQueryMessageCollection.php#L51-L54 This was done to avoid confusions and people often accidentally translating to in the source language when they forget select the correct target language from the selector. But there have been requests to allow this, so it might change at some point. We could warn the translation admin if they set the source language as a priority language, but I think it is such a rare case for now that it is very low priority to have a such warning or error.

When Prevent translations to languages other than the priority languages is selected when marking page for translation, and the translator selects a priority language other than the target language, why show the message list at all, since we are anyways not allowing them to save the translations?

Even if not allowed to translate, we should still allow inspecting the messages. You can compare this how translatewiki.net Special:Translate works when you are logged out.

Also when we prevent them from saving the translation, we first navigate to the next message and only if the user opens the previous message can they see the error - Saving the translation failed:

The save button should be disabled similarly to the logged out case in the previous point. This can be filed as a separate task request.

The priority notice is also displayed when message documentation is selected as the target language. I think we can avoid showing the notice in such cases.

Agreed. This can be filed as a separate task.

Change 493370 merged by jenkins-bot:
[mediawiki/extensions/Translate@master] Fix invalid display of priority language notice

https://gerrit.wikimedia.org/r/493370

abi_ moved this task from QA to Done on the User-abi_ board.

This is fixed. Tested on meta.wikimedia

When translating to non-priority language,

image.png (466×1 px, 54 KB)

When translating to priority language,

image.png (540×1 px, 52 KB)