PHP 클래스 TranslateGettext, symfony-1.4

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.

Example:


또한 보기: BaseFilterReader
저자: Hans Lellelid ([email protected])
상속: extends BaseParamFilterReader, implements ChainableReader
파일 보기 프로젝트 열기: vjousse/symfony-1.4 1 사용 예제들

공개 메소드들

메소드 설명
chain ( Reader $reader ) : TranslateGettext Creates a new TranslateGettext filter using the passed in Reader for instantiation.
getDir ( ) : PhingFile Gets the root locale directory.
getDomain ( ) : string Get the current domain.
getLocale ( ) : string Gets the locale to use for translation.
read ( $len = null ) : mixed Returns the filtered stream.
setDir ( PhingFile $dir ) Sets the root locale directory.
setDomain ( string $domain ) Set the text domain to use.
setLocale ( string $locale ) Sets the locale to use for translation.

보호된 메소드들

메소드 설명
checkAttributes ( ) Make sure that required attributes are set.
initEnvironment ( ) : void Initialize the gettext/locale environment.
restoreEnvironment ( ) : void Restores environment settings and locale.

비공개 메소드들

메소드 설명
_initialize ( ) Parses the parameters if this filter is being used in "generic" mode.
xlateStringCallback ( array $matches ) : string Performs gettext translation of msgid and returns translated text.

메소드 상세

chain() 공개 메소드

Creates a new TranslateGettext filter using the passed in Reader for instantiation.
public chain ( Reader $reader ) : TranslateGettext
$reader Reader A Reader object providing the underlying stream. Must not be null.
리턴 TranslateGettext A new filter based on this configuration, but filtering the specified reader

checkAttributes() 보호된 메소드

Make sure that required attributes are set.
protected checkAttributes ( )

getDir() 공개 메소드

Gets the root locale directory.
public getDir ( ) : PhingFile
리턴 PhingFile

getDomain() 공개 메소드

Get the current domain.
public getDomain ( ) : string
리턴 string

getLocale() 공개 메소드

Gets the locale to use for translation.
public getLocale ( ) : string
리턴 string

initEnvironment() 보호된 메소드

This method will change some env vars and locale settings; the restoreEnvironment should put them all back :)
또한 보기: restoreEnvironment()
protected initEnvironment ( ) : void
리턴 void

read() 공개 메소드

The original stream is first read in fully, and then translation is performed.
public read ( $len = null ) : mixed
리턴 mixed the filtered stream, or -1 if the end of the resulting stream has been reached.

restoreEnvironment() 보호된 메소드

This does _not_ restore any gettext-specific settings (e.g. textdomain()).
protected restoreEnvironment ( ) : void
리턴 void

setDir() 공개 메소드

Sets the root locale directory.
public setDir ( PhingFile $dir )
$dir PhingFile

setDomain() 공개 메소드

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
public setDomain ( string $domain )
$domain string

setLocale() 공개 메소드

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.).
public setLocale ( string $locale )
$locale string