Skip to content

13. Hint Tokens @, @@, !, !!

tetherscript edited this page Feb 16, 2025 · 7 revisions

Let's say we are translating for a photography-related app. When we send a string like 'Aperture' to a Translation Function, do we mean aperture as in a camera lens, or aperture as in an opening of some kind, like a window? We need to give the function a hint to get the best translation results.

With human translators, we might have included context in the .resw comments. But in this Translator app, we'll use the following hint tokens:

Accuracy vs Cost

  • @ - A normal, generic translation.
    Example: '@Aperture' may be translated as an opening of some kind.

  • ! - A translation with extra context.
    Example: '!Aperture' is more likely to be translated in a photography context.

Why not always use !?

  • Longer prompts cost more.
  • If a generic @ prompt works, use that instead to save costs.

Length Constraints

Often, we have limited screen space to display a string, such as the header above a combobox control. It looks good in en-US, but translating it may make the string too long, affecting the layout and making it look bad.

To handle this, use the following hint tokens:

  • @@ - A normal, generic translation, but where we want the translation to be of similar or shorter length.
  • !! - A translation with extra context, but where we want the translation to be of similar or shorter length.

Here are the hints for the OpenAI_SO_gpt-4o-mini-2024-07-18 profile, as used in the sample apps. You can edit these as in the Profile Settings tab.

\Translator\Profiles\OpenAI_SO_gpt-4o-mini-2024-07-18.prf

  {
    "Key": "@",
    "Value": "You are a professional translator who translates from {0} to strict {1} in the context of a software user interface.  What is the translation for {2}?"
  },
  {
    "Key": "@@",
    "Value": "You are a professional translator who translates from {0} to strict {1} in the context of a software user interface.  Strictly keep the translated text visual width as rendered Arial font the same or less than the original.  What is the translation for {2}?"
  },
  {
    "Key": "!",
    "Value": "You are a professional translator who translates from {0} to strict {1} in the context of the text displayed on a photography software user interface.  What is the translation for {2}?"
  },
  {
    "Key": "!!",
    "Value": "You are a professional translator who translates from {0} to strict {1} in the context of the text displayed on a photography software user interface.  Strictly keep the translated text visual width as rendered Arial font the same or less than the original.  What is the translation for {2}?"
  }


Here's some .xaml elements from the sample app. You can see the hint token usage.

    <StackPanel
        Grid.Row="0"
        Orientation="Horizontal"
        HorizontalAlignment="Stretch"
        Margin="20 20 20 20"
        Spacing="15">
        <Button
            x:Uid="Close_btn"
            Content="@Close">
        </Button>
        <CheckBox
            x:Uid="Lock_cb"
            Content="@@Lock" />
        <RadioButtons
            Header="@Zoom"
            x:Uid="Zoom_rbs">
            <RadioButton
                x:Uid="Zoom100_rb"
                Content="@100%" />
            <RadioButton
                x:Uid="Zoom200_rb"
                Content="@200%" />
        </RadioButtons>
        <ToggleButton
            x:Uid="Browser_tgbtn"
            Content="!Image Browser" />
        <ToggleSwitch
            x:Uid="Connect_ts"
            Header="@Connection"
            OffContent="@Disconnected"
            OnContent="@Connected"
            IsOn="True" />
    </StackPanel>```
Clone this wiki locally