We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Pretranslated Fluent string has the ID translated or modified
It happened for at least two strings.

```
remember-pw-link = Remember your password? Sign in
```

Became

```
Remember-pw-link = Ricordi la password? Accedi
```

No clue why it changed to uppercase.

On the other hand, for 

```
plan-price-interval-year =
    { $intervalCount ->
        [one] { $amount } all’anno
       *[other] { $amount } ogni { $intervalCount } anni
    }
    .title =
        { $intervalCount ->
            [one] { $amount } all’anno
           *[other] { $amount } ogni { $intervalCount } anni
        }
```

The id was translated to `piano-prezzo-intervallo-anno`(but the translation was good besides that).


--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `pontoon/pretranslation/pretranslate.py`
Content:
```
1 import operator
2 
3 from fluent.syntax import FluentSerializer
4 from functools import reduce
5 
6 from django.db.models import CharField, Value as V
7 from django.db.models.functions import Concat
8 
9 from pontoon.base.models import User, TranslatedResource
10 from pontoon.machinery.utils import (
11     get_google_translate_data,
12     get_translation_memory_data,
13 )
14 
15 from pontoon.base.templatetags.helpers import (
16     as_simple_translation,
17     is_single_input_ftl_string,
18     get_reconstructed_message,
19 )
20 
21 
22 serializer = FluentSerializer()
23 
24 
25 def get_translations(entity, locale):
26     """
27     Get pretranslations for the entity-locale pair
28 
29     :arg Entity entity: the Entity object
30     :arg Locale locale: the Locale object
31 
32     :returns: a list of tuple with:
33         - a pretranslation of the entity
34         - plural form
35         - user - tm_user/gt_user
36     """
37     tm_user = User.objects.get(email="pontoon-tm@example.com")
38     gt_user = User.objects.get(email="pontoon-gt@example.com")
39 
40     strings = []
41     plural_forms = range(0, locale.nplurals or 1)
42 
43     entity_string = (
44         as_simple_translation(entity.string)
45         if is_single_input_ftl_string(entity.string)
46         else entity.string
47     )
48 
49     # Try to get matches from translation_memory
50     tm_response = get_translation_memory_data(
51         text=entity_string,
52         locale=locale,
53     )
54 
55     tm_response = [t for t in tm_response if int(t["quality"]) == 100]
56 
57     if tm_response:
58         if entity.string_plural == "":
59             translation = tm_response[0]["target"]
60 
61             if entity.string != entity_string:
62                 translation = serializer.serialize_entry(
63                     get_reconstructed_message(entity.string, translation)
64                 )
65 
66             strings = [(translation, None, tm_user)]
67         else:
68             for plural_form in plural_forms:
69                 strings.append((tm_response[0]["target"], plural_form, tm_user))
70 
71     # Else fetch from google translate
72     elif locale.google_translate_code:
73         gt_response = get_google_translate_data(
74             text=entity.string,
75             locale=locale,
76         )
77 
78         if gt_response["status"]:
79             if entity.string_plural == "":
80                 strings = [(gt_response["translation"], None, gt_user)]
81             else:
82                 for plural_form in plural_forms:
83                     strings.append((gt_response["translation"], plural_form, gt_user))
84     return strings
85 
86 
87 def update_changed_instances(tr_filter, tr_dict, translations):
88     """
89     Update the latest activity and stats for changed Locales, ProjectLocales
90     & TranslatedResources
91     """
92     tr_filter = tuple(tr_filter)
93     # Combine all generated filters with an OK operator.
94     # `operator.ior` is the '|' Python operator, which turns into a logical OR
95     # when used between django ORM query objects.
96     tr_query = reduce(operator.ior, tr_filter)
97 
98     translatedresources = TranslatedResource.objects.filter(tr_query).annotate(
99         locale_resource=Concat(
100             "locale_id", V("-"), "resource_id", output_field=CharField()
101         )
102     )
103 
104     translatedresources.update_stats()
105 
106     for tr in translatedresources:
107         index = tr_dict[tr.locale_resource]
108         translation = translations[index]
109         translation.update_latest_translation()
110
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/pontoon/pretranslation/pretranslate.py b/pontoon/pretranslation/pretranslate.py
--- a/pontoon/pretranslation/pretranslate.py
+++ b/pontoon/pretranslation/pretranslate.py
@@ -18,6 +18,7 @@
     get_reconstructed_message,
 )
 
+UNTRANSLATABLE_KEY = "AIzaSyDX3R5Y1kxh_8lJ4OAO"
 
 serializer = FluentSerializer()
 
@@ -40,7 +41,7 @@
     strings = []
     plural_forms = range(0, locale.nplurals or 1)
 
-    entity_string = (
+    tm_input = (
         as_simple_translation(entity.string)
         if is_single_input_ftl_string(entity.string)
         else entity.string
@@ -48,7 +49,7 @@
 
     # Try to get matches from translation_memory
     tm_response = get_translation_memory_data(
-        text=entity_string,
+        text=tm_input,
         locale=locale,
     )
 
@@ -58,7 +59,7 @@
         if entity.string_plural == "":
             translation = tm_response[0]["target"]
 
-            if entity.string != entity_string:
+            if entity.string != tm_input:
                 translation = serializer.serialize_entry(
                     get_reconstructed_message(entity.string, translation)
                 )
@@ -70,12 +71,23 @@
 
     # Else fetch from google translate
     elif locale.google_translate_code:
+        gt_input = (
+            entity.string.replace(entity.key, UNTRANSLATABLE_KEY, 1)
+            if entity.resource.format == "ftl"
+            else entity.string
+        )
+
         gt_response = get_google_translate_data(
-            text=entity.string,
+            text=gt_input,
             locale=locale,
         )
 
         if gt_response["status"]:
+            if entity.string != gt_input:
+                gt_response["translation"] = gt_response["translation"].replace(
+                    UNTRANSLATABLE_KEY, entity.key
+                )
+
             if entity.string_plural == "":
                 strings = [(gt_response["translation"], None, gt_user)]
             else:

{"golden_diff": "diff --git a/pontoon/pretranslation/pretranslate.py b/pontoon/pretranslation/pretranslate.py\n--- a/pontoon/pretranslation/pretranslate.py\n+++ b/pontoon/pretranslation/pretranslate.py\n@@ -18,6 +18,7 @@\n     get_reconstructed_message,\n )\n \n+UNTRANSLATABLE_KEY = \"AIzaSyDX3R5Y1kxh_8lJ4OAO\"\n \n serializer = FluentSerializer()\n \n@@ -40,7 +41,7 @@\n     strings = []\n     plural_forms = range(0, locale.nplurals or 1)\n \n-    entity_string = (\n+    tm_input = (\n         as_simple_translation(entity.string)\n         if is_single_input_ftl_string(entity.string)\n         else entity.string\n@@ -48,7 +49,7 @@\n \n     # Try to get matches from translation_memory\n     tm_response = get_translation_memory_data(\n-        text=entity_string,\n+        text=tm_input,\n         locale=locale,\n     )\n \n@@ -58,7 +59,7 @@\n         if entity.string_plural == \"\":\n             translation = tm_response[0][\"target\"]\n \n-            if entity.string != entity_string:\n+            if entity.string != tm_input:\n                 translation = serializer.serialize_entry(\n                     get_reconstructed_message(entity.string, translation)\n                 )\n@@ -70,12 +71,23 @@\n \n     # Else fetch from google translate\n     elif locale.google_translate_code:\n+        gt_input = (\n+            entity.string.replace(entity.key, UNTRANSLATABLE_KEY, 1)\n+            if entity.resource.format == \"ftl\"\n+            else entity.string\n+        )\n+\n         gt_response = get_google_translate_data(\n-            text=entity.string,\n+            text=gt_input,\n             locale=locale,\n         )\n \n         if gt_response[\"status\"]:\n+            if entity.string != gt_input:\n+                gt_response[\"translation\"] = gt_response[\"translation\"].replace(\n+                    UNTRANSLATABLE_KEY, entity.key\n+                )\n+\n             if entity.string_plural == \"\":\n                 strings = [(gt_response[\"translation\"], None, gt_user)]\n             else:\n", "issue": "Pretranslated Fluent string has the ID translated or modified\nIt happened for at least two strings.\r\n\r\n```\r\nremember-pw-link = Remember your password? Sign in\r\n```\r\n\r\nBecame\r\n\r\n```\r\nRemember-pw-link = Ricordi la password? Accedi\r\n```\r\n\r\nNo clue why it changed to uppercase.\r\n\r\nOn the other hand, for \r\n\r\n```\r\nplan-price-interval-year =\r\n    { $intervalCount ->\r\n        [one] { $amount } all\u2019anno\r\n       *[other] { $amount } ogni { $intervalCount } anni\r\n    }\r\n    .title =\r\n        { $intervalCount ->\r\n            [one] { $amount } all\u2019anno\r\n           *[other] { $amount } ogni { $intervalCount } anni\r\n        }\r\n```\r\n\r\nThe id was translated to `piano-prezzo-intervallo-anno`(but the translation was good besides that).\r\n\n", "before_files": [{"content": "import operator\n\nfrom fluent.syntax import FluentSerializer\nfrom functools import reduce\n\nfrom django.db.models import CharField, Value as V\nfrom django.db.models.functions import Concat\n\nfrom pontoon.base.models import User, TranslatedResource\nfrom pontoon.machinery.utils import (\n    get_google_translate_data,\n    get_translation_memory_data,\n)\n\nfrom pontoon.base.templatetags.helpers import (\n    as_simple_translation,\n    is_single_input_ftl_string,\n    get_reconstructed_message,\n)\n\n\nserializer = FluentSerializer()\n\n\ndef get_translations(entity, locale):\n    \"\"\"\n    Get pretranslations for the entity-locale pair\n\n    :arg Entity entity: the Entity object\n    :arg Locale locale: the Locale object\n\n    :returns: a list of tuple with:\n        - a pretranslation of the entity\n        - plural form\n        - user - tm_user/gt_user\n    \"\"\"\n    tm_user = User.objects.get(email=\"pontoon-tm@example.com\")\n    gt_user = User.objects.get(email=\"pontoon-gt@example.com\")\n\n    strings = []\n    plural_forms = range(0, locale.nplurals or 1)\n\n    entity_string = (\n        as_simple_translation(entity.string)\n        if is_single_input_ftl_string(entity.string)\n        else entity.string\n    )\n\n    # Try to get matches from translation_memory\n    tm_response = get_translation_memory_data(\n        text=entity_string,\n        locale=locale,\n    )\n\n    tm_response = [t for t in tm_response if int(t[\"quality\"]) == 100]\n\n    if tm_response:\n        if entity.string_plural == \"\":\n            translation = tm_response[0][\"target\"]\n\n            if entity.string != entity_string:\n                translation = serializer.serialize_entry(\n                    get_reconstructed_message(entity.string, translation)\n                )\n\n            strings = [(translation, None, tm_user)]\n        else:\n            for plural_form in plural_forms:\n                strings.append((tm_response[0][\"target\"], plural_form, tm_user))\n\n    # Else fetch from google translate\n    elif locale.google_translate_code:\n        gt_response = get_google_translate_data(\n            text=entity.string,\n            locale=locale,\n        )\n\n        if gt_response[\"status\"]:\n            if entity.string_plural == \"\":\n                strings = [(gt_response[\"translation\"], None, gt_user)]\n            else:\n                for plural_form in plural_forms:\n                    strings.append((gt_response[\"translation\"], plural_form, gt_user))\n    return strings\n\n\ndef update_changed_instances(tr_filter, tr_dict, translations):\n    \"\"\"\n    Update the latest activity and stats for changed Locales, ProjectLocales\n    & TranslatedResources\n    \"\"\"\n    tr_filter = tuple(tr_filter)\n    # Combine all generated filters with an OK operator.\n    # `operator.ior` is the '|' Python operator, which turns into a logical OR\n    # when used between django ORM query objects.\n    tr_query = reduce(operator.ior, tr_filter)\n\n    translatedresources = TranslatedResource.objects.filter(tr_query).annotate(\n        locale_resource=Concat(\n            \"locale_id\", V(\"-\"), \"resource_id\", output_field=CharField()\n        )\n    )\n\n    translatedresources.update_stats()\n\n    for tr in translatedresources:\n        index = tr_dict[tr.locale_resource]\n        translation = translations[index]\n        translation.update_latest_translation()\n", "path": "pontoon/pretranslation/pretranslate.py"}], "after_files": [{"content": "import operator\n\nfrom fluent.syntax import FluentSerializer\nfrom functools import reduce\n\nfrom django.db.models import CharField, Value as V\nfrom django.db.models.functions import Concat\n\nfrom pontoon.base.models import User, TranslatedResource\nfrom pontoon.machinery.utils import (\n    get_google_translate_data,\n    get_translation_memory_data,\n)\n\nfrom pontoon.base.templatetags.helpers import (\n    as_simple_translation,\n    is_single_input_ftl_string,\n    get_reconstructed_message,\n)\n\nUNTRANSLATABLE_KEY = \"AIzaSyDX3R5Y1kxh_8lJ4OAO\"\n\nserializer = FluentSerializer()\n\n\ndef get_translations(entity, locale):\n    \"\"\"\n    Get pretranslations for the entity-locale pair\n\n    :arg Entity entity: the Entity object\n    :arg Locale locale: the Locale object\n\n    :returns: a list of tuple with:\n        - a pretranslation of the entity\n        - plural form\n        - user - tm_user/gt_user\n    \"\"\"\n    tm_user = User.objects.get(email=\"pontoon-tm@example.com\")\n    gt_user = User.objects.get(email=\"pontoon-gt@example.com\")\n\n    strings = []\n    plural_forms = range(0, locale.nplurals or 1)\n\n    tm_input = (\n        as_simple_translation(entity.string)\n        if is_single_input_ftl_string(entity.string)\n        else entity.string\n    )\n\n    # Try to get matches from translation_memory\n    tm_response = get_translation_memory_data(\n        text=tm_input,\n        locale=locale,\n    )\n\n    tm_response = [t for t in tm_response if int(t[\"quality\"]) == 100]\n\n    if tm_response:\n        if entity.string_plural == \"\":\n            translation = tm_response[0][\"target\"]\n\n            if entity.string != tm_input:\n                translation = serializer.serialize_entry(\n                    get_reconstructed_message(entity.string, translation)\n                )\n\n            strings = [(translation, None, tm_user)]\n        else:\n            for plural_form in plural_forms:\n                strings.append((tm_response[0][\"target\"], plural_form, tm_user))\n\n    # Else fetch from google translate\n    elif locale.google_translate_code:\n        gt_input = (\n            entity.string.replace(entity.key, UNTRANSLATABLE_KEY, 1)\n            if entity.resource.format == \"ftl\"\n            else entity.string\n        )\n\n        gt_response = get_google_translate_data(\n            text=gt_input,\n            locale=locale,\n        )\n\n        if gt_response[\"status\"]:\n            if entity.string != gt_input:\n                gt_response[\"translation\"] = gt_response[\"translation\"].replace(\n                    UNTRANSLATABLE_KEY, entity.key\n                )\n\n            if entity.string_plural == \"\":\n                strings = [(gt_response[\"translation\"], None, gt_user)]\n            else:\n                for plural_form in plural_forms:\n                    strings.append((gt_response[\"translation\"], plural_form, gt_user))\n    return strings\n\n\ndef update_changed_instances(tr_filter, tr_dict, translations):\n    \"\"\"\n    Update the latest activity and stats for changed Locales, ProjectLocales\n    & TranslatedResources\n    \"\"\"\n    tr_filter = tuple(tr_filter)\n    # Combine all generated filters with an OK operator.\n    # `operator.ior` is the '|' Python operator, which turns into a logical OR\n    # when used between django ORM query objects.\n    tr_query = reduce(operator.ior, tr_filter)\n\n    translatedresources = TranslatedResource.objects.filter(tr_query).annotate(\n        locale_resource=Concat(\n            \"locale_id\", V(\"-\"), \"resource_id\", output_field=CharField()\n        )\n    )\n\n    translatedresources.update_stats()\n\n    for tr in translatedresources:\n        index = tr_dict[tr.locale_resource]\n        translation = translations[index]\n        translation.update_latest_translation()\n", "path": "pontoon/pretranslation/pretranslate.py"}]}