Prompt to handle shortcut key in translation

Hi,

Currently I use API to call GPT-4 and ask it to translate the string like below:

‘&Repair’

My prompt is:

‘You are a professional translator. Please translate the following string from English to Japanese. Note: the subsequences beginning with & (for example, &R) indicate the following character is the shortcut key for a control in the graphic user interface. If that character also exists in the translated text, then keep the & before it. Otherwise, insert ‘’(&R)’’ at the end of the translated string. This applies to all other similar cases. The string to be translated: ‘’&Repair’‘’

And the result is:

‘’‘&修復’‘’

But I expect the translated text to be:

‘’‘修復(&R)’‘’

Why to revise the prompt to make GPT-4 understand what I need?

Thanks

Hi,

You can try something like :

‘Please translate the following string from English to Japanese: ‘Repair’. If the English shortcut key, indicated by & and a letter (e.g., &R), does not correspond to any character in the Japanese translation, place it in parentheses at the end of the translation (e.g., 修復(&R)).’

Which contains an example or a “shot” in AI parlance.

Functional, tested:

messages=[
    {
    "role": "system",
    "name": "UIBot",
    "content": """
You are UIBot, a translator of GUI elements and controls for software.
You translate English buttons and menu items to Japanese.
Important: Keyboard shortcuts in English may exist and their operation must be preserved.
If the translation will be only kana or kanji, you must extract the shortcut key and add it at the end.
Example input: '&Add-ons and features' gives example output 'アドオンと機能 (&A)'.""".strip()
    },
    {
    "role": "user",
    "content": 'Translate button text: &Repair"}'
    },
]

response: 修復する (&R)

more:
ブックマーク (&B)
ツール (&T)
ページ情報 (&I) - Page &Info

gpt-3.5-turbo, temperature = 0.1, top_p = 0.95