mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Allow simple testing of .po files for languages unknown to calibre
This commit is contained in:
parent
f57b6dfe04
commit
f5e774b0c7
@ -29,6 +29,7 @@ Environment variables
|
||||
* ``CALIBRE_OVERRIDE_DATABASE_PATH`` - allows you to specify the full path to metadata.db. Using this variable you can have metadata.db be in a location other than the library folder. Useful if your library folder is on a networked drive that does not support file locking.
|
||||
* ``CALIBRE_DEVELOP_FROM`` - Used to run from a calibre development environment. See :ref:`develop`.
|
||||
* ``CALIBRE_OVERRIDE_LANG`` - Used to force the language used by the interface (ISO 639 language code)
|
||||
* ``CALIBRE_TEST_TRANSLATION`` - Used to test a translation .po file (should be the path to the .po file)
|
||||
* ``CALIBRE_NO_NATIVE_FILEDIALOGS`` - Causes calibre to not use native file dialogs for selecting files/directories. Set it to 1 to enable.
|
||||
* ``CALIBRE_NO_NATIVE_MENUBAR`` - Causes calibre to not create a native (global) menu on Ubuntu Unity and similar linux desktop environments. The menu is instead placed inside the window, as traditional.
|
||||
* ``CALIBRE_IGNORE_SYSTEM_THEME`` - Causes calibre to ignore any system Qt style plugins and use its builtin style plugin instead. Useful to workaround crashes caused by the system Qt plugin being incompatible with the version of Qt shipped with calibre.
|
||||
|
@ -146,27 +146,33 @@ lcdata = {
|
||||
u'yesexpr': u'^[yY].*'
|
||||
}
|
||||
|
||||
def load_po(path):
|
||||
from calibre.translations.msgfmt import make
|
||||
buf = cStringIO.StringIO()
|
||||
try:
|
||||
make(path, buf)
|
||||
except Exception:
|
||||
print (('Failed to compile translations file: %s, ignoring') % path)
|
||||
buf = None
|
||||
else:
|
||||
buf = cStringIO.StringIO(buf.getvalue())
|
||||
return buf
|
||||
|
||||
|
||||
def set_translators():
|
||||
global _lang_trans, lcdata
|
||||
# To test different translations invoke as
|
||||
# CALIBRE_OVERRIDE_LANG=de_DE.utf8 program
|
||||
lang = get_lang()
|
||||
t = None
|
||||
t = buf = iso639 = None
|
||||
|
||||
if 'CALIBRE_TEST_TRANSLATION' in os.environ:
|
||||
buf = load_po(os.path.expanduser(os.environ['CALIBRE_TEST_TRANSLATION']))
|
||||
|
||||
if lang:
|
||||
buf = iso639 = None
|
||||
mpath = get_lc_messages_path(lang)
|
||||
if mpath and os.access(mpath+'.po', os.R_OK):
|
||||
from calibre.translations.msgfmt import make
|
||||
buf = cStringIO.StringIO()
|
||||
try:
|
||||
make(mpath+'.po', buf)
|
||||
except:
|
||||
print (('Failed to compile translations file: %s,'
|
||||
' ignoring')%(mpath+'.po'))
|
||||
buf = None
|
||||
else:
|
||||
buf = cStringIO.StringIO(buf.getvalue())
|
||||
if buf is None and mpath and os.access(mpath + '.po', os.R_OK):
|
||||
buf = load_po(mpath + '.po')
|
||||
|
||||
if mpath is not None:
|
||||
from zipfile import ZipFile
|
||||
|
Loading…
x
Reference in New Issue
Block a user