
โลคัลไลเซชันจำลอง : ทดสอบความพร้อม i18n โดยไม่ต้องมีคำแปลจริง
คำแปลจริงใช้เวลาและเงิน โลคัลไลเซชันจำลองเปลี่ยนข้อความต้นฉบับเป็นข้อความที่อ่านได้แต่ปลอมชัดเจน เพื่อเผยข้อบกพร่องทันที ทั้งข้อความฮาร์ดโค้ด ข้อความล้น ปัญหา RTL และการต่อข้อความ
โลคัลไลเซชันจำลองคืออะไร?
โลคัลไลเซชันจำลองแทนอักขระต้นฉบับด้วยอักขระกำกับเสียงหรือแบบขยายที่ดูคล้ายกัน เพิ่มส่วนเติมเพื่อขยายข้อความ และครอบด้วยวงเล็บ ผลลัพธ์ยังอ่านได้สำหรับนักพัฒนาแต่ต่างจากข้อความจริงอย่างชัดเจน จึงเห็นข้อความที่ไม่ผ่านฟังก์ชันแปลได้ง่าย
// Pseudo-localization transforms your source strings
// to simulate translation without real translators
// Original:
"Welcome to our application"
// Accented (simulates diacritics):
"[Ẁëľčöṁë ţö öüŕ àṗṗľïčàţïöñ]"
// Expanded (simulates text expansion ~30%):
"[Weeelcooomee tooo ouuur aaappliiicaaatiiioon]"
// Mirrored (simulates RTL layout):
"[noitacilppa ruo ot emocleW]"
// Brackets make untranslated strings immediately visibleการใช้ในโปรเจกต์
ติดตั้ง i18n-pseudo แล้วรันกับไฟล์ภาษา เครื่องมือตรวจรูปแบบอัตโนมัติและสร้างฉบับจำลองที่โหลดเป็นภาษาทดสอบในแอปได้
// 1. Hardcoded strings (not wrapped in t())
// Pseudo strings have brackets/accents, so untranslated
// strings are immediately obvious in the UI
// 2. Text truncation
// Expanded text reveals buttons and labels that break
// when translations are longer than English
// 3. Layout issues
// Accented characters reveal font rendering problems
// RTL mode reveals directional layout bugs
// 4. Concatenation bugs
// "Hello " + name vs t('greeting', { name })
// Pseudo-localization breaks concatenated strings
// 5. Missing i18n wrappers
// Any string not going through the i18n system
// appears as plain English among pseudo textกลยุทธ์การแปลง 7 ชนิด
i18n-pseudo มีกลยุทธ์การแปลง 7 ชนิด แต่ละชนิดทดสอบส่วนต่างกัน ใช้เดี่ยวสำหรับเป้าหมายเฉพาะหรือรวมด้วยค่าตั้งต้นเพื่อครอบคลุมทั้งหมด
// Strategy 1: Accented characters
// Replace ASCII with similar-looking Unicode
// a -> à, e -> ë, o -> ö, etc.
// Preserves readability while testing rendering
// Strategy 2: Text expansion
// Pad strings to simulate longer translations
// German is ~30% longer, Finnish ~40% longer
// Helps catch UI overflow early
// Strategy 3: Brackets/wrappers
// Wrap strings in [brackets] or «guillemets»
// Makes untranslated strings visually obvious
// Strategy 4: Bidi/RTL
// Mirror text for right-to-left testing
// Catches layout issues before Arabic/Hebrew testing
// Strategy 5: Combined
// Apply all strategies simultaneously
// Maximum coverage in one passค่าตั้งต้นในตัว 5 แบบ
ค่าตั้งต้นรวมหลายกลยุทธ์สำหรับสถานการณ์ทั่วไป ใช้ค่าตั้งต้นเพื่อทดสอบเร็วหรือสร้างชุดกำหนดเอง
// Using i18n-pseudo CLI
npx i18n-pseudo generate \
--source locales/en.json \
--output locales/pseudo.json \
--preset accented
# Available presets:
# accented - Ḣëľľö Ẁöŕľð (default)
# expanded - Heeellooo Wooorld
# mirrored - dlroW olleH
# brackets - [Hello World]
# maximum - [Ḣëëëľľľöööö Ẁöööŕŕŕľľľðððð]
// i18n-pseudo.config.json
{
"source": "locales/en.json",
"output": "locales/pseudo.json",
"preset": "maximum",
"expansion": 1.4,
"wrapper": ["[", "]"],
"exclude": [
"*.url",
"*.email",
"branding.*"
]
}การเชื่อมต่อ CI/CD
รันโลคัลไลเซชันจำลองใน CI เพื่อจับการถดถอย สร้างไฟล์จำลอง เรนเดอร์หน้าสำคัญ แล้วเทียบภาพฐาน ข้อความที่ไม่แปลงคือข้อความฮาร์ดโค้ดใหม่ที่ข้ามฟังก์ชันแปล
# .github/workflows/pseudo-check.yml
name: Pseudo-Localization Check
on:
pull_request:
paths:
- 'src/**'
jobs:
pseudo-test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm ci
- name: Generate pseudo locale
run: npx i18n-pseudo generate \
--source locales/en.json \
--output locales/pseudo.json \
--preset maximum
- name: Build with pseudo locale
run: npm run build
env:
NEXT_PUBLIC_LOCALE: pseudo
- name: Run visual regression tests
run: npx playwright test --project=pseudo
env:
LOCALE: pseudoลองใช้ i18n Agent ตอนนี้
ลากและวางไฟล์แปลของคุณที่นี่
JSON, YAML, PO, XML, CSV, Markdown, Properties
หรือคลิกเพื่อเลือกไฟล์
ภาษาเป้าหมาย