Working with Placeholders

Phrase supports many common placeholder formats that can be used in many localization file formats.

Why you should use placeholder highlighting

When selecting the correct placeholder format for your project you benefit immediately:

  • Placeholders are highlighted in the editor window and can easily be checked and validated for presence in the translation
  • Placeholders are automatically escaped when ordering translations through Phrase and won’t be modified by the external translator at all

Available placeholder formats for highlighting:

Name Description Examples
Rails i18n Rails i18n style placeholders %{count}, %{username}
Gettext Python Gettext placeholders (python-format) %(count)d, %(username)s, %(foo)
C-Style C-Style format with and without positions %1$s, %2$d, %d, %@, %1%@, %1$#@file@, %#@file@, %1$i, $%1$.2f, %.0f%, %ld, %c, %hi, %lu
.Net C#-Style .Net C#-Style format {0,10:C}, {0}, {1:hh}
Simple Message Properties Simple Java Message Properties {1}, {count}d, "{brackets}"
Laravel Laravel placeholders beginning with a colon :name, :NAME, :Name
Square Brackets Placeholder with Square Brackets (BB-Code Style) [u]abc[/u], [PLACEHOLDER]
Single Percentage Placeholder with single enclosing percentage signs %abc%
Double Percentage Placeholder with Double Percentages %%abc%%
Emoji Emoji codes :sob:, :smile:
Dollar Style Placeholders with opening and closing $ signs. $bc$, $.abc$, $!abc$, $+abc$, $-abc$, $-+.!abc$
NSIS Placeholders with starting $ and closing/opening (curly)brackets. ${StdUtils.TrimStr}, $(StdUtils.TrimStr), ${String}
Razor Markup Placeholder to highlight C# Razor expressions without code blocks @DateTime.Now, @(DateTime.Now - TimeSpan.FromDays(3))
Double Curly Placeholders with opening and closing double curly braces, e.g. for use with AngularJS. {{number}}, {{}}, {{username}}
Android XLIFF placeholders Placeholders with opening <xliff:g> and closing </xliff:g>, e.g. for use with AndroidXml. <xliff:g>%1s</xliff:g>, <xliff:g id="star">★</xliff:g>
OASIS XLIFF placeholders Placeholders with closed tag <x id="YOUR_ID">, e.g. for use with Angular2. <x id="id" example="name"/>, <x id="id"/>
Liquid Liquid style placeholders {{count}}, {{username}}

Enabling placeholder styles in your project

When creating or editing a project in Phrase you can specify the placeholder formats within the “Placeholders” tab. Select all required format styles and see all matching placeholders highlighted immediately when working with Translation Center and In-Context-Editor.

Placeholder conversion

Placeholder conversion is an attempt to reduce translation workload on multi platform development. If you are developing on multiple mobile platforms with the intention to share your translations between these platforms and you don’t want to maintain a separate project for each platform then our placeholder conversion can help you to accomplish that. Whenever downloading a locale within the translation center or via our API you can choose the convert placeholder format option. You can also activate this format option in your .phraseapp.yml configuration file. The placeholders in your translations will be converted to match format specific requirements.

Placeholder conversion is only available for the following localization file formats:

Please note that the placeholder conversion is limited to Android XML and iOS strings string format specifiers (cstyle placeholder style).

Missing a format?

We constantly add support for new formats. If you should require a specific placeholder format that is not supported yet, please contact us and specify the placeholder settings you would love to see in Phrase.