Cheat sheets

Localization and Glossary Tools

Run, feed and check three review-first localization projects. Pick a multilingual model and a source language.

  • Concepts and terms
  • Tasks and commands
  • Annotated code
  • Diagrams
  • Comparisons
  • Defaults and numbers
  • Troubleshooting
  • Questions and tips

Source

Three projects side by side#

FactorSubtitle Localization DeskUI String Localization WorkbenchGlossary Hovercard Publisher
BuildsReviewed WebVTT and an HTML deskReviewed locale JSON and a previewAnnotated HTML lesson
LanguagePython 3.10+Node 22.18 or newerNode 22.18 or newer
Input keysvtt, translations, glossary, cpslocale, messages, proposals, valuesglossary, lesson
Outputsreview.html, translation-decisions.json, reviewed.vttlocale.json, unresolved-strings.json, report.htmlreport.html, glossary.json, coverage.json
Review file--decisions decisions.jsonthird argument locale-review.jsonnone
Hard gatereviewed.vtt only when all cues approvedapprove only with no issuesbalanced HTML subset

Build and grade your version#

TaskCode
Make a starterpython3 scripts/project_test.py <project> --init <dir>
Grade one stagepython3 scripts/project_test.py <project> --stage 1 --path <dir> --strict
Grade all stagespython3 scripts/project_test.py <project> --all --path <dir> --strict
Save a completion report--report completion.json
Grade the referencepython3 scripts/project_test.py <project> --all --solution --strict

UI string workbench flow#

messagesMessage[]Proposal[]catalogunresolvedclientsample.jsonmessages, proposalsprocessreadCatalog()keys, placeholdersprocessproposeTranslations()issues, needsContextprocessreviewTranslations()approve, reject, pendingstorelocale.jsonapproved stringsstoreunresolved-strings.jsonkeys with reasonsmessagesMessage[]Proposal[]catalogunresolvedclientsample.jsonmessages, proposalsprocessreadCatalog()keys, placeholdersprocessproposeTranslations()issues,needsContextprocessreviewTranslations()approve, reject,pendingstorelocale.jsonapproved stringsstoreunresolved-strings.jsonkeys with reasons

Error messages and fixes#

SymptomCauseFix
stale reviewProposals or cps changed after reviewUse the new decisions.json from review.html
resolve glossary or acknowledge reading-budget overflowApproved cue misses a term or the budgetAdd the term or set override_budget to true
STYLE and REGION are outside the supported subsetVTT has STYLE or REGION blocksRemove them. NOTE blocks are ignored
Placeholder multiset changedTranslation drops or adds a {name}Keep every placeholder of the source
Stale or invalid translation decisionReview translation differs from the proposalDownload a new locale-review.json
Resolve translation issues or context before approvingAmbiguous key not acknowledgedSet acknowledgeContext to true
Ambiguous repeated phraseSame phrase in two termsGive each phrase one term
Unsupported HTML elementTag outside the allowed subsetUse the listed tags only

Defaults and limits#

SettingDefaultNote
cps17Must be positive and finite
schema_version1In translation-decisions.json
approvedFalseEvery cue starts unapproved
override_budgetFalseNeeded for an over-budget approval
Proposal length2000Characters at most per proposal
schemaVersion1Required in locale-review.json
Output folderoutputSecond argument of the Node CLIs
Exit code on error2The Node CLIs print the message

Run the reference#

CommandWhat it does
python3 cli.py samples/input.json --output demo-outputSubtitle desk on the sample
python3 cli.py <input.json> --output <dir>Subtitle desk on your input
node cli.ts sample.json outputUI workbench or glossary publisher
node cli.ts <input.json> <dir> <review.json>UI workbench with your review
node cli.ts --helpPrints the argument line

Subtitle desk pipeline#

1parse_vttreads WebVTT into cues. It keeps timestampstrings and gives cue-N to cues with no id.2proposetakes supplied translations. It replaces sourceglossary terms longest first.3inspectcounts visible characters and setsbudget=floor(duration*cps).4export_localizedbinds the review to a SHA-256 fingerprint ofproposals and cps.5Youedit decisions.json, set approved per cue, thenrun again with --decisions.6CLIwrites reviewed.vtt only when every cue isapproved.

Subtitle input (samples/input.json)#

{
"vtt": "WEBVTT\n\nmap\n00:00.000 --> 00:03.000\nOpen the map.\n...",
"translations": {
"map": "Abre el map.",glossary turns it into "Abre el mapa."
"label": "Escribe un nombre descriptivo ..."2 s at cps 12, budget 24
},
"glossary": {"map": "mapa", "marker": "marcador"},source to target
"cps": 12optional, the default is 17
}

Glossary publisher rules#

Term id
lower case, matches ^[a-z][a-z0-9-]*$, and is unique.
Phrases
a term or alias must not repeat across the glossary, in any case.
Matching
matchTerms() tries the longest phrase first and needs word boundaries.
Skipped text
text inside pre, code and a stays untouched.
Attributes
only class, id, title, lang and href on a.
Links
href must start with https://, http:// or #.
Definition
a native button with aria-expanded shows a role="note" span.

Pick a multilingual model#

TaskCode
Classification, 100 languagesXLM-R-base fine-tuned
Zero-shot classificationjoeddav/xlm-roberta-large-xnli
Translation, 200 languagesfacebook/nllb-200-distilled-600M
Low-resource languageXLM-V or a related-language fine-tune
Few-shot epochsnum_train_epochs=5
Few-shot learning ratelearning_rate=2e-5
Long-tail scriptsbyte_fallback=True

Source language choice#

Is English always the best source?
No. Language similarity predicts transfer better than corpus size.
Marathi target?
rank_source_languages() puts Hindi above English.
How many target labels?
100 to 500 examples give 95 to 98 percent of the English baseline.
Why not a higher learning rate?
The multilingual alignment collapses to an English-only model.
What is the fertility tax?
Hindi can need 3 to 5 times the tokens of English.

Tips#

  • Report accuracy per language. An aggregate hides the long tail.
  • Check tokenization fertility on target text before you train.
  • Every translation needs a human review. The tools only flag problems.
  • The UI workbench supports simple named placeholders, not ICU messages.
  • Glossary phrases never cross elements or entity boundaries.
  • The HTML runs locally and sends no data to a third-party service.