Purpose

In Wonderful Relations, text formatting and translation mechanisms allow for dynamic rendering of content. This is particularly useful in caching scenarios, where pre-rendered content still needs to be adaptable for different languages and formats without requiring a full reprocessing.

By using placeholders and transformation functions, text can be formatted dynamically or translated at runtime, ensuring flexibility even when caching is enabled.

Date Formatting

Certain parts of text can be dynamically formatted using the __format() function. This allows placeholders to be replaced with correctly formatted values before rendering.

Example

__format('d. M. Y', '##date##')__

If ##date## contains 2021-01-01, the result will be:

1. Jan. 2021

This method ensures that dates and other values remain dynamic, even if the surrounding content is preprocessed or cached.

Translation Handling

To ensure multilingual support, Wonderful Relations provides a translation layer using the __() function. This allows text to be dynamically translated based on the active language.

Basic Usage

__(Value)__

This function marks Value for translation, allowing it to be adapted at runtime.

With a Specific Text Domain

For better language control, translations can be linked to a text domain:

__(Value, 'text-domain')

This ensures that the correct translation is applied, even when different text domains are used within a system.