Fixed exception thrown on unchecking 'Auto detect' in languages menu

Fixed saving of language setting
Added pinging of review page in translation_util.py

bzr-revno: 1056
This commit is contained in:
Christian Richter 2010-09-24 19:51:21 +02:00 committed by Raoul Snyman
commit 70f8795d61
5 changed files with 47 additions and 19 deletions

View File

@ -343,7 +343,7 @@ class Ui_MainWindow(object):
Set up the translation system Set up the translation system
""" """
MainWindow.mainTitle = translate('OpenLP.MainWindow', 'OpenLP 2.0') MainWindow.mainTitle = translate('OpenLP.MainWindow', 'OpenLP 2.0')
MainWindow.language = translate('OpenLP.MainWindow', 'English') # MainWindow.language = translate('OpenLP.MainWindow', 'English')
MainWindow.setWindowTitle(MainWindow.mainTitle) MainWindow.setWindowTitle(MainWindow.mainTitle)
self.FileMenu.setTitle(translate('OpenLP.MainWindow', '&File')) self.FileMenu.setTitle(translate('OpenLP.MainWindow', '&File'))
self.FileImportMenu.setTitle(translate('OpenLP.MainWindow', '&Import')) self.FileImportMenu.setTitle(translate('OpenLP.MainWindow', '&Import'))

View File

@ -82,7 +82,8 @@ class LanguageManager(object):
""" """
translator = QtCore.QTranslator() translator = QtCore.QTranslator()
translator.load(qm_file) translator.load(qm_file)
return translator.translate('OpenLP.MainWindow', 'English') return translator.translate('OpenLP.MainWindow', 'English',
'Please add the name of your language here')
@staticmethod @staticmethod
def get_language(): def get_language():
@ -107,15 +108,13 @@ class LanguageManager(object):
``action`` ``action``
The language menu option The language menu option
""" """
if action is None: language = u'en'
action_name = u'en' if action:
else:
action_name = u'%s' % action.objectName() action_name = u'%s' % action.objectName()
qm_list = LanguageManager.get_qm_list() qm_list = LanguageManager.get_qm_list()
if LanguageManager.auto_language:
language = u'[%s]' % qm_list[action_name]
else:
language = u'%s' % qm_list[action_name] language = u'%s' % qm_list[action_name]
if LanguageManager.auto_language:
language = u'[%s]' % language
QtCore.QSettings().setValue( QtCore.QSettings().setValue(
u'general/language', QtCore.QVariant(language)) u'general/language', QtCore.QVariant(language))
log.info(u'Language file: \'%s\' written to conf file' % language) log.info(u'Language file: \'%s\' written to conf file' % language)
@ -132,9 +131,11 @@ class LanguageManager(object):
LanguageManager.__qm_list__ = {} LanguageManager.__qm_list__ = {}
qm_files = LanguageManager.find_qm_files() qm_files = LanguageManager.find_qm_files()
for counter, qmf in enumerate(qm_files): for counter, qmf in enumerate(qm_files):
name = unicode(qmf).split(u'.')[0] reg_ex = QtCore.QRegExp("^.*i18n/(.*).qm")
LanguageManager.__qm_list__[u'%#2i %s' % (counter + 1, if reg_ex.exactMatch(qmf):
LanguageManager.language_name(qmf))] = name name = u'%s' % reg_ex.cap(1)
LanguageManager.__qm_list__[u'%#2i %s' % (counter + 1,
LanguageManager.language_name(qmf))] = name
@staticmethod @staticmethod
def get_qm_list(): def get_qm_list():

0
openlp/plugins/songs/lib/test/test3.opensong Executable file → Normal file
View File

View File

@ -1,11 +1,21 @@
#!/usr/bin/env xdg-open
[Desktop Entry] [Desktop Entry]
Categories=AudioVideo;
Comment[de]=
Comment=
Encoding=UTF-8 Encoding=UTF-8
Name=OpenLP
GenericName=Church lyrics projection
Exec=openlp Exec=openlp
GenericName[de]=Church lyrics projection
GenericName=Church lyrics projection
Icon=openlp Icon=openlp
MimeType=
Name[de]=OpenLP
Name=OpenLP
Path=
StartupNotify=true StartupNotify=true
Terminal=false Terminal=false
TerminalOptions=
Type=Application Type=Application
Categories=AudioVideo; X-DBUS-ServiceName=
X-DBUS-StartupType=
X-KDE-SubstituteUID=false
X-KDE-Username=

View File

@ -157,6 +157,21 @@ def run(command):
print_verbose(u'Output:\n%s' % process.readAllStandardOutput()) print_verbose(u'Output:\n%s' % process.readAllStandardOutput())
print u' Done.' print u' Done.'
def update_export_at_pootle(source_filename):
"""
This is needed because of database and exported *.ts file can be out of sync
``source_filename``
The file to sync.
"""
language = source_filename[:-3]
REVIEW_URL = u'http://pootle.projecthq.biz/%s/openlp/review.html' % language
print_verbose(u'Accessing: %s' % (REVIEW_URL))
page = urllib.urlopen(REVIEW_URL)
page.close()
def download_file(source_filename, dest_filename): def download_file(source_filename, dest_filename):
""" """
Download a file and save it to disk. Download a file and save it to disk.
@ -183,11 +198,13 @@ def download_translations():
page = urllib.urlopen(SERVER_URL) page = urllib.urlopen(SERVER_URL)
soup = BeautifulSoup(page) soup = BeautifulSoup(page)
languages = soup.findAll(text=re.compile(r'.*\.ts')) languages = soup.findAll(text=re.compile(r'.*\.ts'))
for language in languages: for language_file in languages:
update_export_at_pootle(language_file)
for language_file in languages:
filename = os.path.join(os.path.abspath(u'..'), u'resources', u'i18n', filename = os.path.join(os.path.abspath(u'..'), u'resources', u'i18n',
language) language_file)
print_verbose(u'Get Translation File: %s' % filename) print_verbose(u'Get Translation File: %s' % filename)
download_file(language, filename) download_file(language_file, filename)
print u' Done.' print u' Done.'
def prepare_project(): def prepare_project():