码迷,mamicode.com
首页 > 其他好文 > 详细

(13)odoo翻译

时间:2016-01-29 21:04:01      阅读:359      评论:0      收藏:0      [点我收藏+]

标签:

zh_CN.po
-------------------------
视图中文字翻译
#. module: sale_commission
#: view:sale.commission.make.invoice:sale_commission.sale_commission_make_invoice_form
msgid "(keep empty for invoicing all the settlements)"
msgstr "(保持所有的结算发票为空)"
------
第一行 #. module: sale_commission 格式为 #. module: 模块的目录名
第二行 #: view:sale.commission.make.invoice:sale_commission.sale_commission_make_invoice_form
格式为 #: view:模型名:模块的目录名.视图的id名
第三行 msgid "(keep empty for invoicing all the settlements)" 把视图对应要翻译的那段复制过来

视图对应代码如下
<record id="sale_commission_make_invoice_form" model="ir.ui.view">
<field name="name">Make invoices</field>
<field name="model">sale.commission.make.invoice</field>
<field name="arch" type="xml">
<form string="Make invoices">
<group>
<field name="journal" />
<field name="product" />
<field name="date" />
</group>
<group string="Settlements"
attrs="{‘invisible‘: [(‘from_settlement‘, ‘=‘, True)]}">
<p colspan="4">(keep empty for invoicing all the settlements)</p>
<field name="from_settlement" invisible="1"/>
<field name="settlements" nolabel="1" widget="many2many_list"/>
</group>
<footer>
<button name="button_create"
string="Create invoices"
type="object"
class="oe_highlight" />
or
<button special="cancel"
string="_Cancel"
class="oe_link" />
</footer>
</form>
</field>
</record>
可以看到模型名 在视图代码 <field name="model">sale.commission.make.invoice</field> model关键词指明了
可以看到视图的id名 在视图代码 <record id="sale_commission_make_invoice_form" model="ir.ui.view">
对应的翻译 在视图代码 <p colspan="4">(keep empty for invoicing all the settlements)</p>

------
-------------------------
字段的翻译
#. module: sale_commission
#: field:sale.commission.make.invoice,from_settlement:0
msgid "From settlement"
msgstr "结算开始时间"

第一行 #. module: sale_commission 格式为 #. module: 模块的目录名
第二行 #: field:sale.commission.make.invoice,from_settlement:0
格式为 #: field:模型名:要翻译的字段名:0
第三行 msgid "From settlement" 这个一般是要翻译的字段的英文

-------
<record id="sale_commission_make_invoice_form" model="ir.ui.view">
<field name="name">Make invoices</field>
<field name="model">sale.commission.make.invoice</field>
<field name="arch" type="xml">
<form string="Make invoices">
<group>
<field name="journal" />
<field name="product" />
<field name="date" />
</group>
<group string="Settlements"
attrs="{‘invisible‘: [(‘from_settlement‘, ‘=‘, True)]}">
<p colspan="4">(keep empty for invoicing all the settlements)</p>
<field name="from_settlement" invisible="1"/>
<field name="settlements" nolabel="1" widget="many2many_list"/>
</group>
<footer>
<button name="button_create"
string="Create invoices"
type="object"
class="oe_highlight" />
or
<button special="cancel"
string="_Cancel"
class="oe_link" />
</footer>
</form>
</field>
</record>
-------
可以看到模型名 在视图代码 <field name="model">sale.commission.make.invoice</field> model关键词指明了
对应的翻译 在视图代码 <field name="from_settlement" invisible="1"/>
-------------------------
py代码中的字符翻译
#. module: sale_commission
#: code:addons/sale_commission/models/settlement.py:78
#, python-format
msgid "Make invoice"
msgstr "制作发票"

第一行 #. module: sale_commission 格式为 #. module: 模块的目录名
第二行 #: code:addons/sale_commission/models/settlement.py:78
格式为 #: code:python代码相对跟目录的文件名:第几行 注意一下code:addons... 一般第三方代码不会放在addons下
一般新建一个目录 addonscustom ,这时这里要相应的更改
第三行 #, python-format 是python代码,这个照写就可以
-----
def action_invoice(self):
return {
‘type‘: ‘ir.actions.act_window‘,
‘name‘: _(‘Make invoice‘),
‘res_model‘: ‘sale.commission.make.invoice‘,
‘view_type‘: ‘form‘,
‘target‘: ‘new‘,
‘view_mode‘: ‘form‘,
‘context‘: {‘settlement_ids‘: self.ids}
}
-------
可以看到要翻译的字符 在视图代码 ‘name‘: _(‘Make invoice‘),
我这里没有行号,用编辑打开源代码就可以看到左边有行号,这个行号也不是要太准,差不多就可以
---------------------------
选择内容
#. module: sale_commission
#: selection:res.partner,settlement:0
msgid "Monthly"
msgstr "月度"

第一行 #. module: sale_commission 格式为 #. module: 模块的目录名
第二行 #: selection:res.partner,settlement:0
格式为 #:selection:模型名,字段名
模型名

----
class ResPartner(models.Model):
"""Add some fields related to commissions"""
_inherit = "res.partner"

agents = fields.Many2many(
comodel_name="res.partner", relation="partner_agent_rel",
column1="partner_id", column2="agent_id",
domain="[(‘agent‘, ‘=‘, True)]")
# Fields for the partner when it acts as an agent
agent = fields.Boolean(
string="Creditor/Agent",
help="Check this field if the partner is a creditor or an agent.")
agent_type = fields.Selection(
selection=[("agent", "External agent")], string="Type", required=True,
default="agent")
commission = fields.Many2one(
string="Commission", comodel_name="sale.commission",
help="This is the default commission used in the sales where this "
"agent is assigned. It can be changed on each operation if "
"needed.")
settlement = fields.Selection(
selection=[("monthly", "Monthly"),
("quaterly", "Quarterly"),
("semi", "Semi-annual"),
("annual", "Annual")],
string="Settlement period", default="monthly", required=True)
settlements = fields.One2many(
comodel_name="sale.commission.settlement", inverse_name="agent",
readonly=True)

@api.onchange(‘agent_type‘)
def onchange_agent_type(self):
if self.agent_type == ‘agent‘:
self.supplier = True

---
可以看到模型名 在代码 _inherit = "res.partner"
对应的翻译字段对应要翻译的值 在代码 settlement = fields.Selection(
selection=[("monthly", "Monthly"),
("quaterly", "Quarterly"),
("semi", "Semi-annual"),
("annual", "Annual")],

-----------------------------------------
帮助
#. module: sale_commission
#: help:res.partner,commission:0
msgid "This is the default commission used in the sales where this agent is assigned. It can be changed on each operation if needed."
msgstr "这是分配给代理的默认提成类型,若你需要可以在每个操作改变它"

第一行 #. module: sale_commission 格式为 #. module: 模块的目录名
第二行 #: help:res.partner,commission:0
格式为 #: help:模型名,字段名
----------
commission = fields.Many2one(
string="Commission", comodel_name="sale.commission",
help="This is the default commission used in the sales where this "
"agent is assigned. It can be changed on each operation if "
"needed.")
可以看到字段名 在代码 commission = fields.Many2one(
-----------
这个和选择内容相似
-----------------------------------------
菜单
#. module: sale_commission
#: model:ir.ui.menu,name:sale_commission.menu_agents_settlement
msgid "Settle commissions"
msgstr "提成结算"

第一行 #. module: sale_commission 格式为 #. module: 模块的目录名
第二行 #: model:ir.ui.menu,name:sale_commission.menu_agents_settlement
格式为 #: model:ir.ui.menu,name:模块的目录名.id名

----------
<menuitem id="menu_agents_settlement"
parent="menu_sale_commissions_conf"
action="action_agents_settlement" />

可以看到id名 在代码 <menuitem id="menu_agents_settlement"
---------

针对菜单,还改用户的首选项,重新保存一次就可以
-----------------------------------------
窗户动作响应
#. module: sale_commission
#: model:ir.actions.act_window,name:sale_commission.action_agents_settlement
msgid "Settle commissions"
msgstr "提成结算"
第一行 #. module: sale_commission 格式为 #. module: 模块的目录名
第二行 #: model:ir.actions.act_window,name:sale_commission.action_agents_settlement
格式为 #: model:ir.actions.act_window,name:模块的目录名.id名

--------------
<act_window id="action_agents_settlement"
name="Settle commissions"
res_model="sale.commission.make.settle"
view_mode="form"
view_type="form"
target="new" />

可以看到id名 在代码 <act_window id="action_agents_settlement"
--------------
-----------------------------------------

#. module: account
#: model:account.payment.term,name:account.account_payment_term_15days
#: model:account.payment.term,note:account.account_payment_term_15days
msgid "15 Days"
msgstr "15 天"

第一行 #. module: account 格式为 #. module: 模块的目录名
第二行 #: model:account.payment.term,name:account.account_payment_term_15days
格式为 #: model:模型名,name:模块的目录名.id名 或 note:模块的目录名.id名
id名为当xml结构一组的标识
换句话说就是id名下面结构下,为name=‘name‘ 包含的字符值,要翻译
--------------
<record id="account_payment_term_15days" model="account.payment.term">
<field name="name">15 Days</field>
<field name="note">15 Days</field>
</record>

可以看到模型名 在代码 model="account.payment.term">
可以看到id名 在代码 <record id="account_payment_term_15days"
--------------

注:总是翻译无效时,可以搜索旁边的 翻译,从而参照 写翻译条

 

(13)odoo翻译

标签:

原文地址:http://www.cnblogs.com/toby2chen/p/5169717.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!