mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Add support for dynamically loading translations from .po files.
This commit is contained in:
parent
33efccb6ad
commit
595e0b8e9b
@ -22,6 +22,8 @@ import sys, os, logging, mechanize, locale, cStringIO
|
|||||||
from gettext import GNUTranslations
|
from gettext import GNUTranslations
|
||||||
from math import floor
|
from math import floor
|
||||||
|
|
||||||
|
from libprs500.translations.msgfmt import make
|
||||||
|
|
||||||
iswindows = 'win32' in sys.platform.lower()
|
iswindows = 'win32' in sys.platform.lower()
|
||||||
isosx = 'darwin' in sys.platform.lower()
|
isosx = 'darwin' in sys.platform.lower()
|
||||||
islinux = not(iswindows or isosx)
|
islinux = not(iswindows or isosx)
|
||||||
@ -119,8 +121,14 @@ def set_translator():
|
|||||||
pass
|
pass
|
||||||
if lang:
|
if lang:
|
||||||
lang = lang[:2]
|
lang = lang[:2]
|
||||||
if translations.has_key(lang):
|
buf = None
|
||||||
|
if os.access(lang+'.po', os.R_OK):
|
||||||
|
buf = cStringIO.StringIO()
|
||||||
|
make(lang+'.po', buf)
|
||||||
|
buf = cStringIO.StringIO(buf.getvalue())
|
||||||
|
elif translations.has_key(lang):
|
||||||
buf = cStringIO.StringIO(translations[lang])
|
buf = cStringIO.StringIO(translations[lang])
|
||||||
|
if buf is not None:
|
||||||
t = GNUTranslations(buf)
|
t = GNUTranslations(buf)
|
||||||
t.install(unicode=True)
|
t.install(unicode=True)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user