| 1 |
#! /usr/bin/perl -w |
| 2 |
############################################################################# |
| 3 |
## |
| 4 |
## Copyright (C) 2017 The Qt Company Ltd. |
| 5 |
## Contact: https://www.qt.io/licensing/ |
| 6 |
## |
| 7 |
## This file is part of the translations module of the Qt Toolkit. |
| 8 |
## |
| 9 |
## $QT_BEGIN_LICENSE:GPL-EXCEPT$ |
| 10 |
## Commercial License Usage |
| 11 |
## Licensees holding valid commercial Qt licenses may use this file in |
| 12 |
## accordance with the commercial license agreement provided with the |
| 13 |
## Software or, alternatively, in accordance with the terms contained in |
| 14 |
## a written agreement between you and The Qt Company. For licensing terms |
| 15 |
## and conditions see https://www.qt.io/terms-conditions. For further |
| 16 |
## information use the contact form at https://www.qt.io/contact-us. |
| 17 |
## |
| 18 |
## GNU General Public License Usage |
| 19 |
## Alternatively, this file may be used under the terms of the GNU |
| 20 |
## General Public License version 3 as published by the Free Software |
| 21 |
## Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT |
| 22 |
## included in the packaging of this file. Please review the following |
| 23 |
## information to ensure the GNU General Public License requirements will |
| 24 |
## be met: https://www.gnu.org/licenses/gpl-3.0.html. |
| 25 |
## |
| 26 |
## $QT_END_LICENSE$ |
| 27 |
## |
| 28 |
############################################################################# |
| 29 |
|
| 30 |
|
| 31 |
use strict; |
| 32 |
|
| 33 |
my @groups = ( |
| 34 |
"qtbase", "qtdeclarative", "qtxmlpatterns", "qtmultimedia", "qtscript", |
| 35 |
"qtquickcontrols", "qtquickcontrols2", |
| 36 |
"qtlocation", "qtconnectivity", "qtwebsockets", "qtserialport", "qtwebengine", |
| 37 |
# "qtdocgallery", "qtpim", "qtsystems", |
| 38 |
"assistant", "designer", "linguist", "qt_help" |
| 39 |
); |
| 40 |
|
| 41 |
my %scores = (); |
| 42 |
my %langs = (); |
| 43 |
|
| 44 |
my $files = join("\n", <*_??.ts>); |
| 45 |
my $res = `xmlpatterns -param files=\"$files\" check-ts.xq`; |
| 46 |
for my $i (split(/ /, $res)) { |
| 47 |
$i =~ /^([^.]+)\.ts:(.*)$/; |
| 48 |
my ($fn, $pc) = ($1, $2); |
| 49 |
for my $g (@groups) { |
| 50 |
if ($fn =~ /^${g}_((.._)?..)$/) { |
| 51 |
my $lang = $1; |
| 52 |
$scores{$g}{$lang} = $pc; |
| 53 |
$langs{$lang} = 1; |
| 54 |
last; |
| 55 |
} |
| 56 |
} |
| 57 |
} |
| 58 |
|
| 59 |
my $code = ""; |
| 60 |
|
| 61 |
print "L10n "; |
| 62 |
for my $g (@groups) { |
| 63 |
print " ".$g." "; |
| 64 |
} |
| 65 |
print "\n"; |
| 66 |
for my $lang (sort(keys(%langs))) { |
| 67 |
printf "%-5s ", $lang; |
| 68 |
my $qt = 1; |
| 69 |
my $rest = 1; |
| 70 |
my $line = ""; |
| 71 |
for my $g (@groups) { |
| 72 |
my $pc = $scores{$g}{$lang}; |
| 73 |
$pc = "0" if !defined($pc); |
| 74 |
if (int($pc) < 98 or !$qt) { |
| 75 |
if ($g eq "qt") { |
| 76 |
$qt = 0; |
| 77 |
} else { |
| 78 |
$rest = 0; |
| 79 |
} |
| 80 |
} else { |
| 81 |
$line .= " ".$g."_".$lang.".ts"; |
| 82 |
} |
| 83 |
printf " %-".(length($g)+1)."s", $pc; |
| 84 |
} |
| 85 |
if ($qt) { |
| 86 |
$code .= " \\\n ".$line; |
| 87 |
if (!$rest) { |
| 88 |
print " (partial)"; |
| 89 |
} |
| 90 |
} else { |
| 91 |
print " (excluded)"; |
| 92 |
} |
| 93 |
print "\n"; |
| 94 |
} |
| 95 |
|
| 96 |
my $fn = "translations.pro"; |
| 97 |
my $nfn = $fn."new"; |
| 98 |
open IN, $fn or die; |
| 99 |
open OUT, ">".$nfn or die; |
| 100 |
while (1) { |
| 101 |
$_ = <IN>; |
| 102 |
last if (/^TRANSLATIONS /); |
| 103 |
print OUT $_; |
| 104 |
} |
| 105 |
while ($_ =~ /\\\n$/) { |
| 106 |
$_ = <IN>; |
| 107 |
} |
| 108 |
print OUT "TRANSLATIONS =".$code."\n"; |
| 109 |
while (<IN>) { |
| 110 |
print OUT $_; |
| 111 |
} |
| 112 |
close OUT; |
| 113 |
close IN; |
| 114 |
rename $nfn, $fn; |