Skip to main content

Keep variables out of the translation

If you translate software strings, your text is not only text. A line like this is part sentence, part code:

{name} - {taxNumber} - Reg. No.: {registrationNumber}

Reg. No.: is language and needs translating. Everything in braces is a slot your app fills in at runtime, and it has to come back exactly as it went in. A translated placeholder is not a small error: your app either shows a raw {name} to your users or fails to render the line at all.

Taia handles this for you. This page explains what is protected automatically and what you can turn on.

What is protected automatically

You do not need to configure anything for these. Taia removes them from the text before any engine sees it, and puts them back afterwards:

StyleExamples
Curly braces{name}, {count}, {user.first_name}, {0}
Double braces{{name}}
Template literals${total}
printf%s, %d, %i
Named printf%(customer)s
Positional printf%1$s, %2$d

This applies to every file format and every translation engine, including Instant AI translation. It also applies in the editor, where placeholders appear as protected tags that cannot be edited by accident.

So the example above translates to exactly what you want:

{name} - {taxNumber} - Reg. No.: {registrationNumber}

with only Reg. No.: changed.

What about square brackets?

Square brackets are a judgement call, so they are off by default.

In some projects [username] is a variable. In others, brackets are ordinary writing that has to be translated:

  • [sic]
  • [Note]
  • Read the guide [see chapter 4]

Turning bracket protection on for everyone would silently ship real text back untranslated, so Taia asks instead.

Turn on bracket protection

You need to be an organization manager.

  1. Go to your Profile page and click Manage Organization.
  2. Click Org settings in the top right.
  3. Select the Advanced tab.
  4. Expand Placeholder Protection.
  5. Switch on Treat [square brackets] as placeholders.
  6. Click Save.

The setting applies to every project in your organization from that point on.

Even with it on, only single-token brackets are protected. [username] and [count] are left alone; [see chapter 4] is still translated, because a bracketed phrase with spaces in it is almost always writing rather than a slot.

Setting it from the API

If you integrate with Taia over the API, you can set it per request instead of organization-wide. Pass protect_bracket_placeholders when you start the translation:

POST /api/v1/projects/{project_id}/instant-mt
{
"translation_engine": "basic",
"protect_bracket_placeholders": true
}

Omit it and the project follows your organization's setting.

What is not protected

ICU message format is left as it is, on purpose:

{count, plural, one {# file} other {# files}}

The words inside those inner braces (file, files) genuinely need translating, so Taia does not treat the whole construct as a slot.

A literal percent sign written as %% is not treated as a printf slot, because it is not one.