Skip to content

Instantly share code, notes, and snippets.

@kraih
Last active October 26, 2016 11:29
Show Gist options
  • Save kraih/20cc3ba02d7c138a3ca5cf4f99348da2 to your computer and use it in GitHub Desktop.
Save kraih/20cc3ba02d7c138a3ca5cf4f99348da2 to your computer and use it in GitHub Desktop.
#!/usr/bin/perl
use 5.24.0;
use Mojo::UserAgent;
use IO::Socket::SSL;
my %LANGUAGES = (
# SLE main languages
'Arabic' => 'ar',
'Brazilian Portugese' => 'pt_BR',
'Chinese Simplified' => 'zh_CN',
'Chinese Traditional' => 'zh_TW',
'Czech' => 'cs',
'Dutch' => 'nl',
'French' => 'fr',
'German' => 'de',
'Hungarian' => 'hu',
'Italian' => 'it',
'Japanese' => 'ja',
'Korean' => 'ko',
'Polish' => 'pl',
'Russian' => 'ru',
'Spanish' => 'es',
'Swedish' => 'sv',
# Strong openSUSE languages
'Catalan' => 'ca',
'Greek' => 'el',
'Slovak' => 'sk',
'Ukrainian' => 'uk',
'Lithuanian' => 'lt',
'Finnish' => 'fi',
'Slovenian' => 'sl',
'Estonian' => 'et',
'Bosnian' => 'bs'
);
my %PROJECTS = (
'Infrastructure and Installation' => {
'download-o-o' => 'Download Page',
'landing-page' => 'Web Site',
'searchpage' => 'Search Page',
'release-notes-openSUSE' => 'Release Notes',
'skelcd-openSUSE' => 'License',
'yast-slide-show' => 'Slide Show'
},
'Software' =>
{'libzypp' => 'libzypp', 'zypper' => 'zypper', 'snapper' => 'snapper'},
'YaST (1)' => {
'yast-base' => 'base',
'yast-country' => 'country',
'yast-firewall' => 'firewall',
'yast-installation' => 'installation',
'yast-ncurses' => 'ncurses',
'yast-ncurses-pkg' => 'ncurses-pkg',
'yast-network' => 'network',
'yast-pam' => 'pam',
'yast-pkg-bindings' => 'pkg-bindings',
'yast-qt' => 'qt',
'yast-qt-pkg' => 'qt-pkg',
'yast-timezone_db' => 'timezone_db',
'yast-storage' => 'storage'
},
'YaST (2)' => {
'yast-control-center' => 'control-center',
'yast-oneclickinstall' => 'oneclickinstall',
'yast-online-update' => 'online-update',
'yast-online-update-configuration' => 'online-update-configuration',
'yast-ldap' => 'ldap',
'yast-mail' => 'mail',
'yast-packager' => 'packager',
'yast-security' => 'security',
'yast-services-manager' => 'services-manager',
'yast-snapper' => 'snapper',
'yast-storage' => 'storage',
'yast-update' => 'update',
'yast-users' => 'users',
'yast-sysconfig' => 'sysconfig'
}
);
my $ua = Mojo::UserAgent->new;
my ($translation_percent, $translation_size) = (0, 0);
for my $category (sort keys %PROJECTS) {
my ($category_percent, $category_size) = (0, 0);
for my $project (sort keys $PROJECTS{$category}->%*) {
my ($project_percent, $project_size) = (0, 0);
my $description = $PROJECTS{$category}{$project};
for my $lang (sort keys %LANGUAGES) {
my $code = $LANGUAGES{$lang};
my $url
= "https://l10n.opensuse.org/api/translations/$project/master/$code/";
my $tx = $ua->get($url => {Accept => 'application/json'});
say 'No JSON!' and next unless my $json = $tx->res->json;
my $percent = $json->{translated_percent} // 0;
say " [$code] $project: $percent%";
$translation_percent += $percent;
$translation_size += 1;
$category_percent += $percent;
$category_size += 1;
$project_percent += $percent;
$project_size += 1;
}
say " $project: @{[$project_percent / $project_size]}%";
}
say " $category: @{[$category_percent / $category_size]}%";
}
say "Overall: @{[$translation_percent / $translation_size]}%";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment