From edce9a6117a78d53f781c97b2489419aabced481 Mon Sep 17 00:00:00 2001 From: rimach Date: Tue, 22 Jun 2010 19:16:39 +0200 Subject: [PATCH] improve translation_utils script --- resources/i18n/openlp_en.ts | 920 ++++++++++++++++++++++++++--------- resources/i18n/openlp_et.ts | 493 ++++++++++++++++++- scripts/translation_utils.py | 295 ++++++----- 3 files changed, 1366 insertions(+), 342 deletions(-) diff --git a/resources/i18n/openlp_en.ts b/resources/i18n/openlp_en.ts index 954ad5aff..446cb286a 100644 --- a/resources/i18n/openlp_en.ts +++ b/resources/i18n/openlp_en.ts @@ -1,6 +1,5 @@ - - + AboutForm @@ -64,8 +63,8 @@ Packagers - Copyright © 2004-2010 Raoul Snyman -Portions copyright © 2004-2010 Tim Bentley, Jonathan Corwin, Michael Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin Thompson, Jon Tibble, Carsten Tinggaard + Copyright © 2004-2010 Raoul Snyman +Portions copyright © 2004-2010 Tim Bentley, Jonathan Corwin, Michael Gorven, Scott Guerrieri, Christian Richter, Maikel Stuivenberg, Martin Thompson, Jon Tibble, Carsten Tinggaard This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; version 2 of the License. @@ -230,6 +229,11 @@ This General Public License does not permit incorporating your program into prop Show an alert message + + + <b>Alerts Plugin</b><br>This plugin controls the displaying of alerts on the presentations screen + + AlertsPlugin.AlertForm @@ -261,7 +265,7 @@ This General Public License does not permit incorporating your program into prop &Delete - &Delete + @@ -289,6 +293,14 @@ This General Public License does not permit incorporating your program into prop + + AlertsPlugin.AlertsManager + + + Alert message created and delayed + + + AlertsPlugin.AlertsTab @@ -691,7 +703,12 @@ This General Public License does not permit incorporating your program into prop BiblePlugin - + + <strong>Bible Plugin</strong><br />This plugin allows bible verses from different sources to be displayed on the screen during the service. + + + + &Bible @@ -708,6 +725,11 @@ This General Public License does not permit incorporating your program into prop Verse Display + + + Only show new chapter numbers + + Layout Style: @@ -764,6 +786,15 @@ This General Public License does not permit incorporating your program into prop + + BiblesPlugin.BiblesTab + + + Note: +Changes don't affect verses already in the service + + + BiblesPlugin.ImportWizardForm @@ -771,6 +802,26 @@ This General Public License does not permit incorporating your program into prop Bible Import Wizard + + + Welcome to the Bible Import Wizard + + + + + This wizard will help you to import Bibles from a variety of formats. Click the next button below to start the process by selecting a format to import from. + + + + + Select Import Source + + + + + Select the import format, and where to import from. + + Format: @@ -856,11 +907,21 @@ This General Public License does not permit incorporating your program into prop Password: + + + Proxy Server (Optional) + + License Details + + + Set up the Bible's license details. + + Version Name: @@ -881,11 +942,86 @@ This General Public License does not permit incorporating your program into prop Importing + + + Please wait while your Bible is imported. + + Ready. + + + Invalid Bible Location + + + + + You need to specify a file to import your Bible from. + + + + + Invalid Books File + + + + + You need to specify a file with books of the Bible to use in the import. + + + + + Invalid Verse File + + + + + You need to specify a file of Bible verses to import. + + + + + Invalid OpenSong Bible + + + + + You need to specify an OpenSong Bible file to import. + + + + + Empty Version Name + + + + + You need to specify a version name for your Bible. + + + + + Empty Copyright + + + + + You need to set a copyright for your Bible! Bibles in the Public Domain need to be marked as such. + + + + + Bible Exists + + + + + This Bible already exists! Please import a different Bible or first delete the existing one. + + Open OSIS File @@ -896,6 +1032,11 @@ This General Public License does not permit incorporating your program into prop Open Books CSV File + + + Open Verses CSV File + + Open OpenSong Bible @@ -906,6 +1047,16 @@ This General Public License does not permit incorporating your program into prop Starting import... + + + Finished import. + + + + + Your Bible import failed. + + BiblesPlugin.MediaItem @@ -1004,6 +1155,11 @@ This General Public License does not permit incorporating your program into prop No Book Found + + + No matching book could be found in this Bible. + + etc @@ -1023,6 +1179,14 @@ This General Public License does not permit incorporating your program into prop + + CustomPlugin + + + <b>Custom Plugin</b><br>This plugin allows slides to be displayed on the screen in the same way songs are. This plugin provides greater freedom over the songs plugin.<br> + + + CustomPlugin.CustomTab @@ -1030,6 +1194,11 @@ This General Public License does not permit incorporating your program into prop Custom + + + Custom Display + + Display Footer @@ -1139,22 +1308,22 @@ This General Public License does not permit incorporating your program into prop - + Save && Preview - Save && Preview + - + Error - Error + - + You need to enter a title - + You need to enter a slide @@ -1166,11 +1335,21 @@ This General Public License does not permit incorporating your program into prop Custom + + + You must select an item to edit. + + + + + You must select an item to delete. + + CustomPlugin.editCustomForm - + You have unsaved data, please save or clear @@ -1263,7 +1442,7 @@ This General Public License does not permit incorporating your program into prop CCLI Number: - CCLI number: + @@ -1930,6 +2109,11 @@ You can download the latest version from http://openlp.org Invalid Service Item + + + You must select a %s service item. + + MediaPlugin @@ -1960,7 +2144,7 @@ You can download the latest version from http://openlp.org OpenLP - + Image Files @@ -2023,22 +2207,78 @@ You can download the latest version from http://openlp.org + + PresentationPlugin + + + <b>Presentation Plugin</b> <br> Delivers the ability to show presentations using a number of different programs. The choice of available presentation programs is available to the user in a drop down box. + + + PresentationPlugin.MediaItem + + + Presentation + + + + + Select Presentation(s) + + + + + Automatic + + Present using: + + + File exists + + + + + A presentation with that filename already exists. + + + + + You must select an item to delete. + + PresentationPlugin.PresentationTab + + + Presentations + + + + + Available Controllers + + available + + RemotePlugin + + + <b>Remote Plugin</b><br>This plugin provides the ability to send messages to a running version of openlp on a different computer via a web browser or other app<br>The Primary use for this would be to send alerts from a creche + + + RemotePlugin.RemoteTab @@ -2230,7 +2470,7 @@ You can download the latest version from http://openlp.org Error - Error + @@ -2358,6 +2598,108 @@ The content encoding is not UTF-8. + + SongUsagePlugin + + + &Delete recorded data + + + + + Start/Stop live song usage recording + + + + + <b>SongUsage Plugin</b><br>This plugin records the use of songs and when they have been used during a live service + + + + + Delete song usage to specified date + + + + + Generate report on Song Usage + + + + + Song Usage Status + + + + + &Extract recorded data + + + + + &Song Usage + + + + + SongsPlugin + + + &Song + + + + + Import songs using the import wizard. + + + + + Songs of Fellowship (temp menu item) + + + + + Import songs from the VOLS1_2.RTF, sof3words.rtf and sof4words.rtf supplied with the music books + + + + + Generic Document/Presentation Import (temp menu item) + + + + + Import songs from Word/Writer/Powerpoint/Impress + + + + + Open Songs of Fellowship file + + + + + Import Error + + + + + Error importing Songs of Fellowship file. +OpenOffice.org must be installed and you must be using an unedited copy of the RTF included with the Songs of Fellowship Music Editions + + + + + Open documents or presentations + + + + + <strong>Song Plugin</strong><br />This plugin allows songs to be managed and displayed. + + + SongsPlugin.AuditDeleteDialog @@ -2368,6 +2710,11 @@ The content encoding is not UTF-8. SongsPlugin.AuditDetailDialog + + + Song Usage Extraction + + Select Date Range @@ -2389,42 +2736,42 @@ The content encoding is not UTF-8. Author Maintenance - Author Maintenance + Display name: - &Display name: + First name: - &First name: + Last name: - &Last name: + Error - Error + You need to type in the first name of the author. - You need to type in the first name of the author. + You need to type in the last name of the author. - You need to type in the last name of the author. + You haven't set a display name for the author, would you like me to combine the first and last names for you? - You haven't set a display name for the author, would you like me to combine the first and last names for you? + @@ -2432,222 +2779,222 @@ The content encoding is not UTF-8. Song Editor - Song Editor + &Title: - &Title: - - - - &Lyrics: - &Lyrics: - - - - &Verse Order: - &Verse order: - - - - &Add - &Add - - - - &Edit - &Edit - - - - Ed&it All - Ed&it All - - - - &Delete - &Delete - - - - Title && Lyrics - Title && Lyrics - - - - Authors - Authors - - - - &Add to Song - &Add to Song - - - - &Remove - &Remove - - - - &Manage Authors, Topics, Books - &Manage Authors, Topics, Books - - - - Topic - Topic - - - - A&dd to Song - A&dd to Song - - - - R&emove - R&emove - - - - Song Book - Song Book - - - - Authors, Topics && Book - Authors, Topics && Book - - - - Theme - Theme - - - - Copyright Information - Copyright Information - - - - CCLI Number: - CCLI number: - - - - Comments - Comments - - - - Theme, Copyright Info && Comments - Theme, Copyright Info && Comments - - - - Add Author - Add Author - - - - This author does not exist, do you want to add them? - This author does not exist, do you want to add them? - - - - No Author Selected - No Author Selected - - - - You have not selected a valid author. Either select an author from the list, or type in a new author and click the "Add Author to Song" button to add the new author. - You have not selected a valid author. Either select an author from the list, or type in a new author and click the "Add Author to Song" button to add the new author. - - - - Add Topic - Add Topic - - - - This topic does not exist, do you want to add it? - This topic does not exist, do you want to add it? - - - - No Topic Selected - No Topic Selected - - - - You have not selected a valid topic. Either select a topic from the list, or type in a new topic and click the "Add Topic to Song" button to add the new topic. - You have not selected a valid topic. Either select a topic from the list, or type in a new topic and click the "add Topic to Song" button to add the new topic. - - - - Add Book - Add Book - - - - This song book does not exist, do you want to add it? - This song book does not exist, do you want to add it? - - - - The verse order is invalid. There is no verse corresponding to %s. Valid entries are %s. - The verse order is invalid. There is no verse corresponding to %s. Valid entries are %s. + Alt&ernate Title: - Alt&ernate Title: + + + + + &Lyrics: + + + + + &Verse Order: + + + + + &Add + + + + + &Edit + + + + + Ed&it All + + + + + &Delete + + + + + Title && Lyrics + + + + + Authors + + + + + &Add to Song + + + + + &Remove + + + + + &Manage Authors, Topics, Books + + + + + Topic + + + + + A&dd to Song + + + + + R&emove + + + + + Song Book + + + + + Authors, Topics && Book + + + + + Theme + New &Theme - New &Theme + + + + + Copyright Information + - © - © + © + + + + + CCLI Number: + + + + + Comments + + + + + Theme, Copyright Info && Comments + Save && Preview - Save && Preview + + + + + Add Author + + + + + This author does not exist, do you want to add them? + + + + + No Author Selected + + + + + You have not selected a valid author. Either select an author from the list, or type in a new author and click the "Add Author to Song" button to add the new author. + + + + + Add Topic + + + + + This topic does not exist, do you want to add it? + + + + + No Topic Selected + + + + + You have not selected a valid topic. Either select a topic from the list, or type in a new topic and click the "Add Topic to Song" button to add the new topic. + + + + + Add Book + + + + + This song book does not exist, do you want to add it? + Error - Error + You need to type in a song title. - You need to type in a song title. + You need to type in at least one verse. - You need to type in at least one verse. + Warning - Warning + You have not added any authors for this song. Do you want to add an author now? - You have not added any authors for this song. Do you want to add an author now? + + + + + The verse order is invalid. There is no verse corresponding to %s. Valid entries are %s. + You have not used %s anywhere in the verse order. Are you sure you want to save the song like this? - You have not used %s anywhere in the verse order. Are you sure you want to save the song like this? + @@ -2655,17 +3002,17 @@ The content encoding is not UTF-8. Edit Verse - Edit Verse + &Verse type: - &Verse type: + &Insert - &Insert + @@ -2710,6 +3057,11 @@ The content encoding is not UTF-8. You need to specify a CSV file to import from. + + + Starting import... + + Song Import Wizard @@ -2800,11 +3152,6 @@ The content encoding is not UTF-8. %p% - - - Starting import... - - SongsPlugin.MediaItem @@ -2816,7 +3163,12 @@ The content encoding is not UTF-8. Song Maintenance - Song Maintenance + + + + + Maintain the lists of authors, topics and books + @@ -2851,13 +3203,33 @@ The content encoding is not UTF-8. Authors - Authors + %s (%s) + + + You must select an item to edit. + + + + + You must select an item to delete. + + + + + Delete song? + + + + + Delete %d songs? + + Delete Confirmation @@ -2874,27 +3246,27 @@ The content encoding is not UTF-8. Edit Book - Edit Book + &Name: - &Name: + &Publisher: - &Publisher: + Error - Error + You need to type in a name for the book. - You need to type in a name for the book. + @@ -2902,59 +3274,155 @@ The content encoding is not UTF-8. Song Maintenance - Song Maintenance + Authors - Authors + Topics - Topics + Books/Hymnals - Books/Hymnals + &Add - &Add + &Edit - &Edit + &Delete - &Delete + + + + + Error + + + + + Couldn't add your author. + + + + + Couldn't add your topic. + + + + + Couldn't add your book. + + + + + Couldn't save your author. + + + + + Couldn't save your topic. + + + + + Couldn't save your book. + Delete Author + + + Are you sure you want to delete the selected author? + + + + + This author can't be deleted, they are currently assigned to at least one song. + + + + + No author selected! + + Delete Topic + + + Are you sure you want to delete the selected topic? + + + + + This topic can't be deleted, it is currently assigned to at least one song. + + + + + No topic selected! + + Delete Book + + + Are you sure you want to delete the selected book? + + + + + This book can't be deleted, it is currently assigned to at least one song. + + No book selected! + + SongsPlugin.SongUsageDeleteForm + + + Delete Selected Song Usage Events? + + + + + Are you sure you want to delete selected Song Usage data? + + + + + SongsPlugin.SongUsageDetailForm + + + Output File Location + + + SongsPlugin.SongsTab @@ -2972,6 +3440,11 @@ The content encoding is not UTF-8. Enable search as you type + + + Display Verses on Live Tool bar + + SongsPlugin.TopicsForm @@ -2988,7 +3461,12 @@ The content encoding is not UTF-8. Error - Error + + + + + You need to type in a topic name! + @@ -3019,7 +3497,7 @@ The content encoding is not UTF-8. Error - Error + diff --git a/resources/i18n/openlp_et.ts b/resources/i18n/openlp_et.ts index b84f4a108..5af0470e8 100644 --- a/resources/i18n/openlp_et.ts +++ b/resources/i18n/openlp_et.ts @@ -262,6 +262,11 @@ This General Public License does not permit incorporating your program into prop Show an alert message + + + <b>Alerts Plugin</b><br>This plugin controls the displaying of alerts on the presentations screen + + AlertsPlugin.AlertForm @@ -321,6 +326,14 @@ This General Public License does not permit incorporating your program into prop + + AlertsPlugin.AlertsManager + + + Alert message created and delayed + + + AlertsPlugin.AlertsTab @@ -723,10 +736,15 @@ This General Public License does not permit incorporating your program into prop BiblePlugin - + &Bible + + + <strong>Bible Plugin</strong><br />This plugin allows bible verses from different sources to be displayed on the screen during the service. + + BiblesPlugin,BiblesTab @@ -795,6 +813,20 @@ This General Public License does not permit incorporating your program into prop Display Dual Bible Verses + + + Only show new chapter numbers + + + + + BiblesPlugin.BiblesTab + + + Note: +Changes don't affect verses already in the service + + BiblesPlugin.ImportWizardForm @@ -938,6 +970,126 @@ This General Public License does not permit incorporating your program into prop Starting import... + + + Welcome to the Bible Import Wizard + + + + + This wizard will help you to import Bibles from a variety of formats. Click the next button below to start the process by selecting a format to import from. + + + + + Select Import Source + + + + + Select the import format, and where to import from. + + + + + Proxy Server (Optional) + + + + + Set up the Bible's license details. + + + + + Please wait while your Bible is imported. + + + + + Invalid Bible Location + + + + + You need to specify a file to import your Bible from. + + + + + Invalid Books File + + + + + You need to specify a file with books of the Bible to use in the import. + + + + + Invalid Verse File + + + + + You need to specify a file of Bible verses to import. + + + + + Invalid OpenSong Bible + + + + + You need to specify an OpenSong Bible file to import. + + + + + Empty Version Name + + + + + You need to specify a version name for your Bible. + + + + + Empty Copyright + + + + + You need to set a copyright for your Bible! Bibles in the Public Domain need to be marked as such. + + + + + Bible Exists + + + + + This Bible already exists! Please import a different Bible or first delete the existing one. + + + + + Open Verses CSV File + + + + + Finished import. + + + + + Your Bible import failed. + + BiblesPlugin.MediaItem @@ -1046,6 +1198,11 @@ This General Public License does not permit incorporating your program into prop Bible not fully loaded + + + No matching book could be found in this Bible. + + BiblesPlugin.Opensong @@ -1055,6 +1212,14 @@ This General Public License does not permit incorporating your program into prop + + CustomPlugin + + + <b>Custom Plugin</b><br>This plugin allows slides to be displayed on the screen in the same way songs are. This plugin provides greater freedom over the songs plugin.<br> + + + CustomPlugin.CustomTab @@ -1067,6 +1232,11 @@ This General Public License does not permit incorporating your program into prop Display Footer + + + Custom Display + + CustomPlugin.EditCustomForm @@ -1171,22 +1341,22 @@ This General Public License does not permit incorporating your program into prop Autorid: - + Save && Preview Salvesta && eelvaatle - + Error Viga - + You need to enter a title Pead sisestama pealkirja - + You need to enter a slide Pead sisenema slaidile @@ -1198,11 +1368,21 @@ This General Public License does not permit incorporating your program into prop Custom + + + You must select an item to edit. + + + + + You must select an item to delete. + + CustomPlugin.editCustomForm - + You have unsaved data, please save or clear Sul on salvestamata andmeid, palun salvesta või tühjenda @@ -1962,6 +2142,11 @@ You can download the latest version from http://openlp.org You must select one or more items to send live. + + + You must select a %s service item. + + MediaPlugin @@ -1992,7 +2177,7 @@ You can download the latest version from http://openlp.org OpenLP - + Image Files @@ -2055,6 +2240,14 @@ You can download the latest version from http://openlp.org + + PresentationPlugin + + + <b>Presentation Plugin</b> <br> Delivers the ability to show presentations using a number of different programs. The choice of available presentation programs is available to the user in a drop down box. + + + PresentationPlugin.MediaItem @@ -2062,6 +2255,36 @@ You can download the latest version from http://openlp.org Present using: + + + Presentation + + + + + Select Presentation(s) + + + + + Automatic + + + + + File exists + + + + + A presentation with that filename already exists. + + + + + You must select an item to delete. + + PresentationPlugin.PresentationTab @@ -2070,6 +2293,24 @@ You can download the latest version from http://openlp.org available + + + Presentations + + + + + Available Controllers + + + + + RemotePlugin + + + <b>Remote Plugin</b><br>This plugin provides the ability to send messages to a running version of openlp on a different computer via a web browser or other app<br>The Primary use for this would be to send alerts from a creche + + RemotePlugin.RemoteTab @@ -2390,6 +2631,108 @@ The content encoding is not UTF-8. Muuda ja kuva laulu eelvaade uuesti + + SongUsagePlugin + + + &Song Usage + + + + + &Delete recorded data + + + + + Delete song usage to specified date + + + + + &Extract recorded data + + + + + Generate report on Song Usage + + + + + Song Usage Status + + + + + Start/Stop live song usage recording + + + + + <b>SongUsage Plugin</b><br>This plugin records the use of songs and when they have been used during a live service + + + + + SongsPlugin + + + &Song + + + + + Import songs using the import wizard. + + + + + Songs of Fellowship (temp menu item) + + + + + Import songs from the VOLS1_2.RTF, sof3words.rtf and sof4words.rtf supplied with the music books + + + + + Generic Document/Presentation Import (temp menu item) + + + + + Import songs from Word/Writer/Powerpoint/Impress + + + + + Open Songs of Fellowship file + + + + + Import Error + + + + + Error importing Songs of Fellowship file. +OpenOffice.org must be installed and you must be using an unedited copy of the RTF included with the Songs of Fellowship Music Editions + + + + + Open documents or presentations + + + + + <strong>Song Plugin</strong><br />This plugin allows songs to be managed and displayed. + + + SongsPlugin.AuditDeleteDialog @@ -2415,6 +2758,11 @@ The content encoding is not UTF-8. Report Location + + + Song Usage Extraction + + SongsPlugin.AuthorsForm @@ -2900,6 +3248,31 @@ The content encoding is not UTF-8. CCLI Licence: + + + Maintain the lists of authors, topics and books + + + + + You must select an item to edit. + + + + + You must select an item to delete. + + + + + Delete song? + + + + + Delete %d songs? + + SongsPlugin.SongBookForm @@ -2986,6 +3359,102 @@ The content encoding is not UTF-8. No book selected! + + + Error + Viga + + + + Couldn't add your author. + + + + + Couldn't add your topic. + + + + + Couldn't add your book. + + + + + Couldn't save your author. + + + + + Couldn't save your topic. + + + + + Couldn't save your book. + + + + + Are you sure you want to delete the selected author? + + + + + This author can't be deleted, they are currently assigned to at least one song. + + + + + No author selected! + + + + + Are you sure you want to delete the selected topic? + + + + + This topic can't be deleted, it is currently assigned to at least one song. + + + + + No topic selected! + + + + + Are you sure you want to delete the selected book? + + + + + This book can't be deleted, it is currently assigned to at least one song. + + + + + SongsPlugin.SongUsageDeleteForm + + + Delete Selected Song Usage Events? + + + + + Are you sure you want to delete selected Song Usage data? + + + + + SongsPlugin.SongUsageDetailForm + + + Output File Location + + SongsPlugin.SongsTab @@ -3004,6 +3473,11 @@ The content encoding is not UTF-8. Enable search as you type + + + Display Verses on Live Tool bar + + SongsPlugin.TopicsForm @@ -3022,6 +3496,11 @@ The content encoding is not UTF-8. Error Viga + + + You need to type in a topic name! + + Splashscreen diff --git a/scripts/translation_utils.py b/scripts/translation_utils.py index ee5baead9..14c4ba6fc 100755 --- a/scripts/translation_utils.py +++ b/scripts/translation_utils.py @@ -25,143 +25,210 @@ ############################################################################### # Short description # Steps for creating languages: -# 1. make shure that the openlp_en.ts file exist +# 1. make sure that the openlp_en.ts file exist # 2. go to scripts folder and start: # python translation_utils.py -a ############################################################################### import os import urllib +import re from optparse import OptionParser from PyQt4 import QtCore +from BeautifulSoup import BeautifulSoup -ignore_pathes = [u"./scripts", u"./openlp/core/test"] -ignore_files = [u"setup.py"] -translation_path = u"http://pootle.projecthq.biz/export/openlp/" -translations = [ u"en" - , u"af" - , u"en_ZA" - , u"en_GB" - , u"de" - , u"hu" - , u"ko" - , u"nb" - , u"pt_BR" - , u"es" - , u"sv"] +class TranslationUtils(object): + def __init__(self): + self.ignore_paths = [u'./scripts'] + self.ignore_files = [u'setup.py'] + self.server_url = u'http://pootle.projecthq.biz/export/openlp/' + self.cmd_stack = [] + self.stack_count = 0 + self.verbose = False + -def write_file(filename, stringlist): - content = u'' - for line in stringlist: - content = u'%s%s\n' % (content, line) - file = open(filename, u'w') - file.write(content.encode('utf8')) - file.close() + def process_stack(self): + if len(self.cmd_stack) > 0: + if len(self.cmd_stack) == self.stack_count: + print u'Process %d commands' % self.stack_count + print u'%d. ' % (self.stack_count-len(self.cmd_stack)+1), + command = self.cmd_stack.pop(0) + if len(command) > 1: + command[0](command[1]) + else: + command[0]() + else: + print "Finished all commands" -def main(): - # Set up command line options. - usage = u'Usage: %prog [options]' - parser = OptionParser(usage=usage) - parser.add_option("-d", "--download-ts", action="store_true", - dest="download", help="Load languages from Pootle Server") - parser.add_option("-p", "--prepare", action="store_true", dest="prepare", - help="preparation (generate pro file)") - parser.add_option("-u", "--update", action="store_true", dest="update", - help="update translation files") - parser.add_option("-g", "--generate", action="store_true", dest="generate", - help="generate qm files") - parser.add_option("-a", "--all", action="store_true", dest="all", - help="proceed all options") - (options, args) = parser.parse_args() - if options.download: - downloadTranslations() - elif options.prepare: - preparation() - elif options.update: - update() - elif options.generate: - generate() - elif options.all: - all() - else: - pass + def downloadTranslations(self): + print 'Download Translation files from HQ-Server' + page = urllib.urlopen(u'%s' % (self.server_url)) + soup = BeautifulSoup(page) + languages = soup.findAll(text=re.compile(".*\.ts")) + for language in languages: + filename = os.path.join(u'..', u'resources', u'i18n', + u'openlp_%s' % language) + self.printVerbose(u'Get Translation File: %s' % filename) + self.get_and_write_file(language, filename) + print u' done' + self.process_stack() -def downloadTranslations(): - print "download()" - for language in translations: - filename = os.path.join(u'..', u'resources', u'i18n', - u"openlp_%s.ts" % language) - print filename - page = urllib.urlopen(u"%s%s.ts" % (translation_path, language)) - content = page.read().decode("utf8") + def get_and_write_file(self, language, filename): + page = urllib.urlopen(u'%s%s' % (self.server_url, language)) + content = page.read().decode('utf8') page.close() file = open(filename, u'w') file.write(content.encode('utf8')) file.close() - -def preparation(): - stringlist = [] - start_dir = os.path.join(u'..') - for root, dirs, files in os.walk(start_dir): - for file in files: - path = u"%s" % root - path = path.replace("\\","/") - path = path.replace("..",".") - if file.startswith(u'hook-') or file.startswith(u'test_'): - continue + def creation(self, language): + print "Create new Translation File" + """ + Use this option to create a new translation file + this function: + * create the new *.ts file + """ + filename = os.path.join(u'..', u'resources', u'i18n', + u'openlp_%s.ts' % language) + self.get_and_write_file(u'en.ts', filename) + self.printVerbose(""" + Please remind: For permanent providing this language: + this language name have to append to the global list + variable "translations" in this file + and this file have to be uploaded to the Pootle Server + Please contact the developers! + """) + print u' done' + self.process_stack() + + + def preparation(self): + print u'Generating the openlp.pro file' + stringlist = [] + start_dir = os.path.join(u'..') + for root, dirs, files in os.walk(start_dir): + for file in files: + path = u'%s' % root + path = path.replace('\\','/') + path = path.replace('..','.') + + if file.startswith(u'hook-') or file.startswith(u'test_'): + continue - cond = False - for search in ignore_pathes: - if path.startswith(search): - cond = True - if cond: - continue - cond = False - for search in ignore_files: - if search == file: - cond = True - if cond: - continue - - if file.endswith(u'.py'): - line = u"%s/%s" % (path, file) - print u'Parsing "%s"' % line - stringlist.append(u"SOURCES += %s" % line) - elif file.endswith(u'.pyw'): - line = u"%s/%s" % (path, file) - print u'Parsing "%s"' % line - stringlist.append(u"SOURCES += %s" % line) - elif file.endswith(u'.ts'): - line = u"%s/%s" % (path, file) - print u'Parsing "%s"' % line - stringlist.append(u"TRANSLATIONS += %s" % line) - - print u'Generating PRO file...', - stringlist.sort() - write_file(os.path.join(start_dir, u'openlp.pro'), stringlist) - print u'done.' + cond = False + for search in self.ignore_paths: + if path.startswith(search): + cond = True + if cond: + continue + cond = False + for search in self.ignore_files: + if search == file: + cond = True + if cond: + continue + + if file.endswith(u'.py'): + line = u'%s/%s' % (path, file) + self.printVerbose(u'Parsing "%s"' % line) + stringlist.append(u'SOURCES += %s' % line) + elif file.endswith(u'.pyw'): + line = u'%s/%s' % (path, file) + self.printVerbose(u'Parsing "%s"' % line) + stringlist.append(u'SOURCES += %s' % line) + elif file.endswith(u'.ts'): + line = u'%s/%s' % (path, file) + self.printVerbose(u'Parsing "%s"' % line) + stringlist.append(u'TRANSLATIONS += %s' % line) + + stringlist.sort() + self.write_file(os.path.join(start_dir, u'openlp.pro'), stringlist) + print u' done' + self.process_stack() -def update(): - print "update()" - updateProcess = QtCore.QProcess() - updateProcess.start(u"pylupdate4 -noobsolete ../openlp.pro") - updateProcess.waitForFinished(60000) + def update(self): + print u'Update the translation files' + cmd = u'pylupdate4 -verbose -noobsolete ../openlp.pro' + self.start_cmd(cmd) -def generate(): - print "generate()" - generateProcess = QtCore.QProcess() - generateProcess.start(u"lrelease ../openlp.pro") - generateProcess.waitForFinished(60000) + def generate(self): + print u'Generate the related *.qm files' + cmd = u'lrelease ../openlp.pro' + self.start_cmd(cmd) + + def write_file(self, filename, stringlist): + content = u'' + for line in stringlist: + content = u'%s%s\n' % (content, line) + file = open(filename, u'w') + file.write(content.encode('utf8')) + file.close() -def all(): - print "all()" - downloadTranslations() - preparation() - update() - generate() + def printVerbose(self, data): + if self.verbose: + print u' %s' % data + + def start_cmd(self, command): + self.printVerbose(command) + self.process = QtCore.QProcess() + self.process.start(command) + while (self.process.waitForReadyRead()): + self.printVerbose(u'ReadyRead: %s' % QtCore.QString(self.process.readAll())) + self.printVerbose(self.process.readAllStandardError()) + self.printVerbose(self.process.readAllStandardOutput()) + print u' done' + self.process_stack() + + +def main(): + # start Main Class + Util = TranslationUtils() + + # Set up command line options. + usage = u''' + This script handle the translation files for OpenLP. + Usage: %prog [options] + If no option will be used, options "-d -p -u -g" will be set automatically + ''' + parser = OptionParser(usage=usage) + parser.add_option('-d', '--download-ts', action='store_true', + dest='download', help='Load languages from Pootle Server') + parser.add_option('-c', '--create', metavar='lang', + help='creation of new translation file, Parameter: language (e.g. "en_GB"') + parser.add_option('-p', '--prepare', action='store_true', dest='prepare', + help='preparation (generate pro file)') + parser.add_option('-u', '--update', action='store_true', dest='update', + help='update translation files') + parser.add_option('-g', '--generate', action='store_true', dest='generate', + help='generate qm files') + parser.add_option('-v', '--verbose', action='store_true', dest='verbose', + help='Give more informations while processing') + + (options, args) = parser.parse_args() + if options.download: + Util.cmd_stack.append([Util.downloadTranslations]) + if options.create: + Util.cmd_stack.append([Util.creation, u'%s' % options.create]) + if options.prepare: + Util.cmd_stack.append([Util.preparation]) + if options.update: + Util.cmd_stack.append([Util.update]) + if options.generate: + Util.cmd_stack.append([Util.generate]) + if options.verbose: + Util.verbose = True + + if len(Util.cmd_stack) == 0: + Util.cmd_stack.append([Util.downloadTranslations]) + Util.cmd_stack.append([Util.preparation]) + Util.cmd_stack.append([Util.update]) + Util.cmd_stack.append([Util.generate]) + + Util.stack_count = len(Util.cmd_stack) + Util.process_stack() + if __name__ == u'__main__':