Skip to content

Commit c264620

Browse files
committed
Merge branch 'ayshushus-4506-ghost-text' into dev
2 parents 35977a1 + d5cd8be commit c264620

21 files changed

Lines changed: 829 additions & 14 deletions

File tree

‎documentation/docs/localizer/translation-workspace.md‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ In the lower-right side of the editing space, it’s possible to `COPY` the sour
167167

168168
In the lower-left side:
169169

170-
* Clicking the gear icon allows users to toggle `Translation Toolkit checks` and `Make suggestions`, select their editor theme, and navigate to the user settings. Note that access to some settings is restricted by [user permissions](users.md#user-roles).
170+
* Clicking the gear icon allows users to toggle `Translation Toolkit checks`, `Make suggestions` and [`Autocomplete from Machinery`](#autocomplete-from-machinery), select their editor theme, and navigate to the user settings. Note that access to some settings is restricted by [user permissions](users.md#user-roles).
171171
* Clicking the keyboard icon displays a list of available shortcuts.
172172
* The numbers displayed to the right of the keyboard icon (e.g. `50|59`) are the number of characters in the target and source string.
173173

@@ -284,6 +284,8 @@ Machinery shows possible translations from a variety of sources. These sources i
284284
* [Caighdean](https://github.com/kscanne/caighdean).
285285
* [Bing Translator](https://www.bing.com/translator) (not currently enabled on pontoon.mozilla.org).
286286

287+
Machinery suggestions can be used to [complete translations as you type](#autocomplete-from-machinery) in the editor.
288+
287289
In addition, the user has the ability to search for translations containing words via [`Concordance search`](#concordance-search).
288290

289291
In the tab, the number of entries is visible alongside the `MACHINERY` title in white. If any of the machinery matches are from translation memory, the number of matches will appear separately in green. For example, the screenshot below shows `2+1`, where the green `2` represents the two matches from translation memory and the `1` represents a machinery entry from Google Translate.
@@ -298,6 +300,20 @@ The origin of the machinery entry is listed in gray above the source string. Cli
298300

299301
Be careful when using the machinery tab as suggestions may not match the source string for the project being translated. Even if the source strings match, the context in which strings are used may not be the same. This could lead to incorrect or unnatural translations. Always keep the meaning and purpose of the string being translated in mind when using the machinery tab.
300302

303+
#### Autocomplete from Machinery
304+
305+
When `Autocomplete from Machinery` is enabled in the [Editor's gear icon](#editor) (or in the [settings page](users.md#editor)), the editor offers to complete what you type using the Machinery suggestions for the current string: translation memory, machine translation, and automatic LLM suggestions.
306+
307+
As you type, the end of the text before the cursor is compared with each suggestion, and the suggestion with the longest match is used. Depending on how long the matching part is, the editor shows in gray after the cursor:
308+
309+
* Nothing, if the match is short.
310+
* The rest of the word being typed, if the match is longer.
311+
* The next word, if the match is long and the word being typed is already complete.
312+
313+
Press `Tab` to accept the gray text, or `Esc` to hide it. Once accepted, the following word is offered, so pressing `Tab` repeatedly follows a suggestion word by word, and typing something else at any point simply continues with your own translation. Placeholders and tags are always completed as a whole.
314+
315+
While the list of placeholder completions is open, `Tab` selects from that list instead. Nothing is offered during a Concordance search, since its results are not translations of the current string.
316+
301317
#### Large language model (LLM) integration
302318

303319
Pontoon will show a dropdown labeled `AI` for all locales that have Google Translate available as a translation source. This feature refines the Google Translate output using an LLM. Opening this dropdown will reveal three options:

‎documentation/docs/localizer/users.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,8 @@ To change a theme, select the button corresponding to your preferred option. The
8686

8787
`Make suggestions` allows a translator or a team manager to submit suggestions instead of translations. This setting is also displayed to users with translator permissions.
8888

89+
`Autocomplete from Machinery` completes words in the editor as the user types, using the Machinery suggestions for the current string. It is disabled by default. For more information, see [this document](translation-workspace.md#autocomplete-from-machinery).
90+
8991
### Default search options
9092

9193
Users can configure default search options to use when searching for strings in the translation workspace or the [Translation Search page](search.md). The following options can be enabled by default:
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Generated by Django 5.2.18 on 2026-10-26 21:37
2+
3+
from django.db import migrations, models
4+
5+
6+
class Migration(migrations.Migration):
7+
dependencies = [
8+
("base", "0138_mark_anonymous_user_as_system_user"),
9+
]
10+
11+
operations = [
12+
migrations.AddField(
13+
model_name="userprofile",
14+
name="machinery_autocomplete",
15+
field=models.BooleanField(default=False),
16+
),
17+
]

‎pontoon/base/models/user_profile.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ class EmailFrequencies(models.TextChoices):
127127
# Translation settings
128128
quality_checks = models.BooleanField(default=True)
129129
force_suggestions = models.BooleanField(default=False)
130+
machinery_autocomplete = models.BooleanField(default=False)
130131

131132
# Search settings
132133
search_exclude_source_strings = models.BooleanField(default=False)

‎pontoon/base/views.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1178,6 +1178,7 @@ def user_data(request):
11781178
"settings": {
11791179
"quality_checks": user.profile.quality_checks,
11801180
"force_suggestions": user.profile.force_suggestions,
1181+
"machinery_autocomplete": user.profile.machinery_autocomplete,
11811182
"search_exclude_source_strings": user.profile.search_exclude_source_strings,
11821183
"search_identifiers": user.profile.search_identifiers,
11831184
"search_match_case": user.profile.search_match_case,

‎pontoon/contributors/templates/contributors/settings.html‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -374,6 +374,15 @@ <h3>Editor</h3>
374374
title='Save suggestions instead of translations')
375375
}}
376376
{% endif %}
377+
378+
{{
379+
Checkbox.checkbox(
380+
'Autocomplete from Machinery',
381+
class='machinery-autocomplete',
382+
attribute='machinery_autocomplete',
383+
is_enabled=user.profile.machinery_autocomplete,
384+
title='Complete words from Machinery translations as you type')
385+
}}
377386
</div>
378387
</section>
379388

‎pontoon/contributors/tests/test_views.py‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,27 @@ def test_toggle_user_profile_attribute(member):
269269
assert response.status_code == 200
270270

271271

272+
@pytest.mark.django_db
273+
def test_toggle_machinery_autocomplete(member):
274+
"""The machinery_autocomplete setting is off by default and can be toggled."""
275+
276+
def get_settings():
277+
response = member.client.get(
278+
"/user-data/", HTTP_X_REQUESTED_WITH="XMLHttpRequest"
279+
)
280+
return response.json()["settings"]
281+
282+
assert get_settings()["machinery_autocomplete"] is False
283+
284+
params = {"attribute": "machinery_autocomplete", "value": "true"}
285+
response = member.client.post("/user/attributes/toggle/", params)
286+
assert response.status_code == 200
287+
member.user.profile.refresh_from_db()
288+
assert member.user.profile.machinery_autocomplete is True
289+
290+
assert get_settings()["machinery_autocomplete"] is True
291+
292+
272293
@pytest.mark.django_db
273294
def test_toggle_editor_theme(member):
274295
"""toggle_editor_theme accepts valid choices and rejects invalid ones."""

‎pontoon/contributors/views.py‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ def toggle_user_profile_attribute(request):
297297
# Editor settings
298298
"quality_checks",
299299
"force_suggestions",
300+
"machinery_autocomplete",
300301
# Search settings
301302
"search_exclude_source_strings",
302303
"search_identifiers",

‎translate/public/locale/en-US/translate.ftl‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,9 @@ editor-EditorSettings--toolkit-checks = <glyph></glyph>Translate Toolkit checks
156156
editor-EditorSettings--force-suggestions = <glyph></glyph>Make suggestions
157157
.title = Save suggestions instead of translations
158158
159+
editor-EditorSettings--machinery-autocomplete = <glyph></glyph>Autocomplete from Machinery
160+
.title = Complete words from Machinery translations as you type
161+
159162
editor-EditorSettings--theme-title = Editor theme
160163
161164
editor-EditorSettings--theme-dark = <glyph></glyph> Dark
@@ -636,6 +639,8 @@ notification--tt-checks-enabled = Translate Toolkit Checks enabled
636639
notification--tt-checks-disabled = Translate Toolkit Checks disabled
637640
notification--make-suggestions-enabled = Make Suggestions enabled
638641
notification--make-suggestions-disabled = Make Suggestions disabled
642+
notification--machinery-autocomplete-enabled = Autocomplete from Machinery enabled
643+
notification--machinery-autocomplete-disabled = Autocomplete from Machinery disabled
639644
notification--ftl-not-supported-rich-editor = Translation not supported in rich editor
640645
notification--entity-not-found = Can’t load specified string
641646
notification--string-link-copied = Link copied to clipboard

‎translate/src/api/user.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ export type ApiUserData = {
4242
settings?: {
4343
quality_checks: boolean;
4444
force_suggestions: boolean;
45+
machinery_autocomplete: boolean;
4546
search_exclude_source_strings: boolean;
4647
search_identifiers: boolean;
4748
search_match_case: boolean;
@@ -99,14 +100,17 @@ export const markAllNotificationsAsRead = (): Promise<void> =>
99100

100101
export function updateUserSetting(
101102
username: string,
102-
setting: 'forceSuggestions' | 'runQualityChecks',
103+
setting: 'forceSuggestions' | 'machineryAutocomplete' | 'runQualityChecks',
103104
value: boolean,
104105
): Promise<string> {
105106
let attribute: string;
106107
switch (setting) {
107108
case 'forceSuggestions':
108109
attribute = 'force_suggestions';
109110
break;
111+
case 'machineryAutocomplete':
112+
attribute = 'machinery_autocomplete';
113+
break;
110114
case 'runQualityChecks':
111115
attribute = 'quality_checks';
112116
break;

0 commit comments

Comments
 (0)