Skip to content

Instantly share code, notes, and snippets.

@Jiwoks
Created June 10, 2013 12:26
Show Gist options
  • Select an option

  • Save Jiwoks/5748358 to your computer and use it in GitHub Desktop.

Select an option

Save Jiwoks/5748358 to your computer and use it in GitHub Desktop.
This gist takes a Joomla language file and export as a po language file
<?php
/**
* Php cli script
* @param string file to convert
* @param string file to save
**/
if(empty($argv[1])){
die('You have to pass as first argument the file to parse');
}
if(!empty($argv[2])){
$filesource = $argv[2];
}else{
$filesource = 'translated.po';
}
$translations = parse_ini_file($argv[1]);
$file = fopen($filesource, 'w+');
foreach ($translations as $key => $value) {
fwrite($file, "msgid \"$key\" \r\n");
fwrite($file, "msgstr \"$value\" \r\n");
fwrite($file, "\r\n");
}
fclose($file);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment