Languages

Template Strings

Template strings are hardcoded theme text that should be translated without editing the template file.

Translate A String#

Use the translate modifier:

phpresources/views/partials/post-card.php
<a href="{{ url }}">{{ "Read more" | translate }}</a>

Use t as a shorter alias:

php
{{ "Read more" | t }}

When a word needs context, pass a quoted context:

php
{{ "Post" | translate("button label") }}

TemplateX compiles these to WordPress gettext helpers with the theme text domain.

Shared Template Text#

Static text written directly inside TemplateX templates, partials, and blocks is also registered as shared template text.

For example, a block heading like <h2>Latest posts</h2> is translated once per language and reused everywhere that exact source text appears.

Manage Strings#

Open Appearance > Template Strings. Pick a target language, translate each row, and save.

The Template Strings screen can fill empty rows from a LibreTranslate-compatible endpoint. Shared-hosting sites can also use the browser-assisted flow: translate the admin page with the browser, then use Use all browser translations before saving.

Locale-aware modifiers use the active language locale on the frontend. For example, {{ date | relative }} renders through WordPress' translated relative-time strings for the current language.