MOBILE-3213 strings: Have a better CLI interface
parent
4727194f54
commit
9e9b4bcbbe
|
@ -58,6 +58,7 @@ function build_languages($languages, $keys, $added_langs = []) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_langindex_keys() {
|
function get_langindex_keys() {
|
||||||
|
$local = 0;
|
||||||
// Process the index file, just once.
|
// Process the index file, just once.
|
||||||
$keys = file_get_contents('langindex.json');
|
$keys = file_get_contents('langindex.json');
|
||||||
$keys = (array) json_decode($keys);
|
$keys = (array) json_decode($keys);
|
||||||
|
@ -67,6 +68,7 @@ function get_langindex_keys() {
|
||||||
if ($value == 'local_moodlemobileapp') {
|
if ($value == 'local_moodlemobileapp') {
|
||||||
$map->file = $value;
|
$map->file = $value;
|
||||||
$map->string = $key;
|
$map->string = $key;
|
||||||
|
$local++;
|
||||||
} else {
|
} else {
|
||||||
$exp = explode('/', $value, 2);
|
$exp = explode('/', $value, 2);
|
||||||
$map->file = $exp[0];
|
$map->file = $exp[0];
|
||||||
|
@ -87,7 +89,7 @@ function get_langindex_keys() {
|
||||||
}
|
}
|
||||||
|
|
||||||
$total = count($keys);
|
$total = count($keys);
|
||||||
echo "Total strings to translate $total\n";
|
echo "Total strings to translate $total ($local local)\n";
|
||||||
|
|
||||||
return $keys;
|
return $keys;
|
||||||
}
|
}
|
||||||
|
@ -248,7 +250,11 @@ function build_lang($lang, $keys) {
|
||||||
|
|
||||||
$success = count($translations);
|
$success = count($translations);
|
||||||
$percentage = floor($success/$total * 100);
|
$percentage = floor($success/$total * 100);
|
||||||
echo "\t\t$success of $total -> $percentage% ($local local)\n";
|
$bar = progressbar($percentage);
|
||||||
|
if (strlen($lang) <= 2 && !$parent) {
|
||||||
|
echo "\t";
|
||||||
|
}
|
||||||
|
echo "\t\t$success of $total -> $percentage% $bar ($local local)\n";
|
||||||
|
|
||||||
if ($lang == 'en') {
|
if ($lang == 'en') {
|
||||||
generate_local_moodlemobileapp($keys, $translations);
|
generate_local_moodlemobileapp($keys, $translations);
|
||||||
|
@ -258,6 +264,11 @@ function build_lang($lang, $keys) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function progressbar($percentage) {
|
||||||
|
$done = $percentage/10;
|
||||||
|
return "\t".str_repeat('=', $done) . str_repeat('-', 10-$done);
|
||||||
|
}
|
||||||
|
|
||||||
function detect_lang($lang, $keys) {
|
function detect_lang($lang, $keys) {
|
||||||
$langfoldername = get_langfolder($lang);
|
$langfoldername = get_langfolder($lang);
|
||||||
if (!$langfoldername) {
|
if (!$langfoldername) {
|
||||||
|
@ -275,12 +286,14 @@ function detect_lang($lang, $keys) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
echo "Checking $lang";
|
$title = $lang;
|
||||||
if ($parent != "" && $parent != $lang) {
|
if ($parent != "" && $parent != $lang) {
|
||||||
echo " ($parent)";
|
$title .= " ($parent)";
|
||||||
}
|
}
|
||||||
$langname = $string['thislanguage'];
|
$langname = $string['thislanguage'];
|
||||||
echo " ".$langname." -D";
|
$title .= " ".$langname." -D";
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Add the translation to the array.
|
// Add the translation to the array.
|
||||||
foreach ($keys as $key => $value) {
|
foreach ($keys as $key => $value) {
|
||||||
|
@ -304,7 +317,10 @@ function detect_lang($lang, $keys) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$percentage = floor($success/$total * 100);
|
$percentage = floor($success/$total * 100);
|
||||||
echo "\t\t$success of $total -> $percentage% ($local local)";
|
$bar = progressbar($percentage);
|
||||||
|
|
||||||
|
echo "Checking ".$title.str_repeat("\t", 7 - floor(mb_strlen($title, 'UTF-8')/8));
|
||||||
|
echo "\t$success of $total -> $percentage% $bar ($local local)";
|
||||||
if (($percentage > 75 && $local > 50) || ($percentage > 50 && $local > 75)) {
|
if (($percentage > 75 && $local > 50) || ($percentage > 50 && $local > 75)) {
|
||||||
echo " \t DETECTED\n";
|
echo " \t DETECTED\n";
|
||||||
return true;
|
return true;
|
||||||
|
|
Loading…
Reference in New Issue