ZenMagick 0.9.10


Functions


Function Summary
void

_vzm(string text, mixed ...)

Convenience version of _zm using a null context and the default domain.

string

_zm(string text, mixed context, string domain)

Translate the given text.

string

_zmn(string single, int number, string plural, mixed context, string domain)

Translate the given text with plural option.

string

_zmsprintf(string format, mixed mixed)

Helper function to parse translated strings for block replacements.

Function Detail

core\services\locale\_zm.php at line 63

_vzm

public void _vzm(string text, mixed ...)

Convenience version of _zm using a null context and the default domain.

This method will echo the localized text rather than return it.

Parameters:
text - The text.
... - Variable number of arguments to be used as arguments for vsprintf(..) to insert variables into the localized text.

core\services\locale\_zm.php at line 33

_zm

public string _zm(string text, mixed context, string domain)

Translate the given text.

Parameters:
text - The text to translate.
context - Optional translation context; default is null.
domain - The translation domain; default is ZMLocale::DEFAULT_DOMAIN.
Returns:
The translated text or, if no translation found, the original text.

core\services\locale\_zm.php at line 49

_zmn

public string _zmn(string single, int number, string plural, mixed context, string domain)

Translate the given text with plural option.

Parameters:
single - The text to translate for single case.
number - The number.
plural - The text to translate for plural case; default is null to default to the single case.
context - Optional translation context; default is null.
domain - The translation domain; default is ZMLocale::DEFAULT_DOMAIN.
Returns:
The translated text or, if no translation found, the original text.

core\services\locale\_zm.php at line 104

_zmsprintf

public string _zmsprintf(string format, mixed mixed)

Helper function to parse translated strings for block replacements.

Acts like sprintf but also supports block replacements.

Block replacements are useful, for example, if a single word in a string should be a link. Rather than splitting up the string into individual translatable strings it allows to keep the whole string as single translatable unit.

Example:
String to translate: Click <strong>here</strong> to open a new window..
The same with special block markers: Click <strong>%bhere%%</strong> to open a new window..

A block marker starts with %b or %nb, with n being a positonal integer; example: %2b. The block content end is marked by a double '%': %%.

Now, to update the word here from the example with a link (and link text being here), this code can be used:

_zmsprintf(_zm('Click <strong>%bhere%%</strong> to open a new window.'), '<a href="">%%block%%</a>');

The main point of this function is that the actual link text (here) is part of the full sentence to translate rather than a single word that gets concatenated. This helps to translate the link text in the context of the sentence rather than as a single word.

NOTE: This function in itself does not translate at all. As seen in the above example, _zm() needs to be used to pull the translatation first and use _zmsprintf() on that translated string.

Parameters:
format - The format string.
mixed - Variable numer parameter.
Returns:
The formatted string.

ZenMagick 0.9.10