How to translate YAML files for localization

Kinga Pomykała
Kinga Pomykała
Last updated: August 23, 20258 min read
How to translate YAML files for localization

YAML is a developer's best friend for clean, human-readable configuration, and it's also a popular format for storing translation strings in frameworks like Ruby on Rails, Symfony, Laravel, Next.js, and more. But translating YAML files can get messy fast: indentation is unforgiving, keys drift out of sync across locales, and collaboration between developers and translators often happens in spreadsheets or DMs.

In this guide, you'll learn how to translate YAML files effectively, without breaking the structure or losing context. We'll cover common challenges, best practices, and tools that make the process smoother.

What is YAML?

YAML (YAML Ain't Markup Language) is a human-friendly data serialization standard often used for configuration files and data exchange between languages with different data structures. It emphasizes readability and simplicity, making it a popular choice for developers.

Here is a simple example of a YAML file used for localization:

en:
  site:
    name: "Pillow Hotel"
    slogan: "Your comfort, our priority"

  navigation:
    home: "Home"
    rooms: "Rooms"
    dining: "Dining"
    spa: "Spa & Wellness"
    booking: "Book Now"
    contact: "Contact Us"
    about: "About Us"

  homepage:
    welcome_title: "Welcome to Pillow Hotel"
    welcome_message: "Experience luxury and comfort in the heart of the city."
    explore_button: "Explore More"

YAML characteristics

YAML has several key features that make it suitable for localization:

  • File extension: .yml or .yaml
  • Human-readable with a clean, minimal syntax.
  • Indentation defines structure (spaces only, no tabs).
  • Scalars can be plain (hello), single-quoted ('hello'), or double-quoted ("hello") (for escapes and interpolation)
  • Collections: maps (key–value objects) and sequences (lists).
  • Comments start with # and are ignored by parsers.
  • Anchors & aliases (& / *) let you reuse content.
  • Multi-line strings using | (literal) or > (folded).
  • Supports Unicode for international characters.

Check our our block post and learn more about differences between JSON and YAML files in localization.

YAML in i18n frameworks

YAML is widely used for localization (i18n) keys in popular stacks:

  • Ruby on Rails: Uses YAML files for storing translations in config/locales/*.yml.
  • Symfony: Supports YAML for translations in translations/*.yaml.
  • Laravel: Often JSON, but YAML is used in tooling and configs in resources/lang.
  • Django: Primarily uses .po files, but YAML can be used with third-party packages.
  • Static sites & JAMStack: docs, marketing sites, MDX with YAML front-matter.

Common challenges in translating YAML files

While YAML is great for localization, it comes with its own set of challenges:

  • Indentation errors: One extra space breaks structure and your app fails to parse.
  • Key mismatches: en gains a new key that never reaches es, causing missing translations at runtime.
  • Placeholder mismatches: {name}, %{name}, or {{name}}, frameworks differ. Translators may accidentally change or delete placeholders.
  • Pluralization complexity: Languages have many plural forms; mapping them to YAML keys (e.g., one, few, many, other) is easy to get wrong.
  • Collaboration friction: Not everyone is comfortable editing YAML. PRs with merge conflicts or syntax mistakes slow things down.
  • QA at scale: Manually checking hundreds of keys across multiple languages is error-prone and time-consuming.
  • Context loss: Short keys like title or save lack context, leading to vague or incorrect translations.
en:
  site:
    name "Pillow Hotel"        # ❌ Missing colon
    slogan: "Your comfort, our priority

  navigation:
     home: "Home"              # ❌ Indentation error (extra space)
    rooms: "Rooms"
    dining: "Dining"
    spa: "Spa & Wellness"
    booking: "Book Now"
    contact: Contact Us        # ❌ Missing quotes
    about: "About Us"

  homepage:
    welcome_title: "Welcome to Pillow Hotel"
    welcome_message: "Experience luxury and comfort in the heart of the city."
    explore_button: "Explore More

How to translate YAML files

There are several approaches to translating YAML files.

Manual translation

Depending on your team's size and workflow, you might choose to translate YAML files manually.

If you go for managing translations in multiple YAML files (e.g., en.yml, es.yml, fr.yml):

  1. Duplicate your source file (e.g., en.yml) to create a new locale (e.g., es.yml).
  2. Keep identical key paths; translate only the values.
  3. Use a YAML linter or validator to check for syntax errors after editing.
Translating YAML files manually
Translating YAML files manually

For multi-language files (e.g., locales.yml):

  1. Add new language sections under the root key (e.g., es:).
  2. Translate values while preserving the structure.
  3. Validate the entire file to ensure no syntax issues.

Here is an example of a simple multi-language YAML file:

en:
  site:
    name: "Pillow Hotel"
    slogan: "Your comfort, our priority"
  navigation:
    home: "Home"
    rooms: "Rooms"
    dining: "Dining"

es:
  site:
    name: "Hotel Almohada"
    slogan: "Tu comodidad, nuestra prioridad"
  navigation:
    home: "Inicio"
    rooms: "Habitaciones"
    dining: "Restaurante"

Pros: full control, no new tools.

Cons: slow, error-prone, hard to scale or collaborate.

Assisted translation (code-aware editor)

If your team is comfortable with YAML but wants some help, use a code-aware editor that understands YAML, like VSCode.

  • Install YAML extensions for syntax highlighting and validation.
  • Use multi-cursor editing to translate multiple lines at once.
  • Use search-and-replace for placeholders or common phrases.
Translating YAML files in VSCode
Translating YAML files in VSCode

Pros: faster than raw text editing, fewer syntax errors.

Cons: still manual, limited collaboration features.

Centralize your keys in a translation platform like SimpleLocalize and let it handle structure, context, and synchronization.

Typical workflow:

  1. Import your YAML files (upload, Git integration, CLI or API).
  2. Pre-translate with auto-translation to create a baseline.
  3. Review & collaborate with translators and developers in one place.
  4. QA check for placeholders, length, and missing translations.
  5. Export clean, validated YAML files back to your repo.
  6. Automate the loop in CI so new keys are detected and distributed automatically.
Translating YAML files with SimpleLocalize

Pros: scalable, less risk, faster release cycles.

Cons: introduces a new tool (with big time savings).

Check out our guide on how to auto-translate YAML files with SimpleLocalize.

Best practices for translating YAML files

Here are some tips to keep your YAML translations clean and maintainable:

  • Mirror the same key tree across all locales: Keep key paths identical. Use tooling to detect missing or extra keys.
  • Keep keys stable; change values only: Keys are your API. Changing them causes churn across all languages.
  • Use descriptive, namespaced keys: Prefer checkout.payment.failed over failed.
  • Add context notes: Provide translator notes (comments, screenshots, descriptions) for ambiguous strings.
Translation key screenshot and description context in SimpleLocalize
Translation key screenshot and description context in SimpleLocalize
  • Protect placeholders: Decide on a placeholder style (e.g., %{name}) and enforce it. Add QA rules that block exports when placeholders change.
  • Handle pluralization explicitly: Use plural keys required by your framework. Example:
en:
  cart:
    item:
      one: "You have 1 item in your cart."
      other: "You have %{count} items in your cart."
  • Avoid embedding HTML when possible: Prefer plain text with placeholders; if markup is necessary, document allowed tags.
  • Validate early and often: Add a linter to pre-commit/CI. Catch indentation, duplicate keys, and invalid YAML before review.
  • Freeze source language first: Review and approve en (or your source) before translation to prevent rework.
  • Glossary and style guide: Maintain product names, capitalization, and tone guidelines; enforce them in QA.

Automate YAML translation with SimpleLocalize

Turn YAML localization into a continuous, low-touch workflow with SimpleLocalize:

  1. Connect your repository. Point SimpleLocalize to your YAML paths (e.g., config/locales/**/*.yml). It scans and imports keys with their full path, preserving structure.

Use GitHub App, GitLab, Bitbucket, or upload files directly.

  1. Pre-translate automatically. Run auto-translation for new or changed strings to create a high-quality draft instantly. Placeholders are protected, so %{name} stays intact.
  2. Review with context. Add screenshots and descriptions so translators see how strings are used. Use comments and community suggestions to resolve questions quickly.
  3. Keep locales in sync. When a developer adds checkout.payment.failed in en.yml, SimpleLocalize detects it, marks it “needs review" and can run an automation to auto-translate it to all target languages.
  4. Export production-ready YAML. Download or sync back to your repo/CI. SimpleLocalize validates syntax, placeholders, and missing translations before export, so you never break your app.
  5. Make it continuous. Wire SimpleLocalize into CI so every push:
    • imports updated YAML,
    • triggers pre-translation,
    • and exports ready-to-deploy files.

Result: fewer PR ping-pong sessions, no broken indentation, and faster, safer multilingual releases.

Check more examples of AI-powered localization workflows.

Conclusion

Translating YAML files doesn't have to mean manual edits, broken indentation, or last-minute string hunts. By keeping consistent keys, validating syntax, and centralizing your workflow in SimpleLocalize, you can turn localization into a smooth, repeatable part of your release process.

Upload your YAML files, run machine translation for a head start, invite reviewers, and export clean, synchronized locales in minutes, not days. Ready to ship a truly multilingual product? Import your YAML to SimpleLocalize and see how much time (and stress) you save on your next release.

Kinga Pomykała
Kinga Pomykała
Content creator of SimpleLocalize
Ready to say
|

Greet your customers
in their native language

Start for free
5-minute setupNo credit card required