update i18n implementation

This commit is contained in:
rimach 2010-04-17 00:06:28 +02:00
parent 95998f456a
commit ea64675d65
17 changed files with 323 additions and 3590 deletions

View File

@ -37,7 +37,7 @@ log = logging.getLogger()
from openlp.core.lib import Receiver, str_to_bool
from openlp.core.resources import qInitResources
from openlp.core.ui import MainWindow, SplashScreen, ScreenList
from openlp.core.utils import AppLocation, ConfigHelper
from openlp.core.utils import AppLocation, ConfigHelper, LanguageManager
application_stylesheet = u"""
QMainWindow::separator
@ -193,17 +193,10 @@ def main():
qInitResources()
# Now create and actually run the application.
app = OpenLP(qt_args)
lang_Path = AppLocation.get_directory(AppLocation.AppDir)
if hasattr(sys, u'frozen'):
lang_Path = os.path.join(lang_Path, u'..')
lang_Path = os.path.join(lang_Path, u'resources', u'i18n')
locale = QtCore.QLocale.system().name()
qtTranslator = QtCore.QTranslator()
if qtTranslator.load("openlp_" + locale, lang_Path):
app.installTranslator(qtTranslator)
appTranslator = QtCore.QTranslator()
if appTranslator.load("openlp_" + locale, lang_Path):
app.installTranslator(appTranslator)
#i18n Set Language
language = LanguageManager.getLanguage()
appTranslator = LanguageManager.getTranslator(language)
app.installTranslator(appTranslator)
sys.exit(app.run())

View File

@ -117,10 +117,13 @@ class OpenLPToolbar(QtGui.QToolBar):
The title of the icon to search for.
"""
title = QtCore.QString(title)
if self.icons[title]:
return self.icons[title]
else:
log.error(u'getIconFromTitle - no icon for %s' % title)
try:
if self.icons[title]:
return self.icons[title]
else:
log.error(u'getIconFromTitle - no icon for %s' % title)
return QtGui.QIcon()
except:
return QtGui.QIcon()
def makeWidgetsInvisible(self, widgets):

View File

