Skip to content

Commit

Permalink
docs(readme): Use HTML syntax for locale table (#386)
Browse files Browse the repository at this point in the history
  • Loading branch information
DenverCoder1 authored Dec 23, 2022
1 parent f2ef022 commit 053bec1
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
12 changes: 6 additions & 6 deletions composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 13 additions & 6 deletions scripts/translation-progress.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,28 @@ function getLineNumber(array $translations_file, string $locale): int
function progressToBadges(array $progress): string
{
$per_row = 5;
$badges = str_repeat("| ", $per_row) . "|" . "\n";
$badges .= str_repeat("| --- ", $per_row) . "|" . "\n";
$table = "<table><tbody>";
$i = 0;
foreach (array_values($progress) as $data) {
if ($i % $per_row === 0) {
$table .= "<tr>";
}
$line_url = "https://github.com/DenverCoder1/github-readme-streak-stats/blob/main/src/translations.php#L{$data["line_number"]}";
$badges .= "| [`{$data["locale"]}`]({$line_url}) - {$data["locale_name"]} <br /> [![{$data["locale_name"]} {$data["percentage"]}%](https://progress-bar.dev/{$data["percentage"]})]({$line_url}) ";
$table .= "<td><a href=\"{$line_url}\"><code>{$data["locale"]}</code></a> - {$data["locale_name"]}<br /><a href=\"{$line_url}\"><img src=\"https://progress-bar.dev/{$data["percentage"]}\" alt=\"{$data["locale_name"]} {$data["percentage"]}%\"></a></td>";
$i++;
if ($i % $per_row === 0) {
$badges .= "|\n";
$table .= "</tr>";
}
}
if ($i % $per_row !== 0) {
$badges .= "|\n";
while ($i % $per_row !== 0) {
$table .= "<td></td>";
$i++;
}
$table .= "</tr>";
}
return $badges;
$table .= "</tbody></table>\n";
return $table;
}

/**
Expand Down

0 comments on commit 053bec1

Please sign in to comment.