DEV Community

Sasa
Sasa

Posted on

How to localize Klaviyo email campaigns without breaking tokens

The Klaviyo localization problem

Klaviyo uses Django-style template syntax for personalization: {{ first_name|default:"there" }}, {{ order.total|currency }}. When you send these templates for translation, two things break consistently.

First, translators modify the variable names. {{ first_name }} becomes {{ Vorname }} in German workflows. Second, filter arguments get translated — the "there" in {{ first_name|default:"there" }} is legitimate translatable content, but it sits inside a token that should otherwise be untouched.

The right approach

Protect the entire token at import. Replace {{ first_name|default:"there" }} with a stable placeholder before any content reaches a translator. Restore the original on export.

For Klaviyo specifically, you need to handle:

  • Simple variables: {{ first_name }}
  • Variables with filters: {{ first_name|default:"there" }}
  • Numeric filters: {{ order.total|currency }}

The regex pattern that covers Klaviyo Django syntax:

import re
KLAVIYO_PATTERN = re.compile(
    r'\{\{[-\s]*[\w.|:()"\' ]+[-\s]*\}\}'
)
Enter fullscreen mode Exit fullscreen mode

Connecting Klaviyo to a localization workflow

Transendly connects directly to Klaviyo via API. Import your template, tokens are auto-detected and locked, translators work on clean copy, approved translations push back to Klaviyo as new templates per locale.

Free 21-day trial at transendly.com.

Top comments (0)