@ -33,7 +33,7 @@ from openlp.core.ui import AboutForm, SettingsForm, \
PluginForm, MediaDockManager, VideoDisplay
from openlp.core.lib import RenderManager, PluginConfig, build_icon, \
OpenLPDockWidget, SettingsManager, PluginManager, Receiver, str_to_bool
from openlp.core.utils import check_latest_version, AppLocation
from openlp.core.utils import check_latest_version, AppLocation, LanguageManager, ConfigHelper
log = logging.getLogger(__name__)
@ -190,19 +190,19 @@ class Ui_MainWindow(object):
self.ThemeManagerDock.setVisible(self.settingsmanager.showThemeManager)
# Create the menu items
self.FileNewItem = QtGui.QAction(MainWindow)
#self.FileNewItem.setIcon(
# self.ServiceManagerContents.Toolbar.getIconFromTitle(
# u'New Service'))
self.FileNewItem.setIcon(
self.ServiceManagerContents.Toolbar.getIconFromTitle(
MainWindow.trUtf8('New Service')))
self.FileNewItem.setObjectName(u'FileNewItem')
self.FileOpenItem = QtGui.QAction(MainWindow)
#self.FileOpenItem.setIcon(
# self.ServiceManagerContents.Toolbar.getIconFromTitle(
# u'Open Service'))
self.FileOpenItem.setIcon(
self.ServiceManagerContents.Toolbar.getIconFromTitle(
MainWindow.trUtf8('Open Service')))
self.FileOpenItem.setObjectName(u'FileOpenItem')
self.FileSaveItem = QtGui.QAction(MainWindow)
#self.FileSaveItem.setIcon(
# self.ServiceManagerContents.Toolbar.getIconFromTitle(
# u'Save Service'))
self.FileSaveItem.setIcon(
self.ServiceManagerContents.Toolbar.getIconFromTitle(
MainWindow.trUtf8('Save Service')))
self.FileSaveItem.setObjectName(u'FileSaveItem')
self.FileSaveAsItem = QtGui.QAction(MainWindow)
self.FileSaveAsItem.setObjectName(u'FileSaveAsItem')
@ -257,10 +257,26 @@ class Ui_MainWindow(object):
self.HelpOnlineHelpItem.setObjectName(u'HelpOnlineHelpItem')
self.HelpWebSiteItem = QtGui.QAction(MainWindow)
self.HelpWebSiteItem.setObjectName(u'HelpWebSiteItem')
self.LanguageTranslateItem = QtGui.QAction(MainWindow)
self.LanguageTranslateItem.setObjectName(u'LanguageTranslateItem')
self.LanguageEnglishItem = QtGui.QAction(MainWindow)
self.LanguageEnglishItem.setObjectName(u'LanguageEnglishItem')
#i18n Language Items
self.AutoLanguageItem = QtGui.QAction(MainWindow)
self.AutoLanguageItem.setObjectName(u'AutoLanguageItem')
self.AutoLanguageItem.setCheckable(True)
self.LanguageGroup = QtGui.QActionGroup(MainWindow)
qmList = LanguageManager.getQmList()
savedLanguage = LanguageManager.getLanguage()
self.LanguageItem = {}
for key in qmList.keys():
self.LanguageItem[key] = QtGui.QAction(MainWindow)
self.LanguageItem[key].setObjectName(key)
self.LanguageItem[key].setCheckable(True)
if LanguageManager.__AutoLanguage__ == True:
self.AutoLanguageItem.setChecked(True)
self.LanguageGroup.setEnabled(False)
else:
self.AutoLanguageItem.setChecked(False)
self.LanguageGroup.setEnabled(True)
if qmList[key] == savedLanguage:
self.LanguageItem[key].setChecked(True)
self.ToolsAddToolItem = QtGui.QAction(MainWindow)
AddToolIcon = build_icon(u':/tools/tools_add.png')
self.ToolsAddToolItem.setIcon(AddToolIcon)
@ -295,9 +311,12 @@ class Ui_MainWindow(object):
self.OptionsViewMenu.addAction(self.ViewThemeManagerItem)
self.OptionsViewMenu.addSeparator()
self.OptionsViewMenu.addAction(self.action_Preview_Panel)
self.OptionsLanguageMenu.addAction(self.LanguageEnglishItem)
#i18n add Language Actions
self.OptionsLanguageMenu.addAction(self.AutoLanguageItem)
self.OptionsLanguageMenu.addSeparator()
self.OptionsLanguageMenu.addAction(self.LanguageTranslateItem)
for item in sorted(self.LanguageItem):
self.LanguageGroup.addAction(self.LanguageItem[item])
self.OptionsLanguageMenu.addAction(self.LanguageItem[item])
self.OptionsMenu.addAction(self.OptionsLanguageMenu.menuAction())
self.OptionsMenu.addAction(self.OptionsViewMenu.menuAction())
self.OptionsMenu.addSeparator()
@ -335,95 +354,98 @@ class Ui_MainWindow(object):
"""
Set up the translation system
"""
MainWindow.mainTitle = self.trUtf8('OpenLP 2.0')
MainWindow.defaultThemeText = self.trUtf8(
MainWindow.mainTitle = MainWindow.trUtf8('OpenLP 2.0')
MainWindow.language = MainWindow.trUtf8('English')
MainWindow.defaultThemeText = MainWindow.trUtf8(
'Default Theme: ')
MainWindow.setWindowTitle(MainWindow.mainTitle)
self.FileMenu.setTitle(self.trUtf8('&File'))
self.FileImportMenu.setTitle(self.trUtf8('&Import'))
self.FileExportMenu.setTitle(self.trUtf8('&Export'))
self.OptionsMenu.setTitle(self.trUtf8('&Options'))
self.OptionsViewMenu.setTitle(self.trUtf8('&View'))
self.ViewModeMenu.setTitle(self.trUtf8('M&ode'))
self.OptionsLanguageMenu.setTitle(self.trUtf8(
self.FileMenu.setTitle(MainWindow.trUtf8('&File'))
self.FileImportMenu.setTitle(MainWindow.trUtf8('&Import'))
self.FileExportMenu.setTitle(MainWindow.trUtf8('&Export'))
self.OptionsMenu.setTitle(MainWindow.trUtf8('&Options'))
self.OptionsViewMenu.setTitle(MainWindow.trUtf8('&View'))
self.ViewModeMenu.setTitle(MainWindow.trUtf8('M&ode'))
self.OptionsLanguageMenu.setTitle(MainWindow.trUtf8(
u'&Language'))
self.ToolsMenu.setTitle(self.trUtf8('&Tools'))
self.HelpMenu.setTitle(self.trUtf8('&Help'))
self.ToolsMenu.setTitle(MainWindow.trUtf8('&Tools'))
self.HelpMenu.setTitle(MainWindow.trUtf8('&Help'))
self.MediaManagerDock.setWindowTitle(
self.trUtf8('Media Manager'))
MainWindow.trUtf8('Media Manager'))
self.ServiceManagerDock.setWindowTitle(
self.trUtf8('Service Manager'))
MainWindow.trUtf8('Service Manager'))
self.ThemeManagerDock.setWindowTitle(
self.trUtf8('Theme Manager'))
self.FileNewItem.setText(self.trUtf8('&New'))
self.FileNewItem.setToolTip(self.trUtf8('New Service'))
self.FileNewItem.setStatusTip(self.trUtf8('Create a new Service'))
self.FileNewItem.setShortcut(self.trUtf8('Ctrl+N'))
self.FileOpenItem.setText(self.trUtf8('&Open'))
self.FileOpenItem.setToolTip(self.trUtf8('Open Service'))
self.FileOpenItem.setStatusTip(self.trUtf8('Open an existing service'))
self.FileOpenItem.setShortcut(self.trUtf8('Ctrl+O'))
self.FileSaveItem.setText(self.trUtf8('&Save'))
self.FileSaveItem.setToolTip(self.trUtf8('Save Service'))
MainWindow.trUtf8('Theme Manager'))
self.FileNewItem.setText(MainWindow.trUtf8('&New'))
self.FileNewItem.setToolTip(MainWindow.trUtf8('New Service'))
self.FileNewItem.setStatusTip(MainWindow.trUtf8('Create a new Service'))
self.FileNewItem.setShortcut(MainWindow.trUtf8('Ctrl+N'))
self.FileOpenItem.setText(MainWindow.trUtf8('&Open'))
self.FileOpenItem.setToolTip(MainWindow.trUtf8('Open Service'))
self.FileOpenItem.setStatusTip(MainWindow.trUtf8('Open an existing service'))
self.FileOpenItem.setShortcut(MainWindow.trUtf8('Ctrl+O'))
self.FileSaveItem.setText(MainWindow.trUtf8('&Save'))
self.FileSaveItem.setToolTip(MainWindow.trUtf8('Save Service'))
self.FileSaveItem.setStatusTip(
self.trUtf8('Save the current service to disk'))
self.FileSaveItem.setShortcut(self.trUtf8('Ctrl+S'))
self.FileSaveAsItem.setText(self.trUtf8('Save &As...'))
self.FileSaveAsItem.setToolTip(self.trUtf8('Save Service As'))
MainWindow.trUtf8('Save the current service to disk'))
self.FileSaveItem.setShortcut(MainWindow.trUtf8('Ctrl+S'))
self.FileSaveAsItem.setText(MainWindow.trUtf8('Save &As...'))
self.FileSaveAsItem.setToolTip(MainWindow.trUtf8('Save Service As'))
self.FileSaveAsItem.setStatusTip(
self.trUtf8('Save the current service under a new name'))
self.FileSaveAsItem.setShortcut(self.trUtf8('F12'))
self.FileExitItem.setText(self.trUtf8('E&xit'))
self.FileExitItem.setStatusTip(self.trUtf8('Quit OpenLP'))
self.FileExitItem.setShortcut(self.trUtf8('Alt+F4'))
self.ImportThemeItem.setText(self.trUtf8('&Theme'))
self.ImportLanguageItem.setText(self.trUtf8('&Language'))
self.ExportThemeItem.setText(self.trUtf8('&Theme'))
self.ExportLanguageItem.setText(self.trUtf8('&Language'))
self.actionLook_Feel.setText(self.trUtf8('Look && &Feel'))
self.OptionsSettingsItem.setText(self.trUtf8('&Settings'))
self.ViewMediaManagerItem.setText(self.trUtf8('&Media Manager'))
self.ViewMediaManagerItem.setToolTip(self.trUtf8('Toggle Media Manager'))
MainWindow.trUtf8('Save the current service under a new name'))
self.FileSaveAsItem.setShortcut(MainWindow.trUtf8('F12'))
self.FileExitItem.setText(MainWindow.trUtf8('E&xit'))
self.FileExitItem.setStatusTip(MainWindow.trUtf8('Quit OpenLP'))
self.FileExitItem.setShortcut(MainWindow.trUtf8('Alt+F4'))
self.ImportThemeItem.setText(MainWindow.trUtf8('&Theme'))
self.ImportLanguageItem.setText(MainWindow.trUtf8('&Language'))
self.ExportThemeItem.setText(MainWindow.trUtf8('&Theme'))
self.ExportLanguageItem.setText(MainWindow.trUtf8('&Language'))
self.actionLook_Feel.setText(MainWindow.trUtf8('Look && &Feel'))
self.OptionsSettingsItem.setText(MainWindow.trUtf8('&Settings'))
self.ViewMediaManagerItem.setText(MainWindow.trUtf8('&Media Manager'))
self.ViewMediaManagerItem.setToolTip(MainWindow.trUtf8('Toggle Media Manager'))
self.ViewMediaManagerItem.setStatusTip(
self.trUtf8('Toggle the visibility of the Media Manager'))
self.ViewMediaManagerItem.setShortcut(self.trUtf8('F8'))
self.ViewThemeManagerItem.setText(self.trUtf8('&Theme Manager'))
self.ViewThemeManagerItem.setToolTip(self.trUtf8('Toggle Theme Manager'))
MainWindow.trUtf8('Toggle the visibility of the Media Manager'))
self.ViewMediaManagerItem.setShortcut(MainWindow.trUtf8('F8'))
self.ViewThemeManagerItem.setText(MainWindow.trUtf8('&Theme Manager'))
self.ViewThemeManagerItem.setToolTip(MainWindow.trUtf8('Toggle Theme Manager'))
self.ViewThemeManagerItem.setStatusTip(
self.trUtf8('Toggle the visibility of the Theme Manager'))
self.ViewThemeManagerItem.setShortcut(self.trUtf8('F10'))
self.ViewServiceManagerItem.setText(self.trUtf8('&Service Manager'))
MainWindow.trUtf8('Toggle the visibility of the Theme Manager'))
self.ViewThemeManagerItem.setShortcut(MainWindow.trUtf8('F10'))
self.ViewServiceManagerItem.setText(MainWindow.trUtf8('&Service Manager'))
self.ViewServiceManagerItem.setToolTip(
self.trUtf8('Toggle Service Manager'))
MainWindow.trUtf8('Toggle Service Manager'))
self.ViewServiceManagerItem.setStatusTip(
self.trUtf8('Toggle the visibility of the Service Manager'))
self.ViewServiceManagerItem.setShortcut(self.trUtf8('F9'))
self.action_Preview_Panel.setText(self.trUtf8('&Preview Panel'))
self.action_Preview_Panel.setToolTip(self.trUtf8('Toggle Preview Panel'))
MainWindow.trUtf8('Toggle the visibility of the Service Manager'))
self.ViewServiceManagerItem.setShortcut(MainWindow.trUtf8('F9'))
self.action_Preview_Panel.setText(MainWindow.trUtf8('&Preview Panel'))
self.action_Preview_Panel.setToolTip(MainWindow.trUtf8('Toggle Preview Panel'))
self.action_Preview_Panel.setStatusTip(
self.trUtf8('Toggle the visibility of the Preview Panel'))
self.action_Preview_Panel.setShortcut(self.trUtf8('F11'))
self.PluginItem.setText(self.trUtf8('&Plugin List'))
self.PluginItem.setStatusTip(self.trUtf8('List the Plugins'))
self.PluginItem.setShortcut(self.trUtf8('Alt+F7'))
self.HelpDocumentationItem.setText(self.trUtf8('&User Guide'))
self.HelpAboutItem.setText(self.trUtf8('&About'))
MainWindow.trUtf8('Toggle the visibility of the Preview Panel'))
self.action_Preview_Panel.setShortcut(MainWindow.trUtf8('F11'))
self.PluginItem.setText(MainWindow.trUtf8('&Plugin List'))
self.PluginItem.setStatusTip(MainWindow.trUtf8('List the Plugins'))
self.PluginItem.setShortcut(MainWindow.trUtf8('Alt+F7'))
self.HelpDocumentationItem.setText(MainWindow.trUtf8('&User Guide'))
self.HelpAboutItem.setText(MainWindow.trUtf8('&About'))
self.HelpAboutItem.setStatusTip(
self.trUtf8('More information about OpenLP'))
self.HelpAboutItem.setShortcut(self.trUtf8('Ctrl+F1'))
self.HelpOnlineHelpItem.setText(self.trUtf8('&Online Help'))
self.HelpWebSiteItem.setText(self.trUtf8('&Web Site'))
self.LanguageTranslateItem.setText(self.trUtf8('&Translate'))
self.LanguageTranslateItem.setStatusTip(
self.trUtf8('Translate the interface to your language'))
self.LanguageEnglishItem.setText(self.trUtf8('English'))
self.LanguageEnglishItem.setStatusTip(
self.trUtf8('Set the interface language to English'))
self.ToolsAddToolItem.setText(self.trUtf8('Add &Tool...'))
MainWindow.trUtf8('More information about OpenLP'))
self.HelpAboutItem.setShortcut(MainWindow.trUtf8('Ctrl+F1'))
self.HelpOnlineHelpItem.setText(MainWindow.trUtf8('&Online Help'))
self.HelpWebSiteItem.setText(MainWindow.trUtf8('&Web Site'))
#i18n
self.AutoLanguageItem.setText(MainWindow.trUtf8('&Auto Detect'))
self.AutoLanguageItem.setStatusTip(
MainWindow.trUtf8('Choose System language, if available'))
for item in self.LanguageItem:
self.LanguageItem[item].setText(self.LanguageItem[item].objectName())
self.LanguageItem[item].setStatusTip(
MainWindow.trUtf8('Set the interface language to %1').arg(self.LanguageItem[item].objectName()))
self.ToolsAddToolItem.setText(MainWindow.trUtf8('Add &Tool...'))
self.ToolsAddToolItem.setStatusTip(
self.trUtf8('Add an application to the list of tools'))
self.action_Preview_Panel.setText(self.trUtf8('&Preview Pane'))
self.ModeLiveItem.setText(self.trUtf8('&Live'))
MainWindow.trUtf8('Add an application to the list of tools'))
self.action_Preview_Panel.setText(MainWindow.trUtf8('&Preview Pane'))
self.ModeLiveItem.setText(MainWindow.trUtf8('&Live'))
class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
@ -511,6 +533,11 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
QtCore.QObject.connect(self.FileSaveAsItem,
QtCore.SIGNAL(u'triggered()'),
self.ServiceManagerContents.onSaveService)
#i18n set signals for languages
QtCore.QObject.connect(self.AutoLanguageItem,
QtCore.SIGNAL(u'toggled(bool)'),
self.setAutoLanguage)
self.LanguageGroup.triggered.connect(LanguageManager.setLanguage)
#warning cyclic dependency
#RenderManager needs to call ThemeManager and
#ThemeManager needs to call RenderManager
@ -552,6 +579,12 @@ class MainWindow(QtGui.QMainWindow, Ui_MainWindow):
log.info(u'Load data from Settings')
self.settingsForm.postSetUp()
#i18n
def setAutoLanguage(self, value):
self.LanguageGroup.setEnabled(not value)
LanguageManager.__AutoLanguage__ = value
LanguageManager.setLanguage(self.LanguageGroup.checkedAction())
def versionCheck(self, version):
"""
Checks the version of the Application called from openlp.pyw

View File

@ -151,5 +151,6 @@ def variant_to_unicode(variant):
from registry import Registry
from confighelper import ConfigHelper
from languagemanager import LanguageManager
__all__ = [u'Registry', u'ConfigHelper', u'AppLocation', u'check_latest_version']
__all__ = [u'Registry', u'ConfigHelper', u'AppLocation', u'LanguageManager', u'check_latest_version']

View File

@ -0,0 +1,106 @@
# -*- coding: utf-8 -*-
# vim: autoindent shiftwidth=4 expandtab textwidth=80 tabstop=4 softtabstop=4
###############################################################################
# OpenLP - Open Source Lyrics Projection #
# --------------------------------------------------------------------------- #
# Copyright (c) 2008-2010 Raoul Snyman #
# Portions copyright (c) 2008-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. #
# #
# This program is distributed in the hope that it will be useful, but WITHOUT #
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or #
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for #
# more details. #
# #
# You should have received a copy of the GNU General Public License along #
# with this program; if not, write to the Free Software Foundation, Inc., 59 #
# Temple Place, Suite 330, Boston, MA 02111-1307 USA #
###############################################################################
import logging
from PyQt4 import QtCore, QtGui
import os
from openlp.core.utils import AppLocation, ConfigHelper
#from openlp.core.ui import MainWindow
#import i18n_rc
class LanguageManager(object):
"""
Helper for Language selection
"""
__qmList__ = None
__AutoLanguage__ = None
@staticmethod
def getTranslator(language):
if LanguageManager.__AutoLanguage__ is True:
language = QtCore.QLocale.system().name()
lang_Path = AppLocation.get_directory(AppLocation.AppDir)
lang_Path = os.path.join(lang_Path, u'resources', u'i18n')
appTranslator = QtCore.QTranslator()
if appTranslator.load("openlp_" + language, lang_Path):
return appTranslator
@staticmethod
def findQmFiles():
trans_dir = AppLocation.get_directory(AppLocation.AppDir)
trans_dir = QtCore.QDir(os.path.join(trans_dir, u'resources', u'i18n'))
fileNames = trans_dir.entryList(QtCore.QStringList("*.qm"),
QtCore.QDir.Files, QtCore.QDir.Name)
for i in fileNames:
fileNames.replaceInStrings(i, trans_dir.filePath(i))
return fileNames
@staticmethod
def languageName(qmFile):
translator = QtCore.QTranslator()
translator.load(qmFile)
return translator.translate(u'MainWindow', u'English')
@staticmethod
def getLanguage():
language = ConfigHelper.get_registry().get_value(u'general', u'language', u'[en]')
print "getLanguage %s" % language
regEx = QtCore.QRegExp("^\[(.*)\]")
if regEx.exactMatch(language):
LanguageManager.__AutoLanguage__ = True
language = regEx.cap(1)
return language
@staticmethod
def setLanguage(action):
actionName = u'%s' % action.objectName()
qmList = LanguageManager.getQmList()
if LanguageManager.__AutoLanguage__ == True:
language = u'[%s]' % qmList[actionName]
else:
language = u'%s' % qmList[actionName]
print "setLanguage: %s" % language
ConfigHelper.set_config(u'general', u'language', language)
QtGui.QMessageBox.information(None,
u'Language', u'After restart new Language settings will be used.')
@staticmethod
def initQmList():
LanguageManager.__qmList__ = {}
qmFiles = LanguageManager.findQmFiles()
for i, qmf in enumerate(qmFiles):
regEx = QtCore.QRegExp("^.*openlp_(.*).qm")
if regEx.exactMatch(qmf):
langName = regEx.cap(1)
LanguageManager.__qmList__[u'%i %s' % (i, LanguageManager.languageName(qmf))] = langName
@staticmethod
def getQmList():
if LanguageManager.__qmList__ == None:
LanguageManager.initQmList()
return LanguageManager.__qmList__

BIN
resources/i18n/openlp_af.qm Normal file

Binary file not shown.

BIN
resources/i18n/openlp_de.qm Normal file

Binary file not shown.

File diff suppressed because it is too large Load Diff

Binary file not shown.

Binary file not shown.

BIN
resources/i18n/openlp_es.qm Normal file

Binary file not shown.

BIN
resources/i18n/openlp_hu.qm Normal file

Binary file not shown.

BIN
resources/i18n/openlp_ko.qm Normal file

Binary file not shown.

BIN
resources/i18n/openlp_nb.qm Normal file

Binary file not shown.

Binary file not shown.

BIN
resources/i18n/openlp_sv.qm Normal file

Binary file not shown.

View File

@ -36,10 +36,26 @@
###############################################################################
import os
from optparse import OptionParser
import urllib
from PyQt4 import QtCore
ignore_pathes = ["./scripts", "./openlp/core/test"]
ignore_files = ["setup.py"]
translation_path = "http://pootle.projecthq.biz/export/openlp/"
translations = [ "af"
, "en_ZA"
, "en_GB"
, "de"
, "hu"
, "ko"
, "nb"
, "pt_BR"
, "es"
, "sv"]
def write_file(filename, stringlist):
content = u''
for line in stringlist:
@ -49,6 +65,48 @@ def write_file(filename, stringlist):
file.close()
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()
qt_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():
print "download()"
for language in translations:
filename = os.path.join('..','resources', 'i18n', "openlp_%s.ts" % language)
print filename
page = urllib.urlopen("%s%s.ts" % (translation_path, 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):
@ -73,10 +131,6 @@ def main():
if cond == True:
continue
# if file.endswith(u'.ui'):
# line = "%s/%s" % (path, file)
# print u'Parsing "%s"' % line
# stringlist.append("FORMS += %s" % line)
if file.endswith(u'.py'):
line = "%s/%s" % (path, file)
print u'Parsing "%s"' % line
@ -95,6 +149,27 @@ def main():
write_file(os.path.join(start_dir, u'openlp.pro'), stringlist)
print u'done.'
def update():
print "update()"
updateProcess = QtCore.QProcess()
updateProcess.start("pylupdate4 -noobsolete ../openlp.pro")
updateProcess.waitForFinished(60000)
def generate():
print "generate()"
generateProcess = QtCore.QProcess()
generateProcess.start("lrelease ../openlp.pro")
generateProcess.waitForFinished(60000)
def all():
print "all()"
downloadTranslations()
preparation()
update()
generate()
if __name__ == u'__main__':
if os.path.split(os.path.abspath(u'.'))[1] != u'scripts':
print u'You need to run this script from the scripts directory.'