跳至内容
菜单
此问题已终结
2 回复
821 查看

I have a set of Push notification messages in different languages (all in po files). I want to send push message depending on user's active token field with language preference. 

I can make it via dict like this:

messages = {'msg 1': {"en": "...", "it": "....", "es": "..."}, ...}

and then get right translation message.get("msg 1").get(lang_code) but assume this might be a double work when translations present in po files.

Is it possible to somehow get right translation via po file without use of dictionary?

形象
丢弃
编写者 最佳答案

Hi Niyas,

No, I am not reading a data from the model field.

形象
丢弃
最佳答案

Hi,
If you are reading data from a field, you can pass the language in the context and get the translated field view, for that you can do as follows:  record.with_context(lang='fr_FR').name

Thanks

形象
丢弃
相关帖文 回复 查看 活动
1
6月 25
1914
3
7月 25
3510
1
5月 25
1632
1
5月 25
1883
4
5月 25
3001