Skip to main content
All CollectionsAppsOthers
Custom placeholders
Custom placeholders

Create your own placeholders and use them in any translation file.

Ilya Krukowski avatar
Written by Ilya Krukowski
Updated over 9 months ago

The custom placeholders feature enables you to create your very own placeholders that can be detected upon translation files importing and exporting. This feature will come in very handy if, for example, you're using non-standard placeholders in your files or placeholders that are not properly recognized by Lokalise.

Introduction

For example, suppose you have a JSON file with the following data:

{
"welcome": "Welcome to the store, {%username%}!"
}

The welcome key uses a {%username%} placeholder which won't be detected properly by Lokalise as it's non-standard (however it may happen that we also don't support certain standard placeholders for some file formats):

As you can see, the curly brackets were not detected as part of the placeholder. It can pose a serious problem when translating this string manually and especially when using machine translation. However, this issue can be easily fixed by creating a custom placeholder!

Installing the app

To get started with the custom placeholders feature, open your Lokalise project and proceed to Apps:

Then find the Custom placeholders item in the list (or use the search box) and click on it:

Then click Install.

Creating a custom placeholder

Now you'll need to enter the opening and closing characters as well as the file format (or simply choose All formats):

For example, I'm going to enter {% and %}, and choose the JSON file format.

Once you are ready, click the Enable app button.

Using custom placeholders

Now if you try to upload a translation file with custom placeholders in place, you'll notice that these are properly displayed in the editor:

Under the hoods, we convert these into Lokalise universal placeholders.

The %s part simply means "a string". Next, you'll be able to export your data in any format and these universal placeholders will be replaced back with your custom ones.

Exporting translations with custom placeholders

To export translations with custom placeholders, navigate to the Download page and choose the desired file format:

Then make sure to choose Raw from the Placeholder format dropdown:

Finally click Build and download. You'll see that Lokalise universal placeholders are replaced with the platform-specific ones once again!

Did this answer your question?