I need to translate the month name from English to Spanish in Qweb report. This is the code for printing Month name, how to translate it inside t-esc option?
<span t-esc="time.strftime('%B', time.strptime(o.payment_date, '%Y-%m-%d'))"/>
Odoo is the world's easiest all-in-one management software.
It includes hundreds of business apps:
I need to translate the month name from English to Spanish in Qweb report. This is the code for printing Month name, how to translate it inside t-esc option?
<span t-esc="time.strftime('%B', time.strptime(o.payment_date, '%Y-%m-%d'))"/>
Hi, I know the solution is a little late, but I hope this could help.
In your code you can call it like this:
<span t-field="o.invoice_date" t-options='{"widget": "date", "format": "MMMM"}'/>
But if you have a case like mine, and need to handle the date directly, you can do this:
<span t-out="line['date']" t-options='{"widget": "date", "format": "MMMM"}'/>
The datetime format can be configured directly in the language settings.
Some languages have "Year- Month - Day", while others have "Day - Month - Year", and the visualization format only depends on the user language.
Thanks,works for me
You can use some code like this:
<span t-esc="datetime.datetime.strptime(o.date_invoice, '%Y-%m-%d').strftime('%d de %m')
.replace('01','Enero')
.replace('02','Febrero')
.replace('03','Marzo')
.replace('04','Abril')
.replace('05','Mayo')
.replace('06','Junio')
.replace('07','Julio')
.replace('08','Agosto')
.replace('09','Septiembre')
.replace('10','Octubre')
.replace('11','Noviembre')
.replace('12','Diciembre')"/>
<span t-esc="datetime.datetime.strptime(o.date_due or o.date_invoice, '%Y-%m-%d').strftime('del %Y')"/>
Hope it helps!
Tạo tài khoản ngay hôm nay để tận hưởng các tính năng độc đáo và tham gia cộng đồng tuyệt vời của chúng tôi!
Đăng kýBài viết liên quan | Trả lời | Lượt xem | Hoạt động | |
---|---|---|---|---|
|
1
thg 4 25
|
1317 | ||
|
2
thg 3 25
|
1506 | ||
|
1
thg 3 24
|
2112 | ||
|
3
thg 9 23
|
24961 | ||
|
0
thg 2 24
|
3099 |
hello sir, have you solve this? i also wanted to know how to change it into my language