Zero-Shot Translation

La Lakshmi Priya Updated 05 Nov 2026
11 min read ·Lesson 21 of 40

What Is Zero-Shot Translation? Translation is converting text from one language (the source language) into another (the target language) while keeping its meaning.

Zero-shot translation means asking a model to translate by describing the task, without providing example translations. Modern LLMs learned many languages from their training data, so they can translate between common language pairs with a simple instruction.

Example Translate the following message into Hindi.

Your class will start today at 6 PM. Possible output:

आपकी कक्षा आज शाम 6 बजे शुरू होगी। Example Explanation The prompt names the target language and delimits the text to translate. The model chose the respectful form आपकी ("your", formal). Hindi has several levels of "you" (आप, तुम, तू), and the model selected the polite form that suits most messages to students or customers. The model wrote "6 PM" as शाम 6 बजे ("6 o'clock in the evening"), which is how time is naturally expressed in Hindi. Good translation adapts expressions, not only words. The model made a reasonable choice about formality here, but it was still a choice. For an app where you want a casual tone with young students, you would need to state that.

Why Translation Needs More Than "Translate This" Translation involves decisions beyond word-for-word conversion. A minimal prompt leaves all of these to the model.

Decision Example Formality Hindi आप (formal) vs तुम (informal); Tamil நீங்கள் (respectful) vs நீ (informal) Audience A legal notice vs a marketing message vs a text to a friend Terminology Translate "dashboard" or keep it in English? Script Tamil script, or Tamil written in English letters ("Tanglish")? Regional variety European Portuguese vs Brazilian Portuguese; formal written Tamil vs spoken Tamil Formatting Keep Markdown, HTML tags, and placeholders unchanged Cultural adaptation Keep "Thanksgiving sale", or adapt it for a local audience? Each of these can make a translation technically correct but wrong for its purpose.

Building a Good Translation Prompt

  1. Name the Source and Target Clearly Translate from English into Tamil. If the source language may vary, say so:

The text may be in English or Hindi. Translate it into Tamil.

  1. Describe the Audience and Register Register means the level of formality and the style of language used for a situation.

The audience is college students reading a push notification on their phone. Use simple, friendly, everyday Tamil, not formal literary Tamil.

  1. Specify Terms That Must Not Be Translated Many technical and brand terms are commonly kept in English by Indian-language speakers. Translating them can make text harder to understand.

Do not translate these terms: GOCOURSE, Django, Python, login, dashboard, OTP. Keep them in English (Latin script).

  1. Provide a Glossary for Fixed Terms If certain words should always be translated a specific way, define them:

Glossary (always use these translations):

  • course → கோர்ஸ்

  • certificate → சான்றிதழ் A glossary keeps terminology consistent across hundreds of strings, such as an entire app interface.

  1. Protect Formatting and Placeholders Keep all Markdown, HTML tags, and placeholders in curly braces (such as {name} or {date}) exactly as they are. Translate only the human-readable text.
  2. Request Only the Translation Return only the translated text, with no explanations or notes. A Complete Translation Prompt Translate the text in from English into Tamil.

Audience: college students reading an app notification. Style: simple, friendly, everyday Tamil, not formal literary Tamil.

Rules:

  • Keep these terms in English: GOCOURSE, Django, login, OTP.
  • Keep placeholders like {name} exactly unchanged.
  • Return only the translation.

Hi {name}, your Django class starts in 30 minutes. Use the OTP sent to your phone to login. Explanation Part Purpose Source and target Removes any doubt about direction Audience and style Sets register for a notification to students Do-not-translate list Keeps familiar technical terms recognizable Placeholder rule Prevents {name} from being translated or removed, which would break the app "Return only" Makes the output directly usable Translation vs Transliteration These two terms are often confused.

Term Meaning Example Translation Converts meaning into another language "Welcome" → Tamil: "வரவேற்கிறோம்" Transliteration Writes the same words in a different script "வணக்கம்" → "Vanakkam" Many people in India write their languages in Latin script on messaging apps, for example Tamil written as "Class 6 manikku start aagum". If your audience reads this style, ask for it explicitly:

Translate into Tamil, written in English letters (Tanglish), as people commonly type on WhatsApp. Keep common English words such as "class" and "link" in English. Without this instruction, the model will usually use the native script.

Translating Code-Mixed Text Code-mixed text combines two or more languages in one message, which is very common in India.

Sir, Django class la doubt irukku, assignment submit pannalaama tomorrow? This message mixes Tamil (in Latin script) and English. To translate it into English:

Translate the message into clear English. The message mixes Tamil written in English letters with English words. Preserve the meaning and politeness.

Sir, Django class la doubt irukku, assignment submit pannalaama tomorrow? Possible output:

Sir, I have a doubt about the Django class. Can I submit the assignment tomorrow? Explanation Telling the model that the text is code-mixed, and in which way, helps it interpret words such as "irukku" (there is) and "pannalaama" (can I do) correctly. Models handle common code-mixed patterns reasonably well, but accuracy is lower than for standard text, so important translations should be reviewed by a speaker of the language.

Localization: Beyond Translation Localization adapts content for a specific region or culture, not just a language.

Element Translation Only Localization Dates "12/03/2026" copied as is Written in the format the region expects, with ambiguity removed Currency "$49" kept Converted to the local price set by your business, such as ₹4,999 Examples "Pay with your credit card" "Pay with UPI, card, or net banking" Cultural references "Black Friday deals" A regionally relevant occasion, if appropriate Units "5 miles" "8 km" Example Prompt Localize the message below for students in Tamil Nadu, writing it in Tamil.

  • Write dates as day-month-year, for example 25-11-2026.
  • Keep prices exactly as given; do not convert currencies.
  • Replace payment examples with methods common in India (UPI, debit card). Note: Never let the model convert prices or change legal or business facts on its own. Prices, deadlines, and policy details should come from your data. The prompt above explicitly keeps prices unchanged.

Translating Application Strings in Code Applications often keep interface text in JSON files keyed by identifiers. The following example translates such a file and verifies that all keys and placeholders survived.

Requirements: pip install openai and an OPENAI_API_KEY environment variable.

import json import re

from openai import OpenAI

client = OpenAI() MODEL = "gpt-5.4" # Replace with a model available in your account

PLACEHOLDER = re.compile(r"{[a-zA-Z_]+}")

INSTRUCTIONS = """Translate the values of the JSON object in from English into Hindi for a learning app used by college students.

Rules:

  • Use simple, polite Hindi (use आप for "you").
  • Do not translate or change the keys.
  • Keep placeholders in curly braces, such as {name}, exactly unchanged.
  • Keep these terms in English: GOCOURSE, login, OTP.
  • Return only a JSON object with the same keys and translated values."""

def translate_strings(strings: dict[str, str]) -> dict[str, str]: response = client.responses.create( model=MODEL, instructions=INSTRUCTIONS, input=f"\n{json.dumps(strings, ensure_ascii=False, indent=2)}\n", ) return json.loads(response.output_text)

def check_translation(source: dict[str, str], translated: dict[str, str]) -> list[str]: problems = [] for key, text in source.items(): if key not in translated: problems.append(f"Missing key: {key}") continue expected = sorted(PLACEHOLDER.findall(text)) actual = sorted(PLACEHOLDER.findall(translated[key])) if expected != actual: problems.append(f"Placeholder mismatch in '{key}': {expected} vs {actual}") for key in translated: if key not in source: problems.append(f"Unexpected key: {key}") return problems

source_strings = { "welcome": "Welcome back, {name}!", "class_reminder": "Your class starts at {time}.", "otp_prompt": "Enter the OTP sent to {phone} to login.", }

hindi = translate_strings(source_strings) issues = check_translation(source_strings, hindi) print(json.dumps(hindi, ensure_ascii=False, indent=2)) print(issues or "All keys and placeholders preserved.") Code Explanation PLACEHOLDER A regular expression that matches placeholders such as {name} and {time}: a curly brace, one or more letters or underscores, and a closing brace.

json.dumps(..., ensure_ascii=False, indent=2)

ensure_ascii=False keeps non-English characters as readable characters instead of \u escape codes, which matters when sending or displaying Hindi or Tamil text. indent=2 formats the JSON readably, making each key-value pair clear to the model. INSTRUCTIONS States the audience and register, protects keys and placeholders, lists terms to keep in English, and requires JSON output with the same keys.

check_translation()

Reports any missing key, which would cause a blank or broken label in the app. Compares the sorted list of placeholders in each source and translated string. Sorting allows placeholders to move, because word order differs between languages: in Hindi, {time} may appear in a different position than in English. Reports unexpected keys, in case the model renamed or translated a key. Why This Matters A translated string such as "Welcome back, {नाम}!" looks correct to a reader, but the app will display the raw text {नाम} instead of the user's name, because the code expects {name}. Automated checks catch this class of error before release.

Checking Translation Quality Back-Translation Back-translation means translating the result back into the source language and comparing it with the original.

Translate the Tamil text below into English as literally as possible. Do not improve or correct it. If the back-translation has a different meaning from the original, the translation may be wrong.

Limitation: A good back-translation does not guarantee a natural-sounding translation. A translation can preserve meaning but still sound awkward or unnatural to native speakers.

Native Speaker Review For anything public, legal, medical, or important to your brand, have a fluent speaker review the translation. Use the model to produce a strong first draft and the reviewer to ensure accuracy and natural phrasing.

Language Coverage Varies Models are generally strongest in languages that are well represented in their training data. Quality can be lower for less widely represented languages and dialects, and for informal or regional phrasing. Test with real content in every language you support.

Common Mistakes Mistake 1: Not Specifying Formality What it is: Translating into languages with formal and informal forms without stating which to use.

Why it happens: English uses a single "you", so the decision is easy to overlook.

What it causes: Messages that sound too stiff or disrespectful for the audience, sometimes inconsistently across screens.

How to fix it: State the register and, for key words such as "you", the exact form.

Mistake 2: Breaking Placeholders and Markup What it is: Translations that change {name}, HTML tags, or Markdown syntax.

Why it happens: The model treats them as part of the text.

What it causes: Broken interfaces and visible raw code.

How to fix it: Instruct the model to keep them unchanged, and validate them in code.

Mistake 3: Translating Everything What it is: Translating brand names, product names, and commonly used English technical terms.

Why it happens: No do-not-translate list was provided.

What it causes: Unfamiliar translated terms that confuse users.

How to fix it: Provide a do-not-translate list and a glossary.

Mistake 4: Letting the Model Localize Facts What it is: Allowing the model to convert prices, change dates, or adapt policies.

Why it happens: Localization instructions are too broad.

What it causes: Incorrect prices or terms shown to users.

How to fix it: Keep business facts unchanged in the prompt; supply localized facts from your data.

Mistake 5: Publishing Without Review What it is: Releasing machine translations directly for important content.

Why it happens: Translations look fluent.

What it causes: Subtle errors in meaning or tone that damage trust.

How to fix it: Use automated checks for structure and native speaker review for meaning and tone.

Best Practices State source, target, audience, and register. Formality and style are part of a correct translation.

Use do-not-translate lists and glossaries. They keep terminology consistent and familiar.

Protect placeholders, markup, and keys. Instruct the model and verify in code.

Specify script and style for informal audiences. Native script, Latin-script transliteration, or code-mixed style should be chosen deliberately.

Separate translation from localization. Adapt formats and examples, but never let the model change business facts.

Translate structured data as structured data. Send JSON, receive JSON, validate keys.

Review important translations with native speakers. Use back-translation as an additional check, not a replacement.

Try It Yourself Exercise 1: Compare Registers Translate this message into Tamil or Hindi twice, once for a formal letter to parents and once for a casual app notification to students:

Your exam results are now available. Check your dashboard to see your score. Compare the forms of "you" and the vocabulary used in each version.

Exercise 2: Protect the Placeholders Use the translate_strings and check_translation functions with 10 interface strings that contain placeholders, including one string with two placeholders such as "{name}, your payment of {amount} was successful." Run it several times and check whether every placeholder is preserved.

Exercise 3: Code-Mixed Messages Collect five code-mixed messages in the style your students actually write (for example, Tamil or Hindi in English letters mixed with English words). Translate each into English and ask a fluent speaker to rate whether the meaning was preserved. Note which kinds of phrases caused errors.

0 Comments

Reviewed before they appear

No comments yet.

Prompt Engineering
Ask about this post
AI Ask about this post

Ask questions about Zero-Shot Translation and get answers drawn from it.

Signed-in readers only.