From: John Mandereau Date: Fri, 21 Mar 2008 08:38:10 +0000 (+0100) Subject: Update word counts automatically with translations-status.py X-Git-Tag: release/2.11.43-1~19^2^2~3 X-Git-Url: https://git.donarmstrong.com/?a=commitdiff_plain;h=4fa6ca0b8a7a1e40e0f62b5dd187b74bfd60ed75;p=lilypond.git Update word counts automatically with translations-status.py --- diff --git a/Documentation/TRANSLATION b/Documentation/TRANSLATION index 61b2e6d02d..56d6e5e3bc 100644 --- a/Documentation/TRANSLATION +++ b/Documentation/TRANSLATION @@ -74,95 +74,79 @@ Translation of Documentation/foo/bar should be Documentation//foo/bar. Unmentioned files should not be translated. -Priorities: 1. delivery, 2. 3. 4. 5. later, 6. optional. +Priorities: + 1. delivery + 2. 3. 4. 5. later + 6. optional Files marked with priority 3, 4 or 5 may be submitted individually. +Word counts (excluding lilypond snippets) are given for each file. --1- Documentation index, Tutorial and Cheat Sheet -1 user/lilypond.tely -1 user/tutorial.itely -1 user/dedication.itely -1 user/cheatsheet.itely -1 index.html.in - po/.po +-1- Documentation index and Tutorial +396 user/lilypond-learning.tely +5593 user/tutorial.itely +23 user/dedication.itely +216 index.html.in +1954 po/lilypond-doc.pot (translate to po/.po) +8182 total In addition, user/macros.itexi may be translated in case typographic rules used in this file are different in your language. --2- User manual introduction -2 user/preface.itely -2 user/introduction.itely +-2- Introduction and beginning of Application Usage +411 user/preface.itely +3198 user/introduction.itely +374 user/lilypond-program.tely +1477 user/install.itely (partial translation) +947 user/setup.itely +2860 user/running.itely +9267 total -3- Learning manual -3 user/putting.itely -- Putting it all together -3 user/working.itely -- Working on LilyPond files -3 user/tweaks.itely -- Tweaking output +8626 user/fundamental.itely -- Fundamental concepts +12134 user/tweaks.itely -- Tweaking output +2985 user/working.itely -- Working on LilyPond files +483 user/templates.itely -- Templates +24228 total -4- Notation reference -4 user/basic-notation.itely -- Basic notation -4 user/instrument-notation.itely -- Instrument-specific notation -4 user/advanced-notation.itely -- Advanced notation -4 user/changing-defaults.itely -- Changing defaults -4 user/non-music.itely -- Non-musical notation -4 user/spacing.itely -- Spacing issues -4 user/programming-interface.itely -- Interfaces for programmers -4 user/scheme-tutorial.itely -- Scheme tutorial - --5- Program usage -5 user/lilypond-program.tely -5 user/install.itely -- How to install or compile -5 user/running.itely -- Running LilyPond -5 user/lilypond-book.itely -- LilyPond-book -5 user/converters.itely -- Converting from other formats +539 user/lilypond.tely +91 user/notation.itely -- Musical notation +2808 user/pitches.itely +7336 user/rhythms.itely +1681 user/expressive.itely +725 user/repeats.itely +916 user/simultaneous.itely +1861 user/staff.itely +879 user/editorial.itely +2336 user/text.itely +54 user/specialist.itely -- Specialist notation +2630 user/vocal.itely +1275 user/chords.itely +702 user/piano.itely +481 user/percussion.itely +826 user/guitar.itely +66 user/strings.itely +242 user/bagpipes.itely +4289 user/ancient.itely +2502 user/input.itely -- Input syntax +2164 user/non-music.itely -- Non-musical notation +8399 user/spacing.itely -- Spacing issues +5107 user/changing-defaults.itely -- Changing defaults +4547 user/programming-interface.itely -- Interfaces for programmers +935 user/notation-appendices.itely -- Notation manual tables +250 user/cheatsheet.itely -- Cheat sheet +53641 total + +-5- Application usage +2917 user/lilypond-book.itely -- LilyPond-book +975 user/converters.itely -- Converting from other formats +3892 total -6- Appendices whose translation is optional -6 user/literature.itely -6 user/templates.itely -6 user/notation-appendices.itely - -* WORD COUNTS FOR CATEGORIES - -LANG=C wc --words $(grep ^1 TRANSLATION | cut -d ' ' -f 2) - 777 user/lilypond.tely - 6322 user/tutorial.itely - 63 user/dedication.itely - 632 user/cheatsheet.itely - 361 index.html.in - 8155 total - -LANG=C wc --words $(grep ^2 TRANSLATION | cut -d ' ' -f 2) - 451 user/preface.itely - 4170 user/introduction.itely - 4621 total - -LANG=C wc --words $(grep ^3 TRANSLATION | cut -d ' ' -f 2) - 2230 user/putting.itely - 3232 user/working.itely - 2327 user/tweaks.itely - 7789 total - -LANG=C wc --words $(grep ^4 TRANSLATION | cut -d ' ' -f 2) - 12391 user/basic-notation.itely - 15779 user/instrument-notation.itely - 9530 user/advanced-notation.itely - 7386 user/changing-defaults.itely - 3884 user/non-music.itely - 8318 user/spacing.itely - 4781 user/programming-interface.itely - 915 user/scheme-tutorial.itely - 62984 total - -LANG=C wc --words $(grep ^5 TRANSLATION | cut -d ' ' -f 2) - 3566 user/running.itely - 3549 user/lilypond-book.itely - 1062 user/converters.itely - 8177 total - -LANG=C wc --words $(grep ^6 TRANSLATION | cut -d ' ' -f 2) - 339 user/literature.itely - 4648 user/templates.itely - 836 user/notation-appendices.itely - 5823 total +299 user/literature.itely +960 user/scheme-tutorial.itely (needs to be revised first) +1259 total TRANSLATION DETAILED INSTRUCTIONS diff --git a/Documentation/translations.html.in b/Documentation/translations.html.in index f514d31f92..6c5bc16fb4 100644 --- a/Documentation/translations.html.in +++ b/Documentation/translations.html.in @@ -38,7 +38,7 @@ translations.template.html.in; DO NOT EDIT !--> is finished.

-

Last updated Sun Mar 16 15:46:21 UTC 2008 +

Last updated Fri Mar 21 08:33:58 UTC 2008

@@ -51,7 +51,7 @@ translations.template.html.in; DO NOT EDIT !--> - @@ -249,7 +249,7 @@ translations.template.html.in; DO NOT EDIT !--> - + @@ -283,7 +283,7 @@ translations.template.html.in; DO NOT EDIT !--> - + @@ -350,7 +350,7 @@ translations.template.html.in; DO NOT EDIT !--> - + @@ -514,10 +514,10 @@ translations.template.html.in; DO NOT EDIT !--> - + @@ -548,7 +548,7 @@ translations.template.html.in; DO NOT EDIT !--> - +
John Mandereau
Jean-Charles Malahieude
translated
- partially up to date
+ up to date
Till Rettig
translated
@@ -126,7 +126,7 @@ translations.template.html.in; DO NOT EDIT !-->
not translated
partially translated (27 %)
+
partially translated (50 %)
1.2 Rhythms
(7279)
1.2 Rhythms
(7336)
Frédéric Chiasson
Valentin Villenave
Jean-Charles Malahieude

@@ -257,12 +257,12 @@ translations.template.html.in; DO NOT EDIT !-->
Till Rettig
- partially translated (82 %)
+ partially translated (83 %)

Francisco Vila
- partially translated (87 %)
- partially up to date
+ partially translated (84 %)
+ partially up to date
1.4 Repeats
(738)
1.4 Repeats
(725)
Valentin Villenave
Jean-Charles Malahieude
John Mandereau

@@ -296,7 +296,7 @@ translations.template.html.in; DO NOT EDIT !-->
Francisco Vila
translated
- partially up to date
+ partially up to date
1.8 Text
(2361)
1.8 Text
(2336)
Jean-Charles Malahieude
Valentin Villenave
John Mandereau

