Created
August 16, 2013 20:23
-
-
Save halfdan/6253228 to your computer and use it in GitHub Desktop.
Conversion script for Piwik translation array to JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$nest = true; | |
foreach (glob("lang/*.php") as $filename) { | |
echo sprintf("Converting %s\n", basename($filename)); | |
require_once "lang/".basename($filename); | |
$basename = explode(".", basename($filename)); | |
if($nest) { | |
$nested = array(); | |
foreach($translations as $key => $value) { | |
list($plugin, $nkey) = explode("_", $key, 2); | |
$nested[$plugin][$nkey] = $value; | |
} | |
$translations = $nested; | |
} | |
$data = json_encode($translations, JSON_UNESCAPED_UNICODE | JSON_PRETTY_PRINT); | |
$newFile = sprintf("lang/%s.json", $basename[0]); | |
file_put_contents($newFile, $data); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment