| 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. |
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.
vsprintf(..) to insert variables into the localized text.public string _zm(string text, mixed context, string domain)
Translate the given text.
null.ZMLocale::DEFAULT_DOMAIN.public string _zmn(string single, int number, string plural, mixed context, string domain)
Translate the given text with plural option.
null to default to the single case.null.ZMLocale::DEFAULT_DOMAIN.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.