Skip to content

Instantly share code, notes, and snippets.

@pascalchevrel
Created September 19, 2014 11:36
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pascalchevrel/9933685399402b6682c9 to your computer and use it in GitHub Desktop.
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
<?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