2017-05-10 13 views
0

Gettext PHP Class을 사용하여 내 .po 파일을 내 웹 사이트로 관리합니다. 모든 traduction을 나열하려면 모든 "원래"키를 가져와야합니다. 나는 이것을 PHP 배열로 변형시킬 생각이 들지 않았습니다.PO 파일을 PHP로 PHP 배열로 변환

클래스의 내부 기능을 찾을 수 없기 때문에이를 수행 할 수있는 해킹을 찾았지만 매우 깨끗한 것은 아닙니다. : http://narasimhulu-mada.blogspot.fr/2011/07/quicktip-convert-po-files-to-php-php.html

다른 해결책이 있습니까?

+0

필자는 이것을 사용한 적이 없지만 [github] ($ https://github.com/oscarotero/Gettext/)'$ translations-> toPhpArrayFile ('locales/gl.php')를 보면 결코 그렇지 않습니다. 그게 네가 원하는거야? [toPhpArrayString] (https://github.com/oscarotero/Gettext/blob/master/src/Translations.php#L62)도 있습니다. –

답변

0

나는이 JSON 문자열에 수출하고 나를

$translations = Translations::fromPoFile($file); 
$content = $translations->toJsonString(); 
$decode = json_decode($content); 
$content = $decode->messages->_empty_; 
foreach($content as $key => $val) { 
echo $key.' = '.$val[0]; 
} 

나는이 방법을 사용하는 것이 쉬울 것입니다!