5
from translation.translation import get_language
7
view_form_end = """<?xml version="1.0"?>
8
<form string="Language file loaded.">
9
<image name="gtk-dialog-info" colspan="2"/>
10
<group colspan="2" col="4">
11
<separator string="Installation done" colspan="4"/>
12
<label align="0.0" string="Csv file for the selected language has been successfully reviewed with the i18n file" colspan="4"/>
16
view_form = """<?xml version="1.0"?>
17
<form string="Language Selection">
18
<image name="gtk-dialog-info" colspan="2"/>
19
<group colspan="2" col="4">
20
<separator string="Language List" colspan="4"/>
21
<label align="0.0" string="Choose a language to install:" colspan="4"/>
22
<field name="lang" colspan="4"/>
23
<label align="0.0" string="Note that this operation may take a few minutes." colspan="4"/>
27
class wizard_review_proposed_contributions(wizard.interface):
28
def _review_difference(self, cr, uid, data, context):
29
lang = data['form']['lang']
30
ir_translation = pooler.get_pool(cr.dbname).get('ir.translation')
31
ir_translation_contrib = pooler.get_pool(cr.dbname).get('ir.translation.contribution')
32
ids = ir_translation.search(cr,uid,[('lang','=',lang)])
33
res = ir_translation.read(cr,uid,ids,['type','name','value','src'])
34
new_res =map(lambda x:{'type':x['type'],'name':x['name'],'value':x['value'],'src':x['src']},res)
35
filename = tools.config["root_path"] + "/i18n/" + lang + ".csv"
36
reader = csv.DictReader(open(filename,'r'),delimiter=',')
37
new_reader =map(lambda x:{'type':x['type'],'name':x['name'],'value':x['value'],'src':x['src']},reader)
45
ids = ir_translation.search(cr,uid,[('type','=',d['type']),('name','=',d['name']),('src','=',d['src']),('lang','=',lang)])
46
res_id = ir_translation.read(cr,uid,ids,['res_id','lang'])[0]
47
ids = ir_translation_contrib.search(cr,uid,[('type','=',d['type']),('name','=',d['name']),('src','=',d['src'])])
49
ir_translation_contrib.write(cr,uid,ids,{'value':d['value'],'src':d['src']})
51
vals['type']=d['type']
52
vals['name']=d['name']
54
vals['value']=d['value']
55
vals['res_id']=res_id['res_id']
56
vals['lang'] = res_id['lang']
58
ir_translation_contrib.create(cr,uid,vals)
60
def _get_language(sel, cr, uid,context):
61
return get_language(cr,uid,context,model='ir_translation')
64
'lang': {'string':'Language', 'type':'selection', 'selection':_get_language,
70
'result': {'type': 'form', 'arch': view_form, 'fields': fields_form,
72
('end', 'Cancel', 'gtk-cancel'),
73
('start', 'Review Difference', 'gtk-ok', True)
78
'actions': [_review_difference],
79
'result': {'type': 'form', 'arch': view_form_end, 'fields': {},
81
('end', 'Ok', 'gtk-ok', True)
86
wizard_review_proposed_contributions('review.proposed.contributions')
b'\\ No newline at end of file'