0

I use the Gettext PHP Class to manage my .po file into my website. I need to get all the "original" key to list all traduction. I didn't manage to do this so i thought to transform it into a PHP Array.

I don't find any internal function of the class to do this so i found a hack to do this but it's not very clean. : http://narasimhulu-mada.blogspot.fr/2011/07/quicktip-convert-po-files-to-php-php.html

Is there any other solution ?

Vadim Kotov
  • 8,084
  • 8
  • 48
  • 62
  • I've never used this but looking at the [github](https://github.com/oscarotero/Gettext/) `$translations->toPhpArrayFile('locales/gl.php');` isn't that what you want? There is also [toPhpArrayString](https://github.com/oscarotero/Gettext/blob/master/src/Translations.php#L62) – Jenne May 10 '17 at 12:51

1 Answers1

0

I export it in a JSON String and that's seem to be easy for me

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

I prefer to use this method !