Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $po = file_get_contents("locale/en_GB/LC_MESSAGES/messages.po");
- $translations = array(); // german => english
- preg_match_all('/msgid "(.+)"\nmsgstr "(.+)"/', $po, $matches, PREG_SET_ORDER);
- foreach ($matches as $match) {
- $match[1] = str_replace('\"','"',$match[1]);
- $match[2] = str_replace('\"','"',$match[2]);
- $translations['_(\''. $match[1] . '\''] = '_(\'' . $match[2] . '\'';
- $translations['_("'. $match[1] . '"'] = '_("' . $match[2] . '"';
- $translations['__(\''. $match[1] . '\''] = '__(\'' . $match[2] . '\'';
- $translations['__("'. $match[1] . '"'] = '__("' . $match[2] . '"';
- }
- $msgidhits = array();
- foreach (glob("*.php") as $file) {
- $code = file_get_contents($file);
- foreach($translations AS $msgid => $msgstr) {
- $hits = 0;
- $code = str_replace($msgid,$msgstr,$code,$hits);
- $msgid = str_replace('"',"'",$msgid);
- $msgid = str_replace('__(',"_(",$msgid);
- if(!isset($msgidhits[$msgid])) $msgidhits[$msgid] = $hits;
- else $msgidhits[$msgid] += $hits;
- }
- $code = str_replace(array_keys($translations), array_values($translations), $code);
- //file_put_contents($file, $code);
- echo $code; // be careful to test this first before doing the actual replace (and do use a version control system!)
- }
- print_r($msgidhits);
- echo "nulldrin?";
- print_r(array_keys($msgidhits, 0, true));
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement