
I Added 6 Languages to My Quiz App. Zero Scoring Changes
How I added on-the-fly translation (Amazon Bedrock) and Arabic RTL support to my AWS certification quiz app without touching the scoring engine.
Series: AWS Quiz (2 articles)
- 2I Added 6 Languages to My Quiz App. Zero Scoring Changes This article
Adding 6-language support to my AWS certification quiz app
I previously wrote about rebuilding a 1,000-question quiz app for AWS Certified Generative AI Developer – Professional (AIP-C01) after failing the beta exam. This is a follow-up: I just added a language switcher for Japanese, English, Chinese, Korean, Spanish, and Arabic.
Why bother
All 1,000 questions are written in Japanese. Translating just the UI chrome (buttons, labels) is easy, but that leaves the actual study content — the part that matters — locked to Japanese readers. AWS certification candidates are everywhere, so I wanted the question text, answer options, and explanations to be readable in all six languages too.
Pre-translating 1,000 questions × 5 additional languages and baking the result into
questions.js wasn't realistic — the data volume and authoring effort would balloon, and most of it would never even get read. So I went with translate-on-display instead: keep the Japanese data as the single source of truth, and translate it at the moment it's shown.Two separate translation paths
UI chrome and question content are translated through completely different mechanisms:
- UI chrome (buttons, headings, progress labels): a static dictionary in
i18n.js, about 50 keys per language, hand-translated. No API calls involved.
- Question content (question text, options, explanations): the Japanese data stays put; Amazon Bedrock translates it on the fly when a non-Japanese language is selected, and the result is cached in
localStorage.
Browser → Amazon API Gateway → AWS Lambda → Amazon Bedrock (Claude Haiku 4.5)I added a
translate action to the existing Lambda proxy. It's a separate path from the app's Strands Agent study coach (which runs on Amazon Bedrock AgentCore Runtime) — plain text translation doesn't need an agent's tool-calling loop, so the Lambda calls Bedrock's Converse API directly instead of going through AgentCore Runtime. Skipping the agent framework keeps both the latency and the architecture simpler for this specific task.Each call batches the question text, every option, and the explanation into a single array and gets back a translated array in the same order — one API call per question, not four or five.
numbered = "\n".join(f"{i + 1}. {s}" for i, s in enumerate(texts))prompt = ( f"Translate each numbered line below from Japanese to {lang_name}. " f"Return ONLY a JSON array of {len(texts)} translated strings, " f"in the same order, with no extra commentary." f"\n\n{numbered}")resp = bedrock_client.converse( modelId="us.anthropic.claude-haiku-4-5-20251001-v1:0", messages=[{"role": "user", "content": [{"text": prompt}]}], inferenceConfig={"maxTokens": 4096, "temperature": 0},)The scoring logic never had to change
Translation only ever replaces an option's
text field — never its ID (A/B/C…), never the correct-answer array, never the question type. Because of that split, the quiz engine's answer-checking logic is identical no matter which language is displayed. Adding six languages required zero changes to the actual scoring code.const trOpt = textData.options.find(o => o.id === opt.id) || opt;// input.value stays opt.id (A/B/C...) always;// only the displayed label swaps to trOpt.textCaching and async rendering
Translation is a network call, so it can't appear instantly. When a question renders, the app first paints whatever it already has — a cached translation, or the original Japanese if nothing is cached yet — then fetches the translation in the background and swaps the text in once it arrives.
function renderQuestion() { const cached = cachedTextOf(q, lang); renderQuestionWithText(q, cached || plainTextOf(q)); // paint immediately
if (lang !== 'ja' && !cached) { const myToken = ++state.translateToken; ensureTranslated(q, lang).then(tr => { if (state.translateToken !== myToken) return; // stale, user moved on renderQuestionWithText(q, tr); }); }}The token guard exists because a user can move to the next question before a slow translation resolves; without it, a stale response could land after navigation and overwrite the wrong question's screen. Translations also persist to
localStorage , so revisiting a question you've already seen is instant — no repeat API call.Keeping the AI coach's language consistent
The app has a "weak point analysis" feature backed by a Strands Agent (Amazon Bedrock AgentCore Runtime) that used to always write its advice in Japanese. I threaded a
lang parameter through to the prompt so it now responds in whatever language is selected.The first pass had a bug: asking for English still produced a stray Japanese preamble sentence before the English content. The system prompt itself is written in Japanese, and that seems to have biased the model toward opening in Japanese regardless of the requested output language. Adding an explicit instruction — no preamble, no heading, no separator line, output only in the requested language from the first character — fixed it. Worth remembering: when you're asking a model to switch output languages on demand, the language the system prompt itself is written in can leak into the response. Japanese

English

Arabic and RTL: less work than expected
Arabic is the one right-to-left language in the set, so I braced for a layout rewrite. It turned out to be one line:
document.documentElement.dir = (lang === "ar") ? "rtl" : "ltr";
Both CSS Grid (
grid-template-columns ) and Flexbox ( display:flex ) are direction-aware — they mirror visual order automatically based on the dir attribute. The question navigator sidebar, the back/next button order, even the language selector's position in the header all flipped correctly with zero extra CSS. A good reminder of how far modern layout engines have come on this.IAM
To let the translation Lambda call Amazon Bedrock directly, I added
bedrock:InvokeModel / bedrock:Converse to its execution role, scoped to the Claude Haiku 4.5 model ARN specifically. That's a separate permission from the existing "invoke the study-coach AgentCore Runtime" grant — keeping them apart follows least privilege more cleanly than one broad Bedrock policy would.Takeaways
- Splitting UI chrome (static dictionary) from question content (translate-on-display) kept the total effort realistic
- Because translation only swaps display text and never touches answer IDs, the scoring engine required no changes at all
- LLM output language can be biased by the language the system prompt itself is written in — state the output-language constraint explicitly and strongly
- RTL support is nearly free if your layout already uses CSS Grid/Flexbox — it's mostly a
dirattribute flip
Series: AWS Quiz (2 articles)
- 2I Added 6 Languages to My Quiz App. Zero Scoring Changes This article
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article