Give the model two strings and a glossary
Suppose a replacement-filter card has two strings to translate: a product description and a link label. In this example, the application supplies SKU NK-08, the pack size and the link destination. Send the model the words the shopper will read.
The source sentence is “Each {model} box contains {count} replacement filters. Mounting clips are sold separately.” The named placeholders identify values that will be filled in later. The link destination lives in a separate field, so only the label “See compatible kettles” needs a translation.
Use this body with the authenticated POST /v1/chat/completions example on the SmarToken Hy MT2 Pro page. The prompt gives the model the product context, the approved Chinese terms and the shape of the expected response.
{
"model": "hy-mt2-pro",
"messages": [
{
"role": "user",
"content": "Translate these two product-card strings into Simplified Chinese. Use 替换滤芯 for replacement filters and 安装卡扣 for mounting clips. Preserve the meaning of sold separately. Keep the named placeholders exactly once in the same field. Return only a JSON object with the original keys.\nbody: Each {model} box contains {count} replacement filters. Mounting clips are sold separately.\nlink_label: See compatible kettles"
}
],
"max_tokens": 256
}Preview the candidate with example product values
Save the following editor-written reference translation as translated.json to try the checker. For a real model call, replace the file with the JSON in the response text. Explanations or Markdown fences need to be handled before passing the candidate to a page template.
{"body":"每盒 {model} 含 {count} 个替换滤芯。安装卡扣需另购。","link_label":"查看适配的水壶"}Save the next block as check.py and run python3 check.py translated.json. This card uses Python's named brace placeholders. The checker compares their names and counts within each field while allowing the target language to change word order. The SKU, quantity and link destination come from the page.
import json
import sys
from collections import Counter
from pathlib import Path
from string import Formatter
source = {
"body": "Each {model} box contains {count} replacement filters. Mounting clips are sold separately.",
"link_label": "See compatible kettles"
}
product = {"model": "NK-08", "count": 2}
href = "/parts/NK-08/compatibility"
def fields(text):
found = Counter()
for _, name, spec, conversion in Formatter().parse(text):
if name is not None:
if name not in product or spec or conversion:
raise ValueError(f"Unexpected placeholder: {name}")
found[name] += 1
return found
copy = json.loads(Path(sys.argv[1]).read_text(encoding="utf-8"))
if not isinstance(copy, dict) or set(copy) != set(source):
raise ValueError("Expected body and link_label")
for key, original in source.items():
translated = copy[key]
if not isinstance(translated, str) or not translated.strip():
raise ValueError(f"Missing text in {key}")
if fields(translated) != fields(original):
raise ValueError(f"Placeholder mismatch in {key}")
print(copy["body"].format_map(product))
print(copy["link_label"], href)The reference renders as “每盒 NK-08 含 2 个替换滤芯。安装卡扣需另购。” The URL printed beside the translated link label is still /parts/NK-08/compatibility. In the actual page, render the candidate as plain text and bind the separate destination to the link. Click the label in the localized preview and check that it opens the compatibility list for NK-08.
A fluent sentence can pass the checker and still promise the wrong thing
| Change to the candidate | Result in the sample checker | What the editor should verify |
|---|---|---|
| Swap the positions of {model} and {count}, keeping one of each | Pass | With NK-08 and 2 filled in, does each value modify the right noun? |
| Rename {count} to {数量}, or repeat {count} | Reject | The template expects the original field name and occurrence count. |
| Replace the Chinese for “clips sold separately” with “clips included in the box” | Pass | This would promise an accessory the shopper has to buy separately. |
The last row needs a product editor. The WMT terminology task and the Hy-MT2 IFMTBench both examine whether translation constraints survive. On this filter card, ask the reviewer two concrete questions: What comes in the box? Does the customer have to buy the clips? Those answers, the rendered SKU and quantity, and a working destination are the acceptance criteria. We ran the checker on the examples above; the table reports its behavior.
For real products, also verify dimensions, weight and price with their units and currency. Keep SKUs as strings so leading zeros survive. Matching placeholder counts does not verify the meaning or a unit conversion.
Five product-field checks
These are illustrative acceptance cases, not model output. The checker above validates named placeholders only; price, quantity meaning and destination still need page-data checks and human review.
| Field | Example | Check |
|---|---|---|
| SKU | 0007 | Keep it as a string; rendered value remains 0007 |
| Quantity | {count} = 2 | Keep the placeholder and preserve the two-per-box meaning |
| Price | ¥19.90 | Check amount, decimal point and currency |
| URL | /parts/NK-08/compatibility | Store the destination separately; translate the label only |
| HTML and variable | <a href="…">{label}</a> | Let the template own markup and URL; insert translated text |
Real example: on December 1, 2026, we sent these five lines together in one request to hy-mt2-pro in the SmarToken playground, asking for English translation while preserving SKU, numbers, currency, URL and HTML tags. The checks below look for the specified strings; one response cannot establish reliability on other copy.
| Source | Model output | Specified field check |
|---|---|---|
| 商品 SKU: MUG-47-BLUE,蓝色马克杯。 | Product SKU: MUG-47-BLUE, blue mug. | Present |
| 每包 12 件,适合家庭使用。 | 12 pieces per pack, suitable for home use. | Present |
| 价格:$18.90,限时优惠。 | Price: $18.90, limited-time offer. | Present |
| 详情访问 https://example.com/items/MUG-47-BLUE | For details, visit https://example.com/items/MUG-47-BLUE | Present |
| <strong>轻便耐用</strong>,适合旅行。 | <strong>Lightweight and durable</strong>, ideal for travel. | Present |
The table checks only whether each string appears: for example, “12” also appears inside “120”. For production, extract and compare complete values, units and currency, then verify that the quantity describes the right product. A substring match does not prove the field’s meaning is correct.
For the five outputs above, this standard-library example checks the complete SKU, a standalone quantity, price, URL and strong-tag order. All five checks return True on the actual output. Changing the quantity to 120 or price to $118.90 makes the corresponding check False; those errors are locally constructed tests, not model output.
import re
from html.parser import HTMLParser
outputs = [
'Product SKU: MUG-47-BLUE, blue mug.',
'12 pieces per pack, suitable for home use.',
'Price: $18.90, limited-time offer.',
'For details, visit https://example.com/items/MUG-47-BLUE',
'<strong>Lightweight and durable</strong>, ideal for travel.',
]
class Tags(HTMLParser):
def __init__(self):
super().__init__()
self.events = []
def handle_starttag(self, tag, attrs):
self.events.append(('start', tag))
def handle_endtag(self, tag):
self.events.append(('end', tag))
def check(lines):
parser = Tags()
parser.feed(lines[4])
urls = re.findall(r'https?://[^\s<>"\']+', lines[3])
return {
'sku': bool(re.search(r'(?<![\w-])MUG-47-BLUE(?![\w-])', lines[0])),
'quantity': bool(re.search(r'(?<![\d.+\-−])12(?!\d|[.,]\d)', lines[1])),
'price': bool(re.search(r'(?<![\d.+\-−])\$18\.90(?!\d|[.,]\d)', lines[2])),
'url': urls == ['https://example.com/items/MUG-47-BLUE'],
'html': parser.events == [('start', 'strong'), ('end', 'strong')],
}
print(check(outputs))This script is specific to this example. It cannot prove what the quantity refers to and is not a general HTML sanitizer; check units, currency, the link and rendered page before publishing.
A test with variables, a link and mixed-language copy
On December 1, 2026, we sent these three Chinese product-copy lines together to hy-mt2-pro on SmarToken, requesting English while preserving variables, URLs, HTML tags, SKUs and numbers. The source and model output below are from one request.
Source
尊敬的 {{customer_name}},您的订单 {order_id} 已备货。
这款 Sakura 樱花杯,SKU: CUP-47,每套 2 件,价格 $18.90。
<a href="https://example.com/p/CUP-47">查看商品</a>,使用优惠码 SPRING20。Raw translation
Dear {{customer_name}}, your order {order_id} has been prepared.
This Sakura Cherry Blossom Cup, SKU: CUP-47, 2 pieces per set, priced at $18.90.
<a href="https://example.com/p/CUP-47">View product</a>, use promo code SPRING20.In this output, the two variables, SKU, price, URL, promo code and Sakura retained their occurrence counts. The parsed a tag and href attribute matched, and quantity 2 remained. This single check does not establish reliability across other inputs or repeated runs; review translation meaning and business rules separately. The address is illustrative.
If the copy comes from an image, use the image translation and OCR troubleshooting guide to check recognition before translation; see the Hy MT2 Pro API example for the request format.