[ Index ]
 

Code source de Symfony 1.0.0

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/lib/vendor/phing/filters/ -> TranslateGettext.php (sommaire)

(pas de description)

Poids: 285 lignes (10 kb)
Inclus ou requis:0 fois
Référencé: 0 fois
Nécessite: 0 fichiers

Définit 1 class

TranslateGettext:: (13 méthodes):
  setDomain()
  getDomain()
  setDir()
  getDir()
  setLocale()
  getLocale()
  checkAttributes()
  initEnvironment()
  restoreEnvironment()
  xlateStringCallback()
  read()
  chain()
  _initialize()


Classe: TranslateGettext  - X-Ref

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:<br>
<pre>
<translategettext locale="en_US" domain="messages" dir="${webroot}/local"/>
</pre>

setDomain($domain)   X-Ref
Set the text domain to use.
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

param: string $domain

getDomain()   X-Ref
Get the current domain.

return: string

setDir(PhingFile $dir)   X-Ref
Sets the root locale directory.

param: PhingFile $dir

getDir()   X-Ref
Gets the root locale directory.

return: PhingFile

setLocale($locale)   X-Ref
Sets the locale to use for translation.
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.).

param: string $locale

getLocale()   X-Ref
Gets the locale to use for translation.

return: string

checkAttributes()   X-Ref
Make sure that required attributes are set.


initEnvironment()   X-Ref
Initialize the gettext/locale environment.
This method will change some env vars and locale settings; the
restoreEnvironment should put them all back :)

return: void

restoreEnvironment()   X-Ref
Restores environment settings and locale.
This does _not_ restore any gettext-specific settings
(e.g. textdomain()).

return: void

xlateStringCallback($matches)   X-Ref
Performs gettext translation of msgid and returns translated text.

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.)

param: array $matches Array of matches; we're interested in $matches[2].
return: string Translated text

read($len = null)   X-Ref
Returns the filtered stream.
The original stream is first read in fully, and then translation is performed.

return: mixed     the filtered stream, or -1 if the end of the resulting stream has been reached.

chain(Reader $reader)   X-Ref
Creates a new TranslateGettext filter using the passed in
Reader for instantiation.

param: Reader $reader A Reader object providing the underlying stream.
return: TranslateGettext A new filter based on this configuration, but filtering

_initialize()   X-Ref
Parses the parameters if this filter is being used in "generic" mode.




Généré le : Fri Mar 16 22:42:14 2007 par Balluche grâce à PHPXref 0.7