Page MenuHomePhabricator

Providing machine translation for Community Wishlist mainspace pages on demand
Closed, ResolvedPublic

Description

User Story:

As a user, I want to be able to read any wish or other text on the page in my own language so that I understand the full context of the wish or easily find my way around.

This does not cover translating talk pages; that's being handled in: T371006: Translating comments on talk pages on demand

To be discussed is which pieces need translation, we already know:

  • Dashboard and all-wishes page: wish titles in tables
  • Individual wish pages: title, description, and audience
  • Focus area pages (although not the comments people leave on votes; those are more like talk page content and will be handled alongside talk pages)

Acceptance criteria:

  • Show translate button at the top of the page if there is any text that is not in the current UI language
  • On clicking translate button, replace the original text with translated text and toggle the state of the translate button
  • Show automatic translation disclaimer
  • Show the source and target language as a link. Clicking the link will show the language selector Only required for talk pages; tracked in T371101
  • Clicking the translate button again switches back to seeing the original language
  • When showing original language, the translated text will be replaced by the original text and translate button will be toggled to its initial state

Details for QA:

Aside from all the items in the acceptance criteria please also check:

  • That the translation of the source text is fully shown without any truncation
  • Wishes that have not yet been marked for translation should work as well (they'll have translate buttons everywhere other than when being viewed in a page that's already in their base language). This is the same as after a wish has been marked for translation but has not yet been translated.
  • It should also be possible to translate to any valid language from any translation of a page (e.g. if you're on the /es translation, it can still have automatic translation applied)

Designs:

https://www.figma.com/design/JcTMFwbEJPpCKBiZ16Jkel/Future-of-the-Wishlist?node-id=3070-70687&t=33MJMSFMIW415rDy-1

Derived Requirement

Allow users to translate any wish or text on the page into their preferred language, excluding talk page comments, by providing a "translate" button that toggles between the original and translated text while displaying relevant language information.

BDD

Feature: Translation of Wishes and Page Text

Scenario: Display translate button for content that is not in the current UI language

Given the user is on a wish or other related page
And there is content not in the current UI language
When the page loads
Then a translate button should be shown at the top of the page

Scenario: Translate page content on clicking the translate button

Given the user is on a wish or related page with a translate button
When the user clicks the translate button
Then the original text should be replaced with translated text
And a translation disclaimer should be shown
And the button should toggle to its translated state

Scenario: Switch back to original language by clicking translate button again

Given the user has translated a page's content
When the user clicks the translate button again
Then the translated text should be replaced by the original text
And the button should toggle to its initial state
Test Steps

Test Case 1: Display Translate Button for Non-UI Language Content

Navigate to the all-wishes page with content not in the current UI language.
✅❓❌⬜ AC1: Confirm the translate button is displayed at the top of the page.
Test Case 2: Replace Original Text with Translated Text

On the all-wishes page, click the translate button.
✅❓❌⬜ AC2: Confirm the original text is replaced with translated text.
✅❓❌⬜ AC3: Confirm a translation disclaimer is shown.
Test Case 3: Toggle Back to Original Language

After translating the page, click the translate button again.
✅❓❌⬜ AC4: Confirm the translated text is replaced with the original text.
✅❓❌⬜ AC5: Confirm the translate button is toggled back to its initial state.

Test Case 4: Validate Translation of Different Pages (ex. Talk)

  1. Click on a specific wish and go to the Discussion tab
  2. ❌ AC5: Confirm the translate icon, and the original text is replaced with translated text

Ensure that no truncation occurs when translating content by observing translated text on multiple wishes.
✅❓❌⬜ AC6: Confirm the full text is visible and not cut off after translation.
Test Case 6: Check Translation for Wishes Not Marked for Translation

Verify that translation works for wishes that have not yet been marked for translation.
✅❓❌⬜ AC7: Confirm that translation occurs and buttons behave correctly even when the wish isn't marked for translation.
Test Case 7: Translation from an Already Translated Page

Navigate to a page in a non-UI language, such as /es, and verify the translation button still works.
✅❓❌⬜ AC8: Ensure that translation can still be applied, even if the page is already in a non-UI language.

QA Results - Wishlist-test.toolforge

Event Timeline

KSiebert renamed this task from Providing automatic translation anywhere within community wishlist on demand to Providing machine translation anywhere within community wishlist on demand.Jul 30 2024, 10:45 AM

@JSengupta-WMF: Assuming this task is about the Community Wishlist code project, hence adding that project tag so other people who don't know or don't care about team tags can also find this task when searching via projects or looking at workboards. Please set appropriate project tags when possible. Thanks!

KSiebert updated the task description. (Show Details)
Samwilson renamed this task from Providing machine translation anywhere within community wishlist on demand to Providing machine translation for Community Wishlist mainspace pages on demand.Aug 19 2024, 5:42 AM
Samwilson updated the task description. (Show Details)

In order to keep the scope (and bug impact) of this to a low level, I'm thinking of two things:

  1. The parts of the pages that we want to translate will be wrapped in <div class="wishlist-translatable" lang="xx"> where the lang is optional (if absent, the source language will be taken from the parent .mw-parser-output element). This would apply to:
    • The title cell of Wish tables;
    • The title, description, and audience of the Wish pages;
    • All the main sections of the focus area pages.
    • Notably, it wouldn't apply to the headings, buttons, and other UI elements because for these we're handling translation separately (currently via on-wiki translation on Meta, and soon via the #CommunityRequests extension and TranslateWiki.net).
  2. The translation button will be displayed "next to" each of the above elements. The scare quotes are because I'm not quite sure how this will pan out, but will start by just showing it inline at the beginning (this will probably not work all the time, because although lots of these bits of text are paragraphs they could also be lists or anything else, in which case the translate button will likely appear as a block item above them; perhaps that's fine).

The first item means we can specify the baselang or lang within the Row template (see !253) and the translate button will be added to the tables (these tables are a bit different from normal in that the Translate extension doesn't come into play and so doesn't wrap any transclusions in lang="").

The current designs don't have any translate buttons on the wish pages, but I assume that's an oversight. Alternatively, we could show only the banner at the top with something like "This page may contain parts that are not in [current UI lang], would you like to translate them?" with the translate button up there. That seems to be how the current designs show it, but they only show the flow after translation has been applied (and my understanding is that we'll also want to apply the translation based on a URL parameter so that we can link people from elsewhere to a translated-on-load page).

Show automatic translation disclaimer

Where is the text of this disclaimer?

Change #1070095 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/extensions/CommunityRequests@master] Add messages for the translation gadget

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

Change #1070095 merged by jenkins-bot:

[mediawiki/extensions/CommunityRequests@master] Add messages for the translation gadget

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

The test site is updated with the latest code (for the new gadget, and the CommunityRequests extension) so the initial behaviour of this feature can now be tested there. Still to come:

  • Improve the selection of what parts of text are sent for translation.
  • Limit how many API requests are sent at once (batches of ten or something).
  • Make the new gadget opt-in to start with, to make testing easier.

Some other things will be done after this task is resolved, e.g. T374183: Do not offer to translate if the target language is not supported

The other bug that comes up a bit is on wishlist pages (especially focus areas) that are transcluding a bunch of text from template that's itself translcuded and is not fully translated. This is tracked in T373656 and is probably a bit complicated to fix. It basically means that we don't know what the source language is of some parts of text (and we don't know that we don't know). Doesn't apply to fully-translated templates though, so the workaround is to aim for 100% translation.

I've updated the description and acceptance criteria a bit. The main change is that we've decided to not have the button next to every single bit of text that can be translated, because often there are a large number (e.g. the whole page) and it not only looks too cluttered but is also annoying to have to click so many times.

There is still work to be done in rationalising the segments of the page that are translated, but that will be done in future tasks. This is mostly about the banner, the translating, and at least some amount of error reporting (in QA, you may be able to get it to fail on some large pages, although it is not happening all the time I think).

I've created meta:MediaWiki:Gadget-WishlistTranslation and meta:MediaWiki:Gadget-WishlistTranslation.js and added it to the 'Language support' section of Gadgets-definition (not on by default).

@Samwilson Can you please review some of the below to see if I captured everything that needed to be tested? I did come across a couple of errors in AC3 and AC5. Also, I'm a little confused about how to test AC7 if you don't mind giving me a little more info, thanks!

Test Result - Wishlist-test.toolforge

Status: ✅ PASS
Environment: Wishlist-test.toolforge
OS: macOS Sonoma 14.6.1
Browser: Chrome 128
Device: MBA
Emulated Device: NA

Test Artifact(s):

Test Steps

Test Case 1: Display Translate Button for Non-UI Language Content

Navigate to the all-wishes page with content not in the current UI language.
✅ AC1: Confirm the translate button is displayed at the top of the page.

logged outlogged in
2024-09-12_13-13-29.png (616×1 px, 199 KB)
2024-09-12_13-14-17.png (642×1 px, 215 KB)

Test Case 2: Replace Original Text with Translated Text

On the all-wishes page, click the translate button.
✅ AC2: Confirm the original text is replaced with translated text.

2024-09-12_13-31-43.mp4.gif (454×1 px, 696 KB)

❌ AC3: Confirm a translation disclaimer is shown.

I did not get the Automatic translation from German to English disclaimer similar to Figma

CurrentFigma
2024-09-12_13-32-41.png (390×694 px, 79 KB)
2024-09-12_13-33-19.png (158×479 px, 12 KB)

Test Case 3: Toggle Back to Original Language

After translating the page, click the translate button again.
✅ AC4: Confirm the translated text is replaced with the original text.

2024-09-12_13-38-06.mp4.gif (408×994 px, 743 KB)

✅ AC5: Confirm the translate button is toggled back to its initial state.
see AC4

Test Case 4: Validate Translation of Different Pages (ex. Talk)

Click on a specific wish and go to Discussion tab
❌ AC5: Confirm translate icon and the original text is replaced with translated text.

ToolforgeFigma
2024-09-12_15-05-22.png (455×902 px, 120 KB)
2024-09-12_14-58-02.png (315×663 px, 68 KB)

Test Case 5: Verify Truncation of Translated Text

Ensure that no truncation occurs when translating content by observing translated text on multiple wishes.
✅ AC6: Confirm the full text is visible and not cut off after translation.
see AC2

Test Case 6: Check Translation for Wishes Not Marked for Translation

Verify that translation works for wishes that have not yet been marked for translation.
❓ AC7: Confirm that translation occurs and buttons behave correctly even when the wish isn't marked for translation.
Not sure how to test this

Test Case 7: Translation from an Already Translated Page

Navigate to a page in a non-UI language, such as /es, and verify the translation button still works.
✅ AC8: Ensure that translation can still be applied, even if the page is already in a non-UI language.

2024-09-12_13-59-12.mp4.gif (456×1 px, 989 KB)

❌ AC3: Confirm a translation disclaimer is shown.
I did not get the Automatic translation from German to English disclaimer similar to Figma

Thanks! Fixing this now.

Test Case 4: Validate Translation of Different Pages (ex. Talk)
Click on a specific wish and go to Discussion tab
❌ AC5: Confirm translate icon and the original text is replaced with translated text.

Talk pages are out of scope for this task.

❓ AC7: Confirm that translation occurs and buttons behave correctly even when the wish isn't marked for translation.
Not sure how to test this

This is basically just confirming that the machine translation is independent of the page translation. Some wishes are marked for translation, and so have the possibility of being translated (by humans). The machine translation works on these, and also works if a page hasn't been translated at all or even prepared for translation.

I think all the tests you've done are probably sufficient; there is no special handling for translated or un-translated pages, so there shouldn't be any difference.

@JSengupta-WMF Currently the translate button is a ToggleButton that goes between untranslated and translated, and its text does not change (the docs say that "the label text should not change depending on the button’s toggled state"). In the designs this isn't a button but a link that says "Show original text". We can change to that, but there's no design for what it should look like before that point (i.e. we were going on the idea that the choice to translate would only ever happen by navigating from the dashboard, but that's not the case — it's possible to translate a page regardless of the navigation path taken to get there).

The messages at the moment are:

This page contains text that is not in your current interface language. You can translate it now using Wikimedia's machine translation tool.
[Translate]
This page contains $1 {{PLURAL:$1|part|parts}} of text that have been machine translated.

The last line is only shown while the button is toggled on.

Do we need to:

  • Add in the name of the target language
  • Add in the names of the source languages (there might be more than one on a page)
  • Link "machine translation tool" to https://www.mediawiki.org/wiki/MinT

@Samwilson as per our discussion here is a modified banner to address your questions.

Screenshot 2024-09-17 at 15.55.30.png (172×1 px, 32 KB)

Change #1074985 had a related patch set uploaded (by Samwilson; author: Samwilson):

[mediawiki/extensions/CommunityRequests@master] Add language name to article space machine translation banner

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

A patch is ready for review for adding the toggle switch and updated messages, as well as the remembering functionality that keeps the toggle state between page loads.

Change #1074985 merged by jenkins-bot:

[mediawiki/extensions/CommunityRequests@master] Add switch button and lang name to machine translation banner

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

This is not ready for deploying in the gadget yet, as we're waiting for the new messages to ride the train, but it can be QA'd on the test site now.

@GMikesell-WMF: we've added a 'sticking' switch. Some random QA notes:

  • The translation banner should appear on any page with the __MACHINETRANSLATION__ magic word, e.g. https://wishlist-test.toolforge.org/wiki/Translation_testing (or any page that transcludes a template that contains that magic word, which is how this'll be deployed to Meta when we get to doing that).
  • Translations of such a page should also get the banner.
  • The interface language is always the target for the translations, regardless of the page language, e.g. https://wishlist-test.toolforge.org/wiki/Translation_testing/de?uselang=mr translates the French and German bits to Marathi (and note that it doesn't translate the English bit because that's not actually marked for translation, and so when viewing the /de version of the page that bit of text appears to be in German; this is a known limitation).
  • Note that some langauges are not supported, for example Austrian German, so https://wishlist-test.toolforge.org/wiki/Translation_testing/de-at?uselang=de-at doesn't offer the translation banner.
  • The switch state should persist between page loads and when you navigate to any other page. If you turn it off it stays off, if it's on it stays on.

I've added some user documentation at https://www.mediawiki.org/wiki/Help:Extension:CommunityRequests and feel free to edit them if there's anything missing.

@Samwilson Thanks for the great information! These look like they are working as designed now based on the gifs and screenshots below. I will move this to Done. Thanks for all your work!

  • The translation banner should appear on any page with the __MACHINETRANSLATION__ magic word, e.g. https://wishlist-test.toolforge.org/wiki/Translation_testing (or any page that transcludes a template that contains that magic word, which is how this'll be deployed to Meta when we get to doing that).
  • Translations of such a page should also get the banner.

2024-09-30_11-27-10.mp4.gif (450×1 px, 375 KB)

  • The interface language is always the target for the translations, regardless of the page language, e.g. https://wishlist-test.toolforge.org/wiki/Translation_testing/de?uselang=mr translates the French and German bits to Marathi (and note that it doesn't translate the English bit because that's not actually marked for translation, and so when viewing the /de version of the page that bit of text appears to be in German; this is a known limitation).

2024-09-30_11-09-27.mp4.gif (466×1 px, 349 KB)

I've added some user documentation at https://www.mediawiki.org/wiki/Help:Extension:CommunityRequests and feel free to edit them if there's anything missing.

2024-09-30_11-24-43.png (490×1 px, 105 KB)
|
2024-09-30_11-28-52.png (435×1 px, 95 KB)

GMikesell-WMF updated Other Assignee, removed: GMikesell-WMF.
GMikesell-WMF updated the task description. (Show Details)
GMikesell-WMF moved this task from QA to Done on the Community-Tech (Jackal (not a fox) Fox) board.