Placeholder Detection and Customization in PTC

Placeholders store dynamic values in software, like names and dates. Learn how PTC detects common placeholder formats during translation and lets you add custom ones.

PTC detects placeholders in strings and keeps them unchanged during translation. Since different resource file formats have their own placeholder syntax, PTC:

  • Recognizes common placeholder formats using predefined regex patterns
  • Applies format-specific rules to correctly identify and handle placeholders

Here are examples of commonly used supported placeholder formats, along with the regular expressions (regex) used to detect them:

Placeholder Example

Regular Expression (Regex)

%service%
\%\w+\%
%{service}
\%\{\w+\}
:service:
\:\w+\:
${service}
\$\{\w+\}
$service$
\$\w+\$
''service''
\'\'\w+\'\' 
[service]
\[\w+\] 
@[service]
\@\[\w+\]
{{service}}, {{service_name}}
\{\{[\w_-]+\}\}
{service}, {service_name}
\{[\w_-]+\}

Adding Custom Placeholders

Your resource files may have non-standard placeholders or ones PTC doesn’t recognize. You can add custom placeholders to make sure PTC detects and preserves them during translation.

On the Settings → String Placeholders page, PTC lists predefined placeholders based on the detected project structure and the types of resource files in your project.

Here, you can:

  • Edit or remove existing placeholders for the whole project or for a specific resource file type.
  • Add new placeholder formats if your project or resource files use a unique structure that isn’t recognized by default

After making any changes, save your settings to apply the updates.

Best Practices For Custom Placeholders

When adding custom placeholders, follow these best practices to prevent translation issues:

Keep placeholders simple

Overly complex placeholder formats are harder for systems to recognize and interpret correctly. For example:

  • Preferred: <name>
  • Overly complex: <user-name&role-123>

Use unique formats

When two placeholders share parts of their structure, translation tools often can’t distinguish between them. For example, take a look at this complex and simple placeholder that unintentionally overlap:

  • Complex placeholder: {user_details}
  • Simple placeholder: {user}

In this example, {user_details} might be mistakenly detected as {user} because {user} is part of the complex placeholder.

Use words between placeholders for context

Surrounding words provide context that helps PTC understand how placeholders fit within a sentence. Don’t rely on human notes to clarify placeholders, as PTC doesn’t process them. Instead, make placeholders clear from the string.

  • Preferred: "Hello, <name>! Your order number is <order_number>."
  • Not recommended: "<name> <order_number>"

What Happens if PTC Encounters Issues with Your Placeholders?

PTC flags strings that are unclear for different reasons, such as:

  • Having too many placeholders with not enough context
  • Containing ambiguous text
  • Being single-word strings

If this happens, you’ll see a recommended action in your PTC dashboard prompting you to review unclear strings. To address strings with unclear placeholders, you can:

  • Update the string directly in your project—for example, by simplifying or reordering the placeholder formats.
  • Follow prompts from PTC to provide more information about the placeholders’ purpose.

Translation Customization
Scroll to Top