bzr revid: fp@tinyerp.com-20101229185833-ujdxwg5zyg2i3zf2
This commit is contained in:
Fabien Pinckaers
2010-12-29 19:58:33 +01:00
5 changed files with 28 additions and 3 deletions
+4
View File
@@ -827,6 +827,10 @@ def load_modules(db, force_demo=False, status=None, update_module=False):
raise osv.osv.except_osv(_('Could not load base module'), _('module base cannot be loaded! (hint: verify addons-path)'))
has_updates = load_module_graph(cr, graph, status, perform_checks=(not update_module), report=report, skip_cleanup=True)
if tools.config['load_language']:
for lang in tools.config['load_language'].split(','):
tools.load_language(cr, lang)
if update_module:
modobj = pool.get('ir.module.module')
logger.notifyChannel('init', netsvc.LOG_INFO, 'updating modules list')
+1 -1
View File
@@ -475,7 +475,7 @@ class module(osv.osv):
categs = categs[1:]
self.write(cr, uid, [mod_browse.id], {'category_id': p_id})
def update_translations(self, cr, uid, ids, filter_lang=None, context=None):
def update_translations(self, cr, uid, ids, filter_lang=None, context={}):
logger = logging.getLogger('i18n')
if not filter_lang:
pool = pooler.get_pool(cr.dbname)
+5 -1
View File
@@ -119,13 +119,17 @@ if not ( tools.config["stop_after_init"] or \
if tools.config['db_name']:
for dbname in tools.config['db_name'].split(','):
db,pool = pooler.get_db_and_pool(dbname, update_module=tools.config['init'] or tools.config['update'], pooljobs=False)
cr = db.cursor()
if tools.config["test_file"]:
logger.info('loading test file %s', tools.config["test_file"])
cr = db.cursor()
tools.convert_yaml_import(cr, 'base', file(tools.config["test_file"]), {}, 'test', True)
cr.rollback()
pool.get('ir.cron')._poolJobs(db.dbname)
cr.close()
#----------------------------------------------------------
# translation stuff
#----------------------------------------------------------
+5 -1
View File
@@ -59,6 +59,7 @@ class configmanager(object):
'translate_in': None,
'translate_out': None,
'overwrite_existing_translations': False,
'load_language': None,
'language': None,
'pg_path': None,
'admin_passwd': 'admin',
@@ -210,6 +211,8 @@ class configmanager(object):
"Option '-l' is mandatory in case of importation"
)
group.add_option('--load-language', dest="load_language",
help="specifies the languages for the translations you want to be loaded")
group.add_option('-l', "--language", dest="language",
help="specify the language of the translation file. Use it with --i18n-export or --i18n-import")
group.add_option("--i18n-export", dest="translate_out",
@@ -291,7 +294,8 @@ class configmanager(object):
self.options[arg] = getattr(opt, arg)
keys = [
'language', 'translate_out', 'translate_in', 'overwrite_existing_translations', 'debug_mode', 'smtp_ssl',
'language', 'translate_out', 'translate_in', 'overwrite_existing_translations',
'debug_mode', 'smtp_ssl', 'load_language',
'stop_after_init', 'logrotate', 'without_demo', 'netrpc', 'xmlrpc', 'syslog',
'list_db', 'xmlrpcs',
'test_file', 'test_disable', 'test_commit', 'test_report_directory'
+13
View File
@@ -1007,5 +1007,18 @@ def resetlocale():
except locale.Error:
continue
def load_language(cr, lang):
"""Loads a translation terms for a language.
Used mainly to automate language loading at db initialization.
:param lang: language ISO code with optional _underscore_ and l10n flavor (ex: 'fr', 'fr_BE', but not 'fr-BE')
:type lang: str
"""
pool = pooler.get_pool(cr.dbname)
language_installer = pool.get('base.language.install')
uid = 1
oid = language_installer.create(cr, uid, {'lang': lang})
language_installer.lang_install(cr, uid, [oid], context=None)
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: