Create a gist now

Instantly share code, notes, and snippets.

Embed
What would you like to do?
convert gettext source file to json
#! /usr/bin/env php
<?php
$po = file_get_contents($argv[1]) or die('Failed to open input');
preg_match_all('/msgid "(.*)"/', $po, $keys);
preg_match_all('/msgstr "(.*)"/', $po, $strings);
$out = array_combine($keys[1], $strings[1]);
echo json_encode($out);
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment