Help Center Translation Management
Adding Variables To Phrases

Adding Variables To Phrases

Last updated: a month ago
3 minute read
Steven Wise
CEO at SiteTran

ALL ARTICLES

Help Center

Variable Translations In Phrases

This crucial feature is a huge time and money saver. If your website contains dynamic or varying content such as dates, numbers (with currencies), names, or anything of that nature, powered entirely through SiteTran, requiring no additional work from a developer, your content can be translated.

Remember, this can all be done directly in SiteTran, so you don't need to make any changes directly to your website. Isn't that amazing!?

Activating variables for your phrase in SiteTran is a 2 step process. (1) First you need to define the word(s), or number(s), etc. in the phrase that varies, and then (2) you need to add the variables into the corresponding translation. To define the variables in the phrase, edit your original phrase, select the parts of the phrase that vary. Click on the 3 vertical dots on your phrase in site-phrases-in-page then click the “Edit” button.

Example Use Case:

Let's take this phrase as an example:

Hello, Jonathan! Welcome to our site.

In the phrase above, the only word that varies is “Jonathan”. Depending on the site’s visitor, it will show a different name. It would be really hard (not to mention expensive) for a translator to translate that phrase with every single possible name combination… So here’s our solution:

Hello, Jonathan! Welcome to our site.

Becomes

Hello, {{name}}! Welcome to our site.

We surrounded the name with 2 curly braces. Just the name. Notice how the exclamation mark and the space are outside of our double curly braces {{variables_go_here}}

After you save your original phrase edit, you will need to translate the phrase as you normally do in the translator interface, but you must include your (untranslated) variable in the translation. Translated to French it becomes:

Bonjour, {{name}}! Bienvenue sur notre site.

SiteTran automatically swaps your variables out of the original phrase on your site and into the translation.

Adding Multiple Variables To A Phrase:

It even works with phrases that have multiple variables. Translating phrases with multiple varying segments is basically the same as above.

Let’s say we have the phrase:

Joined: March 10, 2022

And we want to be able to control the position of the variables, because in Spanish, for example, it would be:

Unió: el 10 de marzo de 2022

Here’s what the edited original phrase would look like:

Joined: {{month_name}} {{month_day}}, {{year}}

The translator would need to input

Unió: el {{month_day}} de {{month_name}} de {{year}}

Importance Of Unique Variables:

Note: you cannot add the same variable into the same phrase twice, but you can use a different variable name for it. For example if you have the phrase:

Hello, Jonathan! Welcome to our site. You are Jonathan #353.

The {{name}} variable cannot be used twice in the same phrase. You would need to do something like this

Hello, {{name}}! Welcome to our site. You are {{name_again}} #{{number}}.

Special Considerations:

Variables work perfectly - almost always. The only time there can be an issue is if your phrase matches a different phrase, For example if you have the phrase:

March 2022

So you convert it into a phrase with a variable:

{{month_name}} 2022

This COULD be problematic if there’s a phrase on your site like:

I was born in 2022

The SiteTran Widget would think that “I was born in” is the variable, and it would leave it untranslated.

In instances like that, you will want to add a regular expression to have more explicit matching rules. You would edit the regex for {{month_name}}, so that it matches more specific phrases. You can do that in the variable editing interface.

Note: It’s nice to leave a comment with the original (unedited) phrase in the translator interface, so that translators can clearly see what the phrase looks like.

Couldn't find what you were looking for?

In this article

Website Translation Made Easy