Variables

How to Use Variables & Placeholders

This article will explain GL Strings variables and placeholders and how they are utilized in GL Strings projects.


Table of Contents

  1. What are Variables?
  2. Variables and Translation Orders
  3. Android/iOS Placeholder Conversion
  4. How to Find Instances of Missing Variables

What are Variables?

GL Strings merges multiple concepts under the term Variables on the dashboard:

  1. Content formatted like HTML and/or XML meaning everything between <> angle brackets
  2. C-style String Formatting starting with a % that are being used in slight variations on Android, iOS, and other software development frameworks to insert dynamic strings, numbers, dates, and other wildcards into static translated strings e.g. %@ (iOS String) or %s (Android String)
  3. Placeholders and other Ordered Formatters between Curly Brackets/Braces {} like they are used in C# and Angular projects for example {0} (C#), or { {var_name} } (AngularJS)
  4. ICU Message Syntax that is a part of strings for plurals, time, dates, and variables that are switched based on context such as gender. Often used in arb files, yaml, po and other file types. See the ICU Syntax article for more information.

On the GL Strings dashboard placeholders are often referred to as Variables, except for placeholder conversion between android and iOS. When uploading strings to the GL Strings dashboard, placeholders found within strings are included in the upload. GL Strings variables ensure that placeholder content within source text are included in the target translation.

Variables are highlighted in gray in the Editor.


Back to Top

Variables and Translation Orders

If content with variables is included in translation orders via the GL Strings Order menu, variables are removed from the editable text. The TransPerfect translators will not be able to alter the content inside a variable. This prevents any accidental issues with the code such as the removal of a bracket. When translations are delivered, they will contain the variable placed at the most appropriate section of the sentence by the translator.

If the content within variables needs to be translated, the variables can be removed from the string via the Editor interface. However, this might have an impact on the application that will be ingesting the content.


Back to Top

Android and iOS Placeholder Conversion

The GL Strings SDK and CLI includes a new feature to convert iOS and Android placeholders within strings. Placeholder conversion reduces the translation workload for multi-platform projects. If you are developing for multiple platforms and plan to share your translations between the platforms, our placeholder conversion can help. See the Placeholder Conversion article for more details.


Back to Top

How to Find Instances of Missing Variables

If a key has a variable in the source value and that variable is completely missing or even just slightly different in the target value, the String Management Interface generates a warning. Users can filter to locate those strings with the missing variables filter.

  1. Navigate to the Editor for a specific project, then click the filter on the right hand side.
  2. Select With Issues then click Variable Missing
  3. This filter will display any translations returned with missing variables


Back to Top