[kde-doc-english] [releaseme/rewrite] lib: add basic l10nstat building reycled from kde4 version

Harald Sitter sitter at kde.org
Wed Aug 13 10:38:20 UTC 2014


Git commit 1141b650032f830fec9d8586d56865493f5dd320 by Harald Sitter.
Committed on 13/08/2014 at 10:34.
Pushed by sitter into branch 'rewrite'.

add basic l10nstat building reycled from kde4 version

doesn't do much except generate a hash of translation information per
language. also, this is not used in any of the production scripts

A  +57   -0    lib/l10nstatistics.rb
M  +30   -0    lib/tests/data/l10nrepo/trunk/l10n-kf5/de/messages/extragear-multimedia/amarok.po
M  +30   -0    lib/tests/data/l10nrepo/trunk/l10n-kf5/de/messages/extragear-multimedia/amarokcollectionscanner_qt.po
A  +1    -0    lib/tests/data/l10nrepo/trunk/l10n-kf5/fr/docs/extragear-multimedia/amarok/index.docbook
A  +30   -0    lib/tests/data/l10nrepo/trunk/l10n-kf5/fr/messages/extragear-multimedia/amarok.po
A  +30   -0    lib/tests/data/l10nrepo/trunk/l10n-kf5/fr/messages/extragear-multimedia/amarokcollectionscanner_qt.po
M  +1    -0    lib/tests/data/l10nrepo/trunk/l10n-kf5/subdirs
M  +21   -0    lib/tests/ts_l10n.rb

http://commits.kde.org/releaseme/1141b650032f830fec9d8586d56865493f5dd320

diff --git a/lib/l10nstatistics.rb b/lib/l10nstatistics.rb
new file mode 100644
index 0000000..924b4b3
--- /dev/null
+++ b/lib/l10nstatistics.rb
@@ -0,0 +1,57 @@
+class L10nStatistics
+    attr_reader :stats
+
+    def initialize()#project)
+#         @project = project
+        @stats = {}
+    end
+
+    def gather!(sourceDirectory)
+        poDir = "#{sourceDirectory}/po/"
+        Dir.chdir(poDir) do
+            languages = Dir.glob("*")
+            languages.each do |language|
+                next unless File.directory?(language)
+                Dir.chdir(language) do
+                    values = nil
+
+                    translated = 0
+                    fuzzy = 0
+                    untranslated = 0
+
+                    for file in Dir.glob("*.po")
+                        data = %x[LC_ALL=C LANG=C msgfmt --statistics #{file} > /dev/stdout 2>&1]
+
+                        # tear the data apart and create some variables
+                        data.split(",").each do |x|
+                            if x.include? "untranslated"
+                                untranslated += x.scan(/[\d]+/)[0].to_i
+                            elsif x.include? "fuzzy"
+                                fuzzy += x.scan(/[\d]+/)[0].to_i
+                            elsif x.include? "translated"
+                                translated += x.scan(/[\d]+/)[0].to_i
+                            end
+                        end
+                    end
+
+                    all = translated + fuzzy + untranslated
+                    notshown = fuzzy + untranslated
+                    shown = all - notshown
+                    percentage= ((100.0 * shown.to_f) / all.to_f)
+
+                    @stats[language] = {
+                        :all => all,
+                        :shown => shown,
+                        :notshown => notshown,
+                        :percentage => percentage
+                    }
+                    p @stats
+                end
+            end
+        end
+    end
+
+    def write(html_file_path)
+
+    end
+end
\ No newline at end of file
diff --git a/lib/tests/data/l10nrepo/trunk/l10n-kf5/de/messages/extragear-multimedia/amarok.po b/lib/tests/data/l10nrepo/trunk/l10n-kf5/de/messages/extragear-multimedia/amarok.po
index e69de29..2f1deb9 100644
--- a/lib/tests/data/l10nrepo/trunk/l10n-kf5/de/messages/extragear-multimedia/amarok.po
+++ b/lib/tests/data/l10nrepo/trunk/l10n-kf5/de/messages/extragear-multimedia/amarok.po
@@ -0,0 +1,30 @@
+# Thomas Diehl <thd at kde.org>, 2002, 2003, 2004.
+# Stephan Johach <hunsum at gmx.de>, 2004, 2005, 2006.
+# Thomas Reitelbach <tr at erdfunkstelle.de>, 2005, 2006, 2007, 2008, 2009.
+# Burkhard Lück <lueck at hube-lueck.de>, 2009, 2012, 2014.
+# Johannes Obermayr <johannesobermayr at gmx.de>, 2009.
+# Panagiotis Papadopoulos <pano_90 at gmx.net>, 2010.
+# Frederik Schwarzer <schwarzer at kde.org>, 2010, 2011.
+# Hendrik Knackstedt <kn.hendrik at gmail.com>, 2011.
+msgid ""
+msgstr ""
+"Project-Id-Version: ksysguard\n"
+"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
+"POT-Creation-Date: 2014-04-27 20:56+0000\n"
+"PO-Revision-Date: 2014-01-16 07:13+0100\n"
+"Last-Translator: Burkhard Lück <lueck at hube-lueck.de>\n"
+"Language-Team: German <kde-i18n-de at kde.org>\n"
+"Language: de\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=n != 1;\n"
+"X-Generator: Lokalize 1.5\n"
+
+#: HostConnector.cpp:44
+msgid "Connect Host"
+msgstr "Mit Rechner verbinden"
+
+#: Workspace.cpp:263
+msgid "There are no tabs that could be deleted."
+msgstr "Es existieren keine Arbeitsblätter, die gelöscht werden könnten."
diff --git a/lib/tests/data/l10nrepo/trunk/l10n-kf5/de/messages/extragear-multimedia/amarokcollectionscanner_qt.po b/lib/tests/data/l10nrepo/trunk/l10n-kf5/de/messages/extragear-multimedia/amarokcollectionscanner_qt.po
index e69de29..914d994 100644
--- a/lib/tests/data/l10nrepo/trunk/l10n-kf5/de/messages/extragear-multimedia/amarokcollectionscanner_qt.po
+++ b/lib/tests/data/l10nrepo/trunk/l10n-kf5/de/messages/extragear-multimedia/amarokcollectionscanner_qt.po
@@ -0,0 +1,30 @@
+# Thomas Diehl <thd at kde.org>, 2002, 2003, 2004.
+# Stephan Johach <hunsum at gmx.de>, 2004, 2005, 2006.
+# Thomas Reitelbach <tr at erdfunkstelle.de>, 2005, 2006, 2007, 2008, 2009.
+# Burkhard Lück <lueck at hube-lueck.de>, 2009, 2012, 2014.
+# Johannes Obermayr <johannesobermayr at gmx.de>, 2009.
+# Panagiotis Papadopoulos <pano_90 at gmx.net>, 2010.
+# Frederik Schwarzer <schwarzer at kde.org>, 2010, 2011.
+# Hendrik Knackstedt <kn.hendrik at gmail.com>, 2011.
+msgid ""
+msgstr ""
+"Project-Id-Version: ksysguard\n"
+"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
+"POT-Creation-Date: 2014-04-27 20:56+0000\n"
+"PO-Revision-Date: 2014-01-16 07:13+0100\n"
+"Last-Translator: Burkhard Lück <lueck at hube-lueck.de>\n"
+"Language-Team: German <kde-i18n-de at kde.org>\n"
+"Language: de\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=n != 1;\n"
+"X-Generator: Lokalize 1.5\n"
+
+#: HostConnector.cpp:44
+msgid "Connect Host"
+msgstr "Mit Rechner verbinden"
+
+#: Workspace.cpp:263
+msgid "There are no tabs that could be deleted."
+msgstr ""
diff --git a/lib/tests/data/l10nrepo/trunk/l10n-kf5/fr/docs/extragear-multimedia/amarok/index.docbook b/lib/tests/data/l10nrepo/trunk/l10n-kf5/fr/docs/extragear-multimedia/amarok/index.docbook
new file mode 100644
index 0000000..8d1c8b6
--- /dev/null
+++ b/lib/tests/data/l10nrepo/trunk/l10n-kf5/fr/docs/extragear-multimedia/amarok/index.docbook
@@ -0,0 +1 @@
+ 
diff --git a/lib/tests/data/l10nrepo/trunk/l10n-kf5/fr/messages/extragear-multimedia/amarok.po b/lib/tests/data/l10nrepo/trunk/l10n-kf5/fr/messages/extragear-multimedia/amarok.po
new file mode 100644
index 0000000..2f1deb9
--- /dev/null
+++ b/lib/tests/data/l10nrepo/trunk/l10n-kf5/fr/messages/extragear-multimedia/amarok.po
@@ -0,0 +1,30 @@
+# Thomas Diehl <thd at kde.org>, 2002, 2003, 2004.
+# Stephan Johach <hunsum at gmx.de>, 2004, 2005, 2006.
+# Thomas Reitelbach <tr at erdfunkstelle.de>, 2005, 2006, 2007, 2008, 2009.
+# Burkhard Lück <lueck at hube-lueck.de>, 2009, 2012, 2014.
+# Johannes Obermayr <johannesobermayr at gmx.de>, 2009.
+# Panagiotis Papadopoulos <pano_90 at gmx.net>, 2010.
+# Frederik Schwarzer <schwarzer at kde.org>, 2010, 2011.
+# Hendrik Knackstedt <kn.hendrik at gmail.com>, 2011.
+msgid ""
+msgstr ""
+"Project-Id-Version: ksysguard\n"
+"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
+"POT-Creation-Date: 2014-04-27 20:56+0000\n"
+"PO-Revision-Date: 2014-01-16 07:13+0100\n"
+"Last-Translator: Burkhard Lück <lueck at hube-lueck.de>\n"
+"Language-Team: German <kde-i18n-de at kde.org>\n"
+"Language: de\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=n != 1;\n"
+"X-Generator: Lokalize 1.5\n"
+
+#: HostConnector.cpp:44
+msgid "Connect Host"
+msgstr "Mit Rechner verbinden"
+
+#: Workspace.cpp:263
+msgid "There are no tabs that could be deleted."
+msgstr "Es existieren keine Arbeitsblätter, die gelöscht werden könnten."
diff --git a/lib/tests/data/l10nrepo/trunk/l10n-kf5/fr/messages/extragear-multimedia/amarokcollectionscanner_qt.po b/lib/tests/data/l10nrepo/trunk/l10n-kf5/fr/messages/extragear-multimedia/amarokcollectionscanner_qt.po
new file mode 100644
index 0000000..2f1deb9
--- /dev/null
+++ b/lib/tests/data/l10nrepo/trunk/l10n-kf5/fr/messages/extragear-multimedia/amarokcollectionscanner_qt.po
@@ -0,0 +1,30 @@
+# Thomas Diehl <thd at kde.org>, 2002, 2003, 2004.
+# Stephan Johach <hunsum at gmx.de>, 2004, 2005, 2006.
+# Thomas Reitelbach <tr at erdfunkstelle.de>, 2005, 2006, 2007, 2008, 2009.
+# Burkhard Lück <lueck at hube-lueck.de>, 2009, 2012, 2014.
+# Johannes Obermayr <johannesobermayr at gmx.de>, 2009.
+# Panagiotis Papadopoulos <pano_90 at gmx.net>, 2010.
+# Frederik Schwarzer <schwarzer at kde.org>, 2010, 2011.
+# Hendrik Knackstedt <kn.hendrik at gmail.com>, 2011.
+msgid ""
+msgstr ""
+"Project-Id-Version: ksysguard\n"
+"Report-Msgid-Bugs-To: http://bugs.kde.org\n"
+"POT-Creation-Date: 2014-04-27 20:56+0000\n"
+"PO-Revision-Date: 2014-01-16 07:13+0100\n"
+"Last-Translator: Burkhard Lück <lueck at hube-lueck.de>\n"
+"Language-Team: German <kde-i18n-de at kde.org>\n"
+"Language: de\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=UTF-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Plural-Forms: nplurals=2; plural=n != 1;\n"
+"X-Generator: Lokalize 1.5\n"
+
+#: HostConnector.cpp:44
+msgid "Connect Host"
+msgstr "Mit Rechner verbinden"
+
+#: Workspace.cpp:263
+msgid "There are no tabs that could be deleted."
+msgstr "Es existieren keine Arbeitsblätter, die gelöscht werden könnten."
diff --git a/lib/tests/data/l10nrepo/trunk/l10n-kf5/subdirs b/lib/tests/data/l10nrepo/trunk/l10n-kf5/subdirs
index 5e2c53c..13b4dd6 100644
--- a/lib/tests/data/l10nrepo/trunk/l10n-kf5/subdirs
+++ b/lib/tests/data/l10nrepo/trunk/l10n-kf5/subdirs
@@ -1,2 +1,3 @@
 de
+fr
 x-test
diff --git a/lib/tests/ts_l10n.rb b/lib/tests/ts_l10n.rb
index 98adf65..582baa6 100644
--- a/lib/tests/ts_l10n.rb
+++ b/lib/tests/ts_l10n.rb
@@ -2,6 +2,7 @@ require "fileutils"
 require "test/unit"
 
 require_relative "../kdel10n.rb"
+require_relative "../l10nstatistics.rb"
 require_relative "../documentation.rb"
 
 class TestL10n < Test::Unit::TestCase
@@ -100,6 +101,26 @@ class TestL10n < Test::Unit::TestCase
         assert(File::exists?("#{@dir}/po/de/amarokcollectionscanner_qt.po"))
     end
 
+    def test_statistics
+        l = create_l10n()
+        l.initRepoUrl("file://#{Dir.pwd}/#{@svnTemplateDir}")
+
+        FileUtils.rm_rf(@dir)
+        FileUtils.cp_r("data/multi-pot", @dir)
+        l.get(@dir)
+
+        statistics = L10nStatistics.new
+        statistics.gather!(@dir)
+        assert(statistics.stats == {"de"=>{:all=>4,
+                                           :shown=>3,
+                                           :notshown=>1,
+                                           :percentage=>75.0},
+                                    "fr"=>{:all=>4,
+                                           :shown=>4,
+                                           :notshown=>0,
+                                           :percentage=>100.0}})
+    end
+
     def create_doc
         l = DocumentationL10n.new(DocumentationL10n::TRUNK, "amarok", @module, @section)
         return l



More information about the kde-doc-english mailing list