Skip to content

Commit 7193b25

Browse files
committed
output stats for website docs
1 parent 232fd2c commit 7193b25

File tree

1 file changed

+31
-7
lines changed

1 file changed

+31
-7
lines changed

src/Commands/NovaLangStats.php

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -159,9 +159,9 @@ public function handle()
159159
$this->filesystem->put($outputFile, json_encode($contributors->merge($missing), JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE));
160160

161161
$this->info(sprintf('Updated "contributors.json" has been output to [%s].', $outputFile));
162-
$this->warn('* Replace contributors.json in your fork of the repository with this file.');
162+
$this->warn('* Replace ./contributors.json in your fork of the repository with this file.');
163163

164-
$contributors->transform(function($localeStat, $locale) use ($sourceCount) {
164+
$contributorsTable = $contributors->map(function($localeStat, $locale) use ($sourceCount) {
165165

166166
$percent = $this->getPercent($localeStat['complete'], $sourceCount);
167167
$icon = $this->getPercentIcon($localeStat['complete'], $percent);
@@ -204,17 +204,17 @@ public function handle()
204204
'| Code | Language | Translated files | Lines translated | Thanks to |'.PHP_EOL.
205205
'| --- | --- | --- | --- | --- |';
206206

207-
$contents = $header.PHP_EOL.$contributors->join(PHP_EOL);
207+
$contents = $header.PHP_EOL.$contributorsTable->join(PHP_EOL);
208208

209209
if ($missing->count()) {
210210

211211
$parityCount = $caouecsLocales->intersect($availableLocales)->count();
212212
$caouecsCount = $caouecsLocales->count();
213213

214-
$percent = $this->getPercent($parityCount, $caouecsCount);
215-
$icon = $this->getPercentIcon($parityCount.'%2F'.$caouecsCount, $percent);
214+
$missingPercent = $this->getPercent($parityCount, $caouecsCount);
215+
$icon = $this->getPercentIcon($parityCount.'%2F'.$caouecsCount, $missingPercent);
216216

217-
$totals = sprintf('Parity with `caouecs/laravel-lang` ![%d/%d (%s%%)](%s)', $parityCount, $caouecsCount, $percent, $icon);
217+
$totals = sprintf('Parity with `caouecs/laravel-lang` ![%d/%d (%s%%)](%s)', $parityCount, $caouecsCount, $missingPercent, $icon);
218218

219219
$header = '## Missing Languages'.PHP_EOL.PHP_EOL.
220220
'The following languages are supported for the main Laravel framework by the excellent [caouecs/laravel-lang](https://github.com/caouecs/Laravel-lang) package. We would love for our package to make these languages available for Nova as well. If you are able to contribute to any of these or other languages, please read our [contributing guidelines](CONTRIBUTING.md) and raise a PR.'.PHP_EOL.PHP_EOL.
@@ -228,7 +228,31 @@ public function handle()
228228
$this->filesystem->put($outputFile, $contents);
229229

230230
$this->info(sprintf('Updated "README.excerpt.md" has been output to [%s].', $outputFile));
231-
$this->warn('* Replace the Available Languages table in README.md in your fork of the repository with the contents of this file.');
231+
$this->warn('* Replace the Available Languages table in ./README.md in your fork of the repository with the contents of this file.');
232+
233+
$outputFile = $outputDirectory . '/introduction.excerpt.md';
234+
235+
$contributorsList = $contributors->map(function ($localeStat, $locale) use ($sourceCount) {
236+
237+
$percent = $this->getPercent($localeStat['complete'], $sourceCount);
238+
239+
return sprintf('* `%s` %s · **%d (%s%%)**', str_replace('-', '', $locale), $localeStat['name'], $localeStat['complete'], $percent);
240+
});
241+
242+
$totals = sprintf('Total languages **%s** ', $languagesCount) . PHP_EOL .
243+
sprintf('Total lines translated **%d (%s%%)**', $sourceComplete, $percent);
244+
245+
$header = '### Available Languages' . PHP_EOL . PHP_EOL .
246+
$totals . PHP_EOL;
247+
248+
$contents = $header . PHP_EOL . $contributorsList->join(PHP_EOL);
249+
250+
$contents .= PHP_EOL . PHP_EOL . 'See the full list of contributors on [GitHub](https://github.com/coderello/laravel-nova-lang#available-languages).';
251+
252+
$this->filesystem->put($outputFile, $contents);
253+
254+
$this->info(sprintf('Updated "introduction.excerpt.md" has been output to [%s].', $outputFile));
255+
$this->warn('* Replace the Available Languages list in ./docs/introduction.md in your fork of the repository with the contents of this file.');
232256
}
233257

234258
protected function getPercent(int $complete, int $total): float

0 commit comments

Comments
 (0)