4

I am trying to use po2php to convert my .po file to Zend php translations array.

I am simply trying this: $ po2php translations.po translations.php, but this results in an error that I do not understand: po2php: warning: Couldn't handle input file translations.po: don't know what to do with input format .po, no template file.

I do not know what a template file is an why should I provide it?

UPDATE: I also tried $ po2php translations.po translations.php -t messages.pot, but this does not help me, it shows pretty much the same error: po2php: warning: Couldn't handle input file translations.po: don't know what to do with input format .po, template format .pot.

ragulka
  • 4,312
  • 7
  • 48
  • 73

1 Answers1

0

You could also try out the pear package File_Gettext. Read more here: https://github.com/pear/File_Gettext

The code would look like this (Not tested):

include_once 'File/Gettext/PO.php';

$poFile = new File_Gettext_PO();
$poFile->load('PATH_TO/translations.po');

print_r($poFile->strings);

$poFile->strings should contain the content of the po file as associative array. Next you need a function to output this array in a file. Take a look at the second answer here: Print array to a file

Community
  • 1
  • 1
bitWorking
  • 12,485
  • 1
  • 32
  • 38