Skip to content

Commit

Permalink
Added script to format crowdin top member report
Browse files Browse the repository at this point in the history
Formats to JSON. Used to create the attribution details
to be included in the blogposts.
  • Loading branch information
ssddanbrown committed Sep 20, 2020
1 parent 33ff86a commit e00e611
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions meta-scripts/bookstack-format-crowdin-members-report
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
#!/usr/bin/env php
<?php

function error($text) {
echo $text . "\n";
exit(1);
}

function output($text) {
echo $text . "\n";
}


// Check a file path is provided
if (count($argv) < 2) {
error("Path to JSON report required");
}

// Check file path exists
$reportFile = realpath($argv[1]);
if (!file_exists($reportFile)) {
error("JSON report file not found at {$reportFile}");
}

$reportContent = file_get_contents($reportFile);
$report = json_decode($reportContent, true);
if (is_null($report)) {
error("Could not read JSON content from file {$reportFile}");
}

foreach ($report['data'] as $userData) {
$fullName = $userData['user']['fullName'];
$languages = array_map(function($lang) {
return '*' . $lang['name'] . '*';
}, $userData['languages']);

if (count($languages) === 0) {
continue;
}

$langString = implode(", ", $languages);
output("* {$fullName} - {$langString}");
}

0 comments on commit e00e611

Please sign in to comment.