@@ -361,7 +361,7 @@ translations.template.html.in; DO NOT EDIT !-->
Francisco Vila
translated
- partially up to date
+ partially up to date
3 Input syntax
(2458)
3 Input syntax
(2502)
Jean-Charles Malahieude
partially translated (7 %)
- partially up to date
+ partially up to date
not translated
6 Changing defaults
(5105)
6 Changing defaults
(5107)
Valentin Villenave
Gilles Thibault
translated
diff --git a/buildscripts/translations-status.py b/buildscripts/translations-status.py index 1d53780b9b..b9f62a706f 100644 --- a/buildscripts/translations-status.py +++ b/buildscripts/translations-status.py @@ -7,9 +7,10 @@ USAGE: translations-status.py BUILDSCRIPT-DIR LOCALEDIR Reads template files translations.template.html.in and for each LANG in LANGUAGES LANG/translations.template.html.in - Writes translations.html.in and for each LANG in LANGUAGES translations.LANG.html.in + Writes out/translations-status.txt + Updates word counts in TRANSLATION """ import sys @@ -145,6 +146,24 @@ def percentage_color (percent): c = [hex (int ((3 * p - 2) * b + 3 * (1 - p) * a))[2:] for (a, b) in [(0xff, 0x1f), (0xff, 0xff), (0x3d, 0x1f)]] return ''.join (c) + +def update_word_count (text, filename, word_count): + return re.sub (r'(?m)^(\d+) *' + filename, + str (word_count).ljust (6) + filename, + text) + +po_msgid_re = re.compile (r'^msgid "(.*?)"(?:\n"(.*?)")*', re.M) + +def po_word_count (po_content): + s = ' '.join ([''.join (t) for t in po_msgid_re.findall (po_content)]) + return len (space_re.split (s)) + +sgml_tag_re = re.compile (r'<.*?>', re.S) + +def sgml_word_count (sgml_doc): + s = sgml_tag_re.sub ('', sgml_doc) + return len (space_re.split (s)) + def tely_word_count (tely_doc): ''' Calculate word count of a Texinfo document node by node. @@ -325,9 +344,11 @@ class MasterTelyDocument (TelyDocument): else: self.includes = [] - # TODO - def print_wc_priority (self): - return + def update_word_counts (self, s): + s = update_word_count (s, self.filename, sum (self.word_count)) + for i in self.includes: + s = i.update_word_counts (s) + return s def html_status (self, numbering=SectionNumber ()): if self.title == 'Untitled' or not self.translations: @@ -378,6 +399,15 @@ class MasterTelyDocument (TelyDocument): return s +update_category_word_counts_re = re.compile (r'(?ms)^-(\d+)-(.*?\n)\d+ *total') + +counts_re = re.compile (r'(?m)^(\d+) ') + +def update_category_word_counts_sub (m): + return '-' + m.group (1) + '-' + m.group (2) + \ + str (sum ([int (c) for c in counts_re.findall (m.group (2))])).ljust (6) + 'total' + + progress ("Reading documents...") tely_files = read_pipe ("find -maxdepth 2 -name '*.tely'")[0].splitlines () @@ -421,3 +451,27 @@ main_status_txt += '\n'.join ([doc.text_status () for doc in master_docs]) status_txt_file = 'out/translations-status.txt' progress ("Writing %s..." % status_txt_file) open (status_txt_file, 'w').write (main_status_txt) + +translation_instructions_file = 'TRANSLATION' +progress ("Updating %s..." % translation_instructions_file) +translation_instructions = open (translation_instructions_file).read () + +for doc in master_docs: + translation_instructions = doc.update_word_counts (translation_instructions) + +for html_file in re.findall (r'(?m)^\d+ *(\S+?\.html\S*?)(?: |$)', translation_instructions): + word_count = sgml_word_count (open (html_file).read ()) + translation_instructions = update_word_count (translation_instructions, + html_file, + word_count) + +for po_file in re.findall (r'(?m)^\d+ *(\S+?\.po\S*?)(?: |$)', translation_instructions): + word_count = po_word_count (open (po_file).read ()) + translation_instructions = update_word_count (translation_instructions, + po_file, + word_count) + +translation_instructions = update_category_word_counts_re.sub (update_category_word_counts_sub, + translation_instructions) + +open (translation_instructions_file, 'w').write (translation_instructions)