diff --git a/setup/translations.py b/setup/translations.py index 4f5b8cd417..412e35d439 100644 --- a/setup/translations.py +++ b/setup/translations.py @@ -11,7 +11,6 @@ from distutils import sysconfig from functools import partial from setup import Command, __appname__, __version__ -from setup.build_environment import pyqt def qt_sources(): qtdir = glob.glob('/usr/src/qt-*')[-1] @@ -20,7 +19,7 @@ def qt_sources(): 'src/gui/widgets/qdialogbuttonbox.cpp', ])) -class POT(Command): +class POT(Command): # {{{ description = 'Update the .pot translation template' PATH = os.path.join(Command.SRC, __appname__, 'translations') @@ -121,7 +120,7 @@ class POT(Command): return pot - +# }}} class Translations(POT): description='''Compile the translations''' @@ -135,7 +134,6 @@ class Translations(POT): locale = os.path.splitext(os.path.basename(po_file))[0] return locale, os.path.join(self.DEST, locale, 'messages.mo') - def run(self, opts): for f in self.po_files(): locale, dest = self.mo_file(f) @@ -144,7 +142,7 @@ class Translations(POT): os.makedirs(base) self.info('\tCompiling translations for', locale) subprocess.check_call(['msgfmt', '-o', dest, f]) - if locale in ('en_GB', 'nds', 'te', 'yi'): + if locale in ('en_GB', 'en_CA', 'en_AU', 'si', 'ur', 'sc', 'ltg', 'nds', 'te', 'yi'): continue pycountry = self.j(sysconfig.get_python_lib(), 'pycountry', 'locales', locale, 'LC_MESSAGES') @@ -158,17 +156,6 @@ class Translations(POT): self.warn('No ISO 639 translations for locale:', locale, '\nDo you have pycountry installed?') - base = os.path.join(pyqt.qt_data_dir, 'translations') - qt_translations = glob.glob(os.path.join(base, 'qt_*.qm')) - if not qt_translations: - raise Exception('Could not find qt translations') - for f in qt_translations: - locale = self.s(self.b(f))[0][3:] - dest = self.j(self.DEST, locale, 'LC_MESSAGES', 'qt.qm') - if self.e(self.d(dest)) and self.newer(dest, f): - self.info('\tCopying Qt translation for locale:', locale) - shutil.copy2(f, dest) - self.write_stats() self.freeze_locales() diff --git a/src/calibre/gui2/__init__.py b/src/calibre/gui2/__init__.py index dff5ee0ced..86cfff1254 100644 --- a/src/calibre/gui2/__init__.py +++ b/src/calibre/gui2/__init__.py @@ -15,7 +15,6 @@ APP_UID = 'libprs500' from calibre.constants import (islinux, iswindows, isbsd, isfrozen, isosx, config_dir) from calibre.utils.config import Config, ConfigProxy, dynamic, JSONConfig -from calibre.utils.localization import set_qt_translator from calibre.ebooks.metadata import MetaInformation from calibre.utils.date import UNDEFINED_DATE @@ -631,6 +630,18 @@ class ResizableDialog(QDialog): nw = min(self.width(), nw) self.resize(nw, nh) +class Translator(QTranslator): + + def translate(self, *args, **kwargs): + try: + src = unicode(args[1]) + except: + return u'' + t = _ + print 111111, src, t(src) + return t(src) + + gui_thread = None qt_app = None @@ -677,9 +688,8 @@ class Application(QApplication): def load_translations(self): if self._translator is not None: self.removeTranslator(self._translator) - self._translator = QTranslator(self) - if set_qt_translator(self._translator): - self.installTranslator(self._translator) + self._translator = Translator(self) + self.installTranslator(self._translator) def event(self, e): if callable(self.file_event_hook) and e.type() == QEvent.FileOpen: diff --git a/src/calibre/translations/calibre.pot b/src/calibre/translations/calibre.pot index db3c6e6a32..b98b91606d 100644 --- a/src/calibre/translations/calibre.pot +++ b/src/calibre/translations/calibre.pot @@ -5,8 +5,8 @@ msgid "" msgstr "" "Project-Id-Version: calibre 0.8.9\n" -"POT-Creation-Date: 2011-07-14 09:38+MDT\n" -"PO-Revision-Date: 2011-07-14 09:38+MDT\n" +"POT-Creation-Date: 2011-07-14 10:44+MDT\n" +"PO-Revision-Date: 2011-07-14 10:44+MDT\n" "Last-Translator: Automatically generated\n" "Language-Team: LANGUAGE\n" "MIME-Version: 1.0\n" @@ -129,8 +129,8 @@ msgstr "" #: /home/kovid/work/calibre/src/calibre/ebooks/pdf/writer.py:102 #: /home/kovid/work/calibre/src/calibre/ebooks/rtf/input.py:313 #: /home/kovid/work/calibre/src/calibre/ebooks/rtf/input.py:315 -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:377 -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:385 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:376 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:384 #: /home/kovid/work/calibre/src/calibre/gui2/actions/add.py:156 #: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:376 #: /home/kovid/work/calibre/src/calibre/gui2/actions/edit_metadata.py:379 @@ -3343,131 +3343,131 @@ msgstr "" msgid "Do not remove font color from output. This is only useful when txt-output-formatting is set to textile. Textile is the only formatting that supports setting font color. If this option is not specified font color will not be set and default to the color displayed by the reader (generally this is black)." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:113 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:112 msgid "Send file to storage card instead of main memory by default" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:115 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:114 msgid "Confirm before deleting" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:117 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:116 msgid "Main window geometry" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:119 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:118 msgid "Notify when a new version is available" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:121 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:120 msgid "Use Roman numerals for series number" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:123 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:122 msgid "Sort tags list by name, popularity, or rating" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:125 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:124 msgid "Match tags by any or all." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:127 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:126 msgid "Number of covers to show in the cover browsing mode" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:129 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:128 msgid "Defaults for conversion to LRF" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:131 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:130 msgid "Options for the LRF ebook viewer" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:134 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:133 msgid "Formats that are viewed using the internal viewer" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:136 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:135 msgid "Columns to be displayed in the book list" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:137 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:136 msgid "Automatically launch content server on application startup" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:138 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:137 msgid "Oldest news kept in database" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:139 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:138 msgid "Show system tray icon" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:141 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:140 msgid "Upload downloaded news to device" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:143 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:142 msgid "Delete books from library after uploading to device" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:145 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:144 msgid "Show the cover flow in a separate window instead of in the main calibre window" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:147 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:146 msgid "Disable notifications from the system tray icon" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:149 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:148 msgid "Default action to perform when send to device button is clicked" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:154 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:153 msgid "Start searching as you type. If this is disabled then search will only take place when the Enter or Return key is pressed." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:157 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:156 msgid "When searching, show all books with search results highlighted instead of showing only the matches. You can use the N or F3 keys to go to the next match." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:176 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:175 msgid "Maximum number of simultaneous conversion/news download jobs. This number is twice the actual value for historical reasons." msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:179 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:178 msgid "Download social metadata (tags/rating/etc.)" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:181 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:180 msgid "Overwrite author and title with new metadata" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:183 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:182 msgid "Automatically download the cover, if available" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:185 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:184 msgid "Limit max simultaneous jobs to number of CPUs" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:187 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:186 msgid "The layout of the user interface" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:189 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:188 msgid "Show the average rating per item indication in the tag browser" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:191 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:190 msgid "Disable UI animations" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:196 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:195 msgid "tag browser categories not to display" msgstr "" -#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:491 +#: /home/kovid/work/calibre/src/calibre/gui2/__init__.py:490 msgid "Choose Files" msgstr "" @@ -15787,6 +15787,22 @@ msgstr "" msgid "Dutch (BE)" msgstr "" +#: /home/kovid/work/calibre/src/calibre/utils/localization.py:152 +msgid "AM" +msgstr "" + +#: /home/kovid/work/calibre/src/calibre/utils/localization.py:153 +msgid "PM" +msgstr "" + +#: /home/kovid/work/calibre/src/calibre/utils/localization.py:154 +msgid "am" +msgstr "" + +#: /home/kovid/work/calibre/src/calibre/utils/localization.py:155 +msgid "pm" +msgstr "" + #: /home/kovid/work/calibre/src/calibre/utils/pyconsole/console.py:56 msgid "Choose theme (needs restart)" msgstr "" diff --git a/src/calibre/utils/localization.py b/src/calibre/utils/localization.py index 376cda414e..aa0c515d43 100644 --- a/src/calibre/utils/localization.py +++ b/src/calibre/utils/localization.py @@ -147,6 +147,13 @@ _extra_lang_codes = { 'und' : _('Unknown') } +if False: + # Extra strings needed for Qt + _('AM') + _('PM') + _('am') + _('pm') + _lcase_map = {} for k in _extra_lang_codes: _lcase_map[k.lower()] = k @@ -176,18 +183,6 @@ def get_language(lang): return translate(ans) -def set_qt_translator(translator): - lang = get_lang() - if lang is not None: - if lang == 'nds': - lang = 'de' - mpath = get_lc_messages_path(lang) - if mpath is not None: - p = os.path.join(mpath, 'qt.qm') - if os.path.exists(p): - return translator.load(p) - return False - _udc = None def get_udc():