mirror of
https://github.com/maxpozdeev/mytinytodo.git
synced 2026-03-11 08:55:27 +00:00
Added info about percent of translations completion
This commit is contained in:
parent
510d04c48f
commit
5cbe0d93a7
3 changed files with 147 additions and 0 deletions
|
|
@ -43,6 +43,7 @@ print "> Version is $ver\n";
|
|||
|
||||
unlink('./docker-config.php');
|
||||
unlink('./includes/lang/en-rtl.json');
|
||||
unlink('./includes/lang/_percent.php');
|
||||
unlink('./mtt-edit-settings.php');
|
||||
unlink('./content/theme/images/svg2base64.php');
|
||||
|
||||
|
|
|
|||
107
src/includes/lang/_percent.php
Executable file
107
src/includes/lang/_percent.php
Executable file
|
|
@ -0,0 +1,107 @@
|
|||
#!/usr/bin/env php
|
||||
<?php
|
||||
|
||||
if (php_sapi_name() != 'cli') {
|
||||
die("Command-line only!\n");
|
||||
}
|
||||
|
||||
$only = [];
|
||||
while ($arg = next($argv))
|
||||
{
|
||||
if ($arg == '-v') {
|
||||
define("P_VERBOSE", 1);
|
||||
}
|
||||
else if ($arg[0] == '-') {
|
||||
die("Unexpected argument: $arg\n");
|
||||
}
|
||||
else {
|
||||
$only[] = $arg;
|
||||
}
|
||||
}
|
||||
|
||||
if (!file_exists("en.json")) {
|
||||
die("File not found: en.json\n");
|
||||
}
|
||||
$src = json_decode(file_get_contents("en.json"), true) ?? [];
|
||||
unset($src['_header']);
|
||||
|
||||
|
||||
$totalKeys = checkArray("en.json", $src, $src); //hack
|
||||
$langs = [];
|
||||
$files = array_diff(scandir('.') ?? [], ['.', '..', 'en-rtl.json']);
|
||||
foreach ($files as $file) {
|
||||
if (!preg_match("/(.+)\.json$/", $file, $m)) {
|
||||
continue; // Skip non-json files
|
||||
}
|
||||
if (count($only) && !in_array($file, $only)) {
|
||||
continue;
|
||||
}
|
||||
$translated = checkLang($src, $file);
|
||||
$langs[$m[1]] = $translated;
|
||||
}
|
||||
ksort($langs);
|
||||
|
||||
$rows = [];
|
||||
$rows[] = ["Locale", "Lines", "% Done"];
|
||||
foreach ($langs as $lang => $translated) {
|
||||
$rows[] = [$lang, "$translated/$totalKeys", round(100 * $translated/$totalKeys)."%"];
|
||||
}
|
||||
|
||||
#calc column width
|
||||
$width = [0,0,0];
|
||||
foreach ($rows as $row) {
|
||||
$width[0] = max($width[0], strlen($row[0]));
|
||||
$width[1] = max($width[1], strlen($row[1]));
|
||||
$width[2] = max($width[2], strlen($row[2]));
|
||||
}
|
||||
|
||||
# print table
|
||||
print "# myTinyTodo Translations\n\n";
|
||||
foreach ($rows as $i => $row) {
|
||||
if ($i == 0) {
|
||||
print("| ". str_pad($row[0], $width[0], " ", STR_PAD_BOTH). " | ".
|
||||
str_pad($row[1], $width[1], " ", STR_PAD_BOTH). " | ".
|
||||
str_pad($row[2], $width[2], " ", STR_PAD_BOTH). " |\n");
|
||||
print("|:". str_repeat("-", $width[0]+1). "|". str_repeat("-", $width[1]+1). ":|". str_repeat("-", $width[2]+1). ":|\n");
|
||||
}
|
||||
else {
|
||||
print("| ". str_pad($row[0], $width[0], " ", STR_PAD_RIGHT). " | ".
|
||||
str_pad($row[1], $width[1], " ", STR_PAD_LEFT). " | ".
|
||||
str_pad($row[2], $width[2], " ", STR_PAD_LEFT). " |\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
function checkLang(array $src, string $file) : int
|
||||
{
|
||||
$lang = json_decode(file_get_contents($file), true) ?? [];
|
||||
unset($lang['_header']);
|
||||
$translated = checkArray($file, $src, $lang);
|
||||
return $translated;
|
||||
}
|
||||
|
||||
function checkArray(string $file, array $src, ?array $a) : int
|
||||
{
|
||||
$translated = 0;
|
||||
foreach ($src as $k => $v) {
|
||||
if (!isset($a[$k])) {
|
||||
if (defined('P_VERBOSE')) {
|
||||
fwrite(STDERR, "$file: key `$k` is not defined\n");
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if (!is_array($v)) {
|
||||
++$translated;
|
||||
}
|
||||
else if (is_array($a[$k])) {
|
||||
++$translated;
|
||||
$translated += checkArray($file, $v, $a[$k]);
|
||||
}
|
||||
}
|
||||
return $translated;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
39
src/includes/lang/readme.md
Normal file
39
src/includes/lang/readme.md
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
# myTinyTodo Translations
|
||||
|
||||
| Locale | Lines | % Done |
|
||||
|:-------|--------:|-------:|
|
||||
| ar | 147/199 | 74% |
|
||||
| bg | 147/199 | 74% |
|
||||
| ca | 147/199 | 74% |
|
||||
| cz | 147/199 | 74% |
|
||||
| da | 147/199 | 74% |
|
||||
| de | 198/199 | 99% |
|
||||
| el | 147/199 | 74% |
|
||||
| en | 199/199 | 100% |
|
||||
| es | 147/199 | 74% |
|
||||
| es-mx | 147/199 | 74% |
|
||||
| fa | 187/199 | 94% |
|
||||
| fr | 195/199 | 98% |
|
||||
| he | 147/199 | 74% |
|
||||
| hu | 147/199 | 74% |
|
||||
| it | 147/199 | 74% |
|
||||
| ja | 147/199 | 74% |
|
||||
| lt | 147/199 | 74% |
|
||||
| mk | 147/199 | 74% |
|
||||
| nl | 187/199 | 94% |
|
||||
| no | 147/199 | 74% |
|
||||
| pl | 175/199 | 88% |
|
||||
| pt-br | 187/199 | 94% |
|
||||
| pt-pt | 147/199 | 74% |
|
||||
| ro | 147/199 | 74% |
|
||||
| ru | 199/199 | 100% |
|
||||
| sk | 147/199 | 74% |
|
||||
| sl | 147/199 | 74% |
|
||||
| sr | 147/199 | 74% |
|
||||
| sv | 147/199 | 74% |
|
||||
| th | 147/199 | 74% |
|
||||
| tr | 147/199 | 74% |
|
||||
| uk | 147/199 | 74% |
|
||||
| vi | 147/199 | 74% |
|
||||
| zh-cn | 196/199 | 98% |
|
||||
| zh-tw | 147/199 | 74% |
|
||||
Loading…
Reference in a new issue