diff options
| author | 2025-07-16 16:11:51 +0200 | |
|---|---|---|
| committer | 2025-07-16 16:11:51 +0200 | |
| commit | f9a42adadec9acd259c205727c95bd6f376dfbc5 (patch) | |
| tree | b576ba4ac948466389de30487c506ae04dd71d24 /cli/i18n | |
| parent | 5f61e426dc90b7b697a46da009af2fc88eed3ad0 (diff) | |
Show translation status in README.md (#7715)
* Show translation status in README.md
* Fix colon
* markdownlint: Allow tag `<translations>`
* Use mostly Unicode flags instead
* Only `oc.svg` remains in an image format
* `check.translation.php` still supports `.png` even though there aren't any PNGs as of right now
* Fix CodeSniffer
* Attempt approach with generating local SVGs
* Fixes for local SVG approach
* Cleanup old code
* PHPStan fix
* Remove decimal precision from percentages
* Suggestions + better error messages
* codesniffer fix v2
* Revert `ghSearchUrl` change
* Generate readme
* Fix syntax highlight, maybe
* Regenerate
* Update help message
* Use existing translation files instead of .txt
* Add test against wrong Unicode flag
---------
Co-authored-by: Alexandre Alapetite <alexandre@alapetite.fr>
Diffstat (limited to 'cli/i18n')
| -rw-r--r-- | cli/i18n/I18nCompletionValidator.php | 8 | ||||
| -rw-r--r-- | cli/i18n/I18nUsageValidator.php | 5 | ||||
| -rw-r--r-- | cli/i18n/I18nValidatorInterface.php | 2 |
3 files changed, 11 insertions, 4 deletions
diff --git a/cli/i18n/I18nCompletionValidator.php b/cli/i18n/I18nCompletionValidator.php index 28f8abed8..5cdd1ba80 100644 --- a/cli/i18n/I18nCompletionValidator.php +++ b/cli/i18n/I18nCompletionValidator.php @@ -20,14 +20,18 @@ class I18nCompletionValidator implements I18nValidatorInterface { } #[\Override] - public function displayReport(): string { + public function displayReport(bool $percentage_only = false): string { if ($this->passEntries > $this->totalEntries) { throw new \RuntimeException('The number of translated strings cannot be higher than the number of strings'); } if ($this->totalEntries === 0) { return 'There is no data.' . PHP_EOL; } - return sprintf('Translation is %5.1f%% complete.', $this->passEntries / $this->totalEntries * 100) . PHP_EOL; + $percentage = sprintf('%5.1f%%', $this->passEntries / $this->totalEntries * 100); + if ($percentage_only) { + return trim($percentage); + } + return 'Translation is ' . $percentage . ' complete.' . PHP_EOL; } #[\Override] diff --git a/cli/i18n/I18nUsageValidator.php b/cli/i18n/I18nUsageValidator.php index 89c88d222..5551d2df7 100644 --- a/cli/i18n/I18nUsageValidator.php +++ b/cli/i18n/I18nUsageValidator.php @@ -20,13 +20,16 @@ class I18nUsageValidator implements I18nValidatorInterface { } #[\Override] - public function displayReport(): string { + public function displayReport(bool $percentage_only = false): string { if ($this->failedEntries > $this->totalEntries) { throw new \RuntimeException('The number of unused strings cannot be higher than the number of strings'); } if ($this->totalEntries === 0) { return 'There is no data.' . PHP_EOL; } + if ($percentage_only) { + return '100%'; + } return sprintf('%5.1f%% of translation keys are unused.', $this->failedEntries / $this->totalEntries * 100) . PHP_EOL; } diff --git a/cli/i18n/I18nValidatorInterface.php b/cli/i18n/I18nValidatorInterface.php index 9266489f6..8c58f84cb 100644 --- a/cli/i18n/I18nValidatorInterface.php +++ b/cli/i18n/I18nValidatorInterface.php @@ -14,6 +14,6 @@ interface I18nValidatorInterface { /** * Display the validation report. */ - public function displayReport(): string; + public function displayReport(bool $percentage_only = false): string; } |
