javascript i18n with gettext and .po files

2019-02-25 15:52发布

My translation mechanism works serverside with the jinja2 template engine, webapp2's i18n function with the magic _ function and now I need it for Javascript to localize just a few strings but I couldn't find a good implementation. Is there one?

I'd like a solution for localizing my web app. The javascript strings are just a few but I need a translation mechanism and the dictionary is .po and .mo files. Ideally I'd like javascript to take the same dictionaries as python does (the .po files)

I don't need extractions, what I need is the _ function plus some way of determining user language and loading the translations, not just for a single language but for all my languages. I looked at some solutions but they only handla one translation at a time and I need to handle many.

For instance, http://www.zomeoff.com/jsin/jsin.1.2.unit.test.html does a successful job but this is only one localization. I need to harmonize the translations so that the same language is used by both the python jinja2 templates and javascript.

Do you have s suggestion or can comment my situation?

Thank yo

1条回答
祖国的老花朵
2楼-- · 2019-02-25 16:03

Javascript Gettext

You could probably use polib and json to generate the JSON on the fly though.

查看更多
登录 后发表回答