source: trunk/translations/check-ts.pl@ 855

Last change on this file since 855 was 846, checked in by Dmitry A. Kuminov, 14 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

  • Property svn:executable set to *
File size: 3.4 KB
Line 
1#! /usr/bin/perl -w
2#############################################################################
3##
4## Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
5## All rights reserved.
6## Contact: Nokia Corporation ([email protected])
7##
8## This file is part of the translations module of the Qt Toolkit.
9##
10## $QT_BEGIN_LICENSE:LGPL$
11## Commercial Usage
12## Licensees holding valid Qt Commercial licenses may use this file in
13## accordance with the Qt Commercial License Agreement provided with the
14## Software or, alternatively, in accordance with the terms contained in
15## a written agreement between you and Nokia.
16##
17## GNU Lesser General Public License Usage
18## Alternatively, this file may be used under the terms of the GNU Lesser
19## General Public License version 2.1 as published by the Free Software
20## Foundation and appearing in the file LICENSE.LGPL included in the
21## packaging of this file. Please review the following information to
22## ensure the GNU Lesser General Public License version 2.1 requirements
23## will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24##
25## In addition, as a special exception, Nokia gives you certain additional
26## rights. These rights are described in the Nokia Qt LGPL Exception
27## version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28##
29## GNU General Public License Usage
30## Alternatively, this file may be used under the terms of the GNU
31## General Public License version 3.0 as published by the Free Software
32## Foundation and appearing in the file LICENSE.GPL included in the
33## packaging of this file. Please review the following information to
34## ensure the GNU General Public License version 3.0 requirements will be
35## met: http://www.gnu.org/copyleft/gpl.html.
36##
37## If you have questions regarding the use of this file, please contact
38## Nokia at [email protected].
39## $QT_END_LICENSE$
40##
41#############################################################################
42
43
44use strict;
45
46my @groups = ("qt", "assistant", "designer", "linguist", "qt_help", "qtconfig", "qvfb");
47
48my %scores = ();
49my %langs = ();
50
51my $files = join("\n", <*_??.ts>);
52my $res = `xmlpatterns -param files=\"$files\" check-ts.xq`;
53for my $i (split(/ /, $res)) {
54 $i =~ /^([^.]+)\.ts:(.*)$/;
55 my ($fn, $pc) = ($1, $2);
56 for my $g (@groups) {
57 if ($fn =~ /^${g}_((.._)?..)$/) {
58 my $lang = $1;
59 $scores{$g}{$lang} = $pc;
60 $langs{$lang} = 1;
61 last;
62 }
63 }
64}
65
66my $code = "";
67
68print "L10n ";
69for my $g (@groups) {
70 print " ".$g." ";
71}
72print "\n";
73for my $lang (sort(keys(%langs))) {
74 printf "%-5s ", $lang;
75 my $qt = 1;
76 my $rest = 1;
77 my $line = "";
78 for my $g (@groups) {
79 my $pc = $scores{$g}{$lang};
80 $pc = "0" if !defined($pc);
81 if (int($pc) < 98 or !$qt) {
82 if ($g eq "qt") {
83 $qt = 0;
84 } else {
85 $rest = 0;
86 }
87 } else {
88 $line .= " ".$g."_".$lang.".ts";
89 }
90 printf " %-".(length($g)+1)."s", $pc;
91 }
92 if ($qt) {
93 $code .= " \\\n ".$line;
94 if (!$rest) {
95 print " (partial)";
96 }
97 } else {
98 print " (excluded)";
99 }
100 print "\n";
101}
102
103my $fn = "translations.pro";
104my $nfn = $fn."new";
105open IN, $fn or die;
106open OUT, ">".$nfn or die;
107while (1) {
108 $_ = <IN>;
109 last if (/^TRANSLATIONS /);
110 print OUT $_;
111}
112while ($_ =~ /\\\n$/) {
113 $_ = <IN>;
114}
115print OUT "TRANSLATIONS =".$code."\n";
116while (<IN>) {
117 print OUT $_;
118}
119close OUT;
120close IN;
121rename $nfn, $fn;
Note: See TracBrowser for help on using the repository browser.