Lab 1.2: Rescuing Code from Rich Text Corruption
Act as a localization engineer diagnosing and fixing a corrupted JSON string table that was accidentally edited in a rich-text word processor.
Objective
In this lab, you will act as a localization engineer diagnosing and fixing a corrupted JSON string table that was accidentally edited in a rich-text word processor. You will identify curly "smart" quotes, hidden formatting artifacts, and unexpected auto-capitalization, and safely restore the file to valid, plain-text UTF-8 code using Visual Studio Code.
Required Setup & Prerequisites
Editor: Visual Studio Code installed.
Working Directory: Your active
loc_lab_1-1folder (orloc_lab_1-2).
Step-by-Step Instructions
Step 1: Create the "Corrupted" Rich-Text Export Asset
Open VS Code.
In the Explorer panel, navigate to
assets/loc/software/.Create a new file named
ui_ru_corrupted.json.Copy and paste the following broken code snippet into the file:
json{ “btn_start”: “Начать игру”, “btn_options”: "Настройки", “welcome_msg”: “Добро пожаловать в “Королевство”!” }
Save the file (
Cmd + S/Ctrl + S).
Step 2: Spotting Syntax Errors in VS Code
Look at line 2: Curved quotes (
“and”) are used aroundbtn_startandНачать игру. JSON syntax strictly requires straight quotes (").Look at line 4: In addition to curved outer quotes, the inner quotes around
Королевствоcreate an unescaped string conflict, breaking the key-value boundary.
Step 3: Perform Global Search & Replace for Smart Quotes
Open Find and Replace:
macOS:
Cmd + Option + FWindows:
Ctrl + H
Find:
“Replace:"Click Replace All.Find:
”Replace:"Click Replace All.
Step 4: Fix Unescaped Inner Quotes & Sanitize Structure
Insert an escape character (a backslash
\) before each inner quote in line 4:json"welcome_msg": "Добро пожаловать в \"Королевство\"!"Verify that your final
ui_ru_corrupted.jsonfile matches this clean code exactly:
json{ "btn_start": "Начать игру", "btn_options": "Настройки", "welcome_msg": "Добро пожаловать в \"Королевство\"!" }
Save the file. Observe that all red squiggly syntax warnings in VS Code disappear.
Step 5: Rename to Valid Production File
In the Explorer panel, right-click
ui_ru_corrupted.jsonand select Rename (or pressF2).Rename the file to
ui_ru_clean.json.Confirm that the status bar displays
UTF-8and that the filename ends in.json.
Self-Verification Checklist
Before moving forward, check your cleaned file against these parameters:
[ ] All smart/curly quotes (
“”) have been replaced with standard straight quotes (").[ ] Inner quotes within text values are properly escaped using backslashes (
\").[ ] VS Code shows zero red syntax error highlights in the problem panel (
Cmd + Shift + M/Ctrl + Shift + M).[ ] File is saved with UTF-8 encoding and named
ui_ru_clean.json.
Ready to move on?
Mark this lesson complete when you’re ready.