Skip to content
Snippets Groups Projects
Commit 3eea75f1 authored by Olav Morken's avatar Olav Morken
Browse files

bin/translate: Convert translation file.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2120 44740490-163a-0410-bde0-09ae8108e29a
parent dc0928a4
No related branches found
No related tags found
No related merge requests found
...@@ -60,8 +60,10 @@ switch($action) { ...@@ -60,8 +60,10 @@ switch($action) {
case 'convert': case 'convert':
include($file); include($file);
$encoded = json_format(convert($lang)); $definition = json_format(convert_definition($lang));
file_put_contents($fileWithoutExt . '.definition.json' , $encoded); $translation = json_format(convert_translation($lang)) . "\n";
file_put_contents($fileWithoutExt . '.definition.json' , $definition);
file_put_contents($fileWithoutExt . '.translation.json' , $translation);
break; break;
...@@ -74,7 +76,7 @@ function ssp_readline($prompt = '') { ...@@ -74,7 +76,7 @@ function ssp_readline($prompt = '') {
return rtrim( fgets( STDIN ), "\n" ); return rtrim( fgets( STDIN ), "\n" );
} }
function convert($data) { function convert_definition($data) {
$new = array(); $new = array();
foreach($data AS $key => $value) { foreach($data AS $key => $value) {
$new[$key] = array('en' => $value['en']); $new[$key] = array('en' => $value['en']);
...@@ -82,6 +84,13 @@ function convert($data) { ...@@ -82,6 +84,13 @@ function convert($data) {
return $new; return $new;
} }
function convert_translation($data) {
foreach ($data as &$value) {
unset($value['en']);
}
return $data;
}
function push($file, $fileWithoutExt, $aid) { function push($file, $fileWithoutExt, $aid) {
if (!file_exists($file)) throw new Exception('Could not find file: ' . $file); if (!file_exists($file)) throw new Exception('Could not find file: ' . $file);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment