Bakerversity
Module 4: Respecting the Reader's Time & EyesLesson 8 of 8

M4 Summary Diagnostic: File Formats, Parsers & Filters

This multi-part diagnostic exercise tests your ability to inspect, parse, and remediate broken file payloads across all major structured data formats, localization interchange standards, and media subtitle streams.

Overview & Objective

Before advancing to Module 5 (Build Automation, CI/CD & L10n Quality Assurance), you must complete this Module 4 Diagnostic Pre-Flight Check.

This multi-part diagnostic exercise tests your ability to inspect, parse, and remediate broken file payloads across all major structured data formats, localization interchange standards, and media subtitle streams:

  1. Structured Data: Eliminating JSON syntax errors, YAML tab/indentation violations, and XML entity corruption.

  2. Interchange Standards: Auditing XLIFF 2.0 segment states, verifying inline placeholder protection (<ph>), and repairing Gettext PO context collisions (msgctxt) and plural arrays (msgstr[N]).

  3. Linear Media: Validating WebVTT vs. SRT millisecond timestamp delimiters, enforcing cue boundary blank line separation, and repairing unclosed inline styling tags (<i>, <b>).

Scenario Briefing

You are preparing a major global release payload across three application channels:

  1. Web App Frontend (JSON & YAML): The German JSON localization delivery crashes JSON.parse() due to unescaped inner double quotes and a trailing comma. Meanwhile, a localized YAML configuration file fails in the CI pipeline due to stray tab characters.

  2. Core Mobile Service (XLIFF & PO): The Japanese XLIFF delivery contains unreviewed segment states and damaged inline placeholder tags. The Polish Gettext PO file causes context collisions on identical words and crashes on numeric count 5 due to an incomplete plural array.

  3. Video Broadcast Stream (WebVTT & SRT): The Spanish subtitle stream drops cues on HTML5 video players because WebVTT timestamps were saved with commas instead of periods, and an unclosed <i> tag causes the entire video caption overlay to turn italic.

Your task is to set up the diagnostic workspace in VS Code, execute the step-by-step remediation procedures, and verify all files against production quality criteria.

Part 1: Hands-On Diagnostic Execution

Step 1: Environment Setup

  1. Open your loc_lab working directory in Visual Studio Code (Cmd + O on macOS / Ctrl + K Ctrl + O on Windows).

  2. Inside assets/loc/, create a diagnostic directory named module_4_diagnostic.

Step 2: Repairing Structured Data Assets (JSON & YAML)

  1. Create assets/loc/module_4_diagnostic/app_de.json and paste the corrupted content:

    JSON

    app_de.jsonjson
    { "dialog_title": "Willkommen bei "BankCorp"", "action_submit": "Jetzt überweisen", }
  2. Create assets/loc/module_4_diagnostic/config_de.yaml and paste (ensure line 3 uses a Tab character):

    YAML

    config_de.yamlyaml
    app_settings: theme: "Dark" notifications_enabled: true
  3. Execute Remediation:

    • In app_de.json: Escape the inner double quotes on line 2 (\"BankCorp\") and remove the trailing comma on line 3. Save as app_de_clean.json.

    • In config_de.yaml: Replace the tab character on line 3 with 2 spaces. Save as config_de_clean.yaml.

Step 3: Repairing Localization Interchange Assets (XLIFF & PO)

  1. Create assets/loc/module_4_diagnostic/delivery_ja.xlf and paste:

    XML

    delivery_ja.xlfxml
    <?xml version="1.0" encoding="UTF-8"?> <xliff version="2.0" xmlns="urn:oasis:names:tc:xliff:document:2.0" srcLang="en" trgLang="ja"> <file id="f_main" original="src/App.json"> <unit id="u_welcome"> <segment state="initial"> <source>Hello, <ph id="0" dataRef="d1"/>!</source> <target>こんにちは、<ph id="0" dataRef="d1"/>様!</target> </segment> </unit> </file> </xliff>
  2. Create assets/loc/module_4_diagnostic/messages_pl.po and paste:

    Code snippet

    messages_pl.po
    msgid "" msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Plural-Forms: nplurals=3; plural=(n==1 ? 0 : n%10>=2 && n%10<=4 && (n%100<10 || n%100>=20) ? 1 : 2);\n" msgid "Save" msgstr "Zapisz" msgid "One file deleted." msgid_plural "%d files deleted." msgstr[0] "%d plik został usunięty." msgstr[1] "%d pliki zostały usunięte."
  3. Execute Remediation:

    • In delivery_ja.xlf: Update state="initial" to state="translated" on the <segment> element. Ensure <ph id="0" dataRef="d1"/> matches between <source> and <target>.

    • In messages_pl.po: Add msgctxt "action_button_save" before msgid "Save" to resolve context ambiguity. Add the missing third plural array entry msgstr[2] "%d plików zostało usuniętych.".

Step 4: Repairing Linear Media Subtitle Assets (WebVTT & SRT)

  1. Create assets/loc/module_4_diagnostic/stream_es.vtt and paste:

    Code snippet

    stream_es.vtt
    WEBVTT cue-01 00:00:01,500 --> 00:00:04,200 <v Speaker1>Bienvenido a la <i>transmisión en vivo! cue-02 00:00:04.500 --> 00:00:08.000 <v Speaker2>Comencemos ahora.
  2. Execute Remediation:

    • Change the comma in line 4 (00:00:01,500) to a period (00:00:01.500).

    • Close the italic tag on line 5: <i>transmisión en vivo!</i>.

    • Add a blank separating line between line 5 and cue-02.

    • Save as stream_es_clean.vtt.

Part 2: Diagnostic Verification Matrix

Verify your remediated files against this master diagnostic evaluation matrix:

Format / Asset

Target File

Diagnostic Check Criteria

Pass Status

JSON

app_de_clean.json

Inner quotes escaped (\"BankCorp\"); trailing comma removed; valid JSON linting.

[ ]

YAML

config_de_clean.yaml

Zero tab characters; exact 2-space indentation hierarchy across all keys.

[ ]

XLIFF 2.0

delivery_ja.xlf

<segment state="translated">; <ph> tags preserved verbatim between source & target.

[ ]

Gettext PO

messages_pl.po

msgctxt disambiguation present; complete 3-form plural array (msgstr[0], msgstr[1], msgstr[2]).

[ ]

WebVTT

stream_es_clean.vtt

Header WEBVTT present; period millisecond delimiters (.500); blank line cue separators; balanced <i>...</i>.

[ ]

Diagnostic Self-Assessment Review

Before advancing, confirm your understanding of these core Module 4 principles:

  1. Why do unescaped inner double quotes break JSON files?

    JSON parsers interpret an unescaped double quote as the end of a string token, causing immediate syntax crashes on subsequent characters.

  2. What is the structural difference in millisecond delimiters between WebVTT and SRT?

    WebVTT strictly requires a period (00:00:01.500), whereas SubRip Text (SRT) strictly requires a comma (00:00:01,500).

  3. Why are <ph> tags and msgctxt entries critical in interchange formats?

    <ph> tags lock variable code tokens inside XLIFF so CAT tools protect them from human error, while msgctxt prevents translation collisions when identical source words require different target terms based on context.

Ready to move on?

Mark this lesson complete when you’re ready.

→ Sign in to track your progress