Replaces gettext("message id") and _("message id") with the translated string.
Gettext is great for creating multi-lingual sites, but in some cases (e.g. for performance reasons) you may wish to replace the gettext calls with the translations of the strings; that's what this task is for. Note that this is similar to ReplaceTokens, but both the find and the replace aspect is more complicated -- hence this is a separate, stand-alone filter.
<
p>
Example:
author |
Hans Lellelid hans@xmpl.org |
---|---|
version |
$Id$ |
access |
public |
see | |
package |
phing.filters |
setDomain(string $domain)
The text domain must correspond to the name of the compiled .mo files. E.g. "messages" ==> $dir/LC_MESSAGES/messages.mo "mydomain" ==> $dir/LC_MESSAGES/mydomain.mo
string
getDomain() : string
string
setLocale(string $locale)
Note that for gettext() to work, you have to make sure this locale is specific enough for your system (e.g. some systems may allow an 'en' locale, but others will require 'en_US', etc.).
string
getLocale() : string
string
checkAttributes()
throws |
|
---|
initEnvironment() : void
This method will change some env vars and locale settings; the restoreEnvironment should put them all back :)
throws |
|
---|---|
see | \restoreEnvironment() |
restoreEnvironment() : void
This does not restore any gettext-specific settings (e.g. textdomain()).
xlateStringCallback(array $matches) : string
This function simply wraps gettext() call, but provides ability to log string replacements. (alternative would be using preg_replace with /e which would probably be faster, but no ability to debug/log.)
array
Array of matches; we're interested in $matches[2].
string
Translated text
read(int $len = null)
If length is specified, then only that number of chars is read, otherwise stream is read until EOF.
int
chain(\Reader $reader) : \TranslateGettext
\TranslateGettext
A new filter based on this configuration, but filtering the specified reader
_initialize()
setParameters($parameters)
getParameters()
getInitialized() : boolean
boolean
whether or not the filter is initialized
setInitialized(boolean $initialized)
boolean
Whether or not the filter is initialized.
setProject(object $project)
object
The project this filter is part of.
Should not be null
.
getProject() : object
object
The project this filter is part of
readLine() : \the
The returned String retains the '\n'.
throws |
if the underlying reader throws one during reading |
---|
\the
line read, or null
if the end of the
stream has already been reached
eof() : boolean
boolean
log(string $msg, int $level = \Project::MSG_INFO)
string
Message to log.
int
Priority level.
skip(int $n)
int
reset()
close()
throws |
if there is an error closing stream |
---|
getResource() : string
This is critical for, e.g., ExpatParser's ability to know the filename that is throwing an ExpatParserException, etc.
string
mark()
A subsequent call to reset() will move stream position back to last marker (if supported).
markSupported() : boolean
boolean
ready() : boolean
boolean
DOMAIN_KEY
DIR_KEY
LOCALE_KEY
domain :
dir :
locale :
storedLocale :
_parameters :
initialized :
project :