Created
September 19, 2014 11:36
-
-
Save pascalchevrel/9933685399402b6682c9 to your computer and use it in GitHub Desktop.
Extract json files from the l10n API and generate text files for Transvision use
This file contains 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 | |
// Script should not be called from the Web | |
if (php_sapi_name() != 'cli') { | |
die('Nope'); | |
} | |
$settings = parse_ini_file(__DIR__ . '/../config/config.ini'); | |
if(! isset($settings['l10nwebservice'])) { | |
error_log('L10n Web service variable in config.ini is not defined'); | |
exit(1); | |
} | |
if (! $json = json_decode(file_get_contents($settings['l10nwebservice']), true)) { | |
error_log('Json source is not reachable or valid.'); | |
exit(1); | |
} | |
foreach ($json as $key => $repository) { | |
file_put_contents( | |
$settings['config'] . '/' . $repository['id'] . '.txt', | |
implode("\n", $repository['locales']) . "\n" | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment