Přejít na obsah
Menu
You need to be registered to interact with the community.
This question has been flagged
2 Odpovědi
840 Zobrazení

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?

Avatar
Zrušit
Autor Nejlepší odpověď

Hi Niyas,

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

Avatar
Zrušit
Nejlepší odpověď

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

Avatar
Zrušit
Related Posts Odpovědi Zobrazení Aktivita
1
čvn 25
1932
3
čvc 25
3520
1
kvě 25
1642
1
kvě 25
1889
4
kvě 25
3014