export lang: propose filename
bzr revid: christophe@tinyerp.com-20080902114922-bpejt6a9xheeqyt0
This commit is contained in:
parent
ed7af4de69
commit
ece0491a4b
|
@ -31,7 +31,7 @@
|
|||
<image name="gtk-dialog-info"/>
|
||||
<group col="2" states="choose" fill="0" height="500">
|
||||
<separator string="Export translation file" colspan="2"/>
|
||||
<field name="lang" width="300" required="1"/>
|
||||
<field name="lang" width="300"/>
|
||||
<field name="format" required="1"/>
|
||||
<field name="modules" width="500" height="200"/>
|
||||
<field name="state" invisible="1"/>
|
||||
|
@ -41,6 +41,7 @@
|
|||
<separator string="Export done"/>
|
||||
<field name="data" readonly="1" nolabel="1"/>
|
||||
<field name="advice" nolabel="1" height="80"/>
|
||||
<field name="name" invisible="True"/>
|
||||
</group>
|
||||
<group col="2" colspan="3" fill="0">
|
||||
<button states="choose" icon="gtk-cancel" name="act_cancel" special="cancel" string="Cancel" type="object"/>
|
||||
|
|
|
@ -44,7 +44,7 @@ class wizard_export_lang(osv.osv_memory):
|
|||
lang_obj=pooler.get_pool(cr.dbname).get('res.lang')
|
||||
ids=lang_obj.search(cr, uid, ['&', ('active', '=', True), ('translatable', '=', True),])
|
||||
langs=lang_obj.browse(cr, uid, ids)
|
||||
return [('', _('New language'))] + [(lang.code, lang.name) for lang in langs]
|
||||
return [(lang.code, lang.name) for lang in langs]
|
||||
|
||||
|
||||
def act_cancel(self, cr, uid, ids, context=None):
|
||||
|
@ -56,28 +56,31 @@ class wizard_export_lang(osv.osv_memory):
|
|||
|
||||
def act_getfile(self, cr, uid, ids, context=None):
|
||||
this = self.browse(cr, uid, ids)[0]
|
||||
mods = map(lambda m: m.name, this.modules)
|
||||
mods = map(lambda m: m.name, this.modules) or ['all']
|
||||
mods.sort()
|
||||
buf=StringIO.StringIO()
|
||||
|
||||
tools.trans_export(this.lang, mods, buf, this.format, dbname=cr.dbname)
|
||||
|
||||
if this.format == 'csv':
|
||||
this.advice = _("Save this document to a .CSV file and open it with your favourite spreadsheet software. The file encoding is UTF-8. You have to translate the latest column before reimporting it.")
|
||||
elif this.format == 'po':
|
||||
ext = this.lang and '.po' or '.pot'
|
||||
this.advice = _("Save this document to a %s file and edit it with a specific software or a text editor. The file encoding is UTF-8." % (ext,))
|
||||
if not this.lang:
|
||||
this.format = 'pot'
|
||||
this.advice = _("Save this document to a %s file and edit it with a specific software or a text editor. The file encoding is UTF-8.") % ('.'+this.format,)
|
||||
elif this.format == 'tgz':
|
||||
ext = this.lang and '.po' or '.pot'
|
||||
this.advice = _('Save this document to a .tgz file. This archive containt UTF-8 %s files and may be uploaded to launchpad.' % (ext,))
|
||||
|
||||
this.advice = _('Save this document to a .tgz file. This archive containt UTF-8 %s files and may be uploaded to launchpad.') % (ext,)
|
||||
|
||||
this.name = "%s.%s" % (this.lang or _('new'), this.format)
|
||||
|
||||
out=base64.encodestring(buf.getvalue())
|
||||
buf.close()
|
||||
return self.write(cr, uid, ids, {'state':'get', 'data':out, 'advice':this.advice}, context=context)
|
||||
return self.write(cr, uid, ids, {'state':'get', 'data':out, 'advice':this.advice, 'name':this.name}, context=context)
|
||||
|
||||
_name = "wizard.module.lang.export"
|
||||
_columns = {
|
||||
'lang': fields.selection(_get_languages, 'Language'), # not required: unset = new language
|
||||
'name': fields.char('Filename', 16, readonly=True),
|
||||
'lang': fields.selection(_get_languages, 'Language', help='To export a new language, do not select a language.'), # not required: unset = new language
|
||||
'format': fields.selection( ( ('csv','CSV File'), ('po','PO File'), ('tgz', 'TGZ Archive')), 'File Format', required=True),
|
||||
'modules': fields.many2many('ir.module.module', 'rel_modules_langexport', 'wiz_id', 'module_id', 'Modules', domain=[('state','=','installed')]),
|
||||
'data': fields.binary('File', readonly=True),
|
||||
|
@ -86,7 +89,8 @@ class wizard_export_lang(osv.osv_memory):
|
|||
('get','get'), # get the file
|
||||
) ),
|
||||
}
|
||||
_defaults = { 'state': lambda *a: 'choose', }
|
||||
_defaults = { 'state': lambda *a: 'choose',
|
||||
}
|
||||
wizard_export_lang()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
|
Loading…
Reference in New Issue