简体   繁体   English

具有gettext和.po文件的javascript i18n

[英]javascript i18n with gettext and .po files

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. 我的翻译机制在服务器端与jinja2模板引擎一起工作,在webapp2的i18n函数与魔术_函数一起工作,现在我需要Java本地化它来仅对几个字符串进行本地化,但找不到很好的实现。 Is there one? 有一个吗?

I'd like a solution for localizing my web app. 我想要一个本地化我的Web应用程序的解决方案。 The javascript strings are just a few but I need a translation mechanism and the dictionary is .po and .mo files. javascript字符串只是几个,但是我需要一种翻译机制,而字典是.po和.mo文件。 Ideally I'd like javascript to take the same dictionaries as python does (the .po files) 理想情况下,我希望javascript接受与python相同的词典(.po文件)

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. 例如, http://www.zomeoff.com/jsin/jsin.1.2.unit.test.html做得很成功,但这只是一个本地化。 I need to harmonize the translations so that the same language is used by both the python jinja2 templates and javascript. 我需要统一翻译,以便python jinja2模板和javascript使用相同的语言。

Do you have s suggestion or can comment my situation? 您有什么建议或可以评论我的情况吗?

Thank yo 谢谢

Javascript Gettext Javascript Gettext

You could probably use polib and json to generate the JSON on the fly though. 您可能可以使用polib和json即时生成JSON。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM