난 당신이 파일을 .mo 귀하와 .po 파일을 컴파일 할 필요가 있다고 생각 :
/**
* This method overides the original load method. Its duty is loading the domain files by config or by default internal settings.
*
*/
function load_gettext($userlang = false) {
/* I want the super object */
if ($userlang)
$this->gettext_language = $userlang;
else
$this->gettext_language = 'it_IT';
log_message('debug', 'Gettext Class gettext_language was set by parameter:' . $this->gettext_language);
putenv("LANG=$this->gettext_language");
setlocale(LC_ALL, $this->gettext_language);
/* Let's set the path of .po files */
$this->gettext_path = APPPATH . 'language/locale';
log_message('debug', 'Gettext Class path chosen is: ' . $this->gettext_path);
bindtextdomain($this->gettext_domain, $this->gettext_path);
textdomain($this->gettext_domain);
log_message('debug', 'Gettext Class the domain chosen is: ' . $this->gettext_domain);
return true;
}
/**
* Plural forms added by Tchinkatchuk
* http://www.codeigniter.com/forums/viewthread/2168/
*/
/**
* The translator method
*
* @param string $original the original string to translate
* @param array $aParams the plural parameters
* @return the string translated
*/
function _trans($original, $aParams = false) {
if (isset($aParams['plural']) && isset($aParams['count'])) {
$sTranslate = ngettext($original, $aParams['plural'], $aParams['count']);
$sTranslate = $this->replaceDynamically($sTranslate, $aParams);
} else {
$sTranslate = gettext($original);
if (is_array($aParams) && count($aParams))
$sTranslate = $this->replaceDynamically($sTranslate, $aParams);
}
return $sTranslate;
}
이것은 컨트롤러의 사용은 다음과 같습니다
여기 라이브러리 코드입니다. Gettext는 .mo 파일을 사용하고 .po는 사람이 읽을 수있는 형식입니다. http://wiki.creativecommons.org/Translating_PO_Files
도움이 될 희망이 http://bit.ly/rrITVx
가 다시 시작 되세요 멋지 & 코드 점화와 PHP-gettext를 통합하기 위해 도우미를 썼다 아파치 (당신이 사용하고있는 웹 서버라고 가정)? – salathe