简体   繁体   English

i18n在谷歌应用引擎1.4.3和django 1.2上

[英]i18n on google app engine 1.4.3 and django 1.2

I have found some tutorials that show how to use i18n on gae, but they assume django 0.96. 我找到了一些教程,展示如何在gae上使用i18n,但他们假设django 0.96。 Right now I don't have for example separate script for makemessages and I can't run manage.py. 现在我没有例如makemessages的单独脚本,我无法运行manage.py。 Has anyone tried using i18n recently and could explain to me, how can this be done? 有没有人最近尝试过使用i18n并且可以向我解释一下,如何做到这一点?

EDIT 编辑

I have managed to generate po files and compile them. 我设法生成po文件并编译它们。 I receive language headers and I am able to set translation langauge. 我收到语言标题,我可以设置翻译语言。 self.request.LANGUAGE_CODE is set to pl which is just fine. self.request.LANGUAGE_CODE设置为pl ,这很好。 And yet those translations are not used while rendering the webpage. 然而,在渲染网页时不使用这些翻译。 Do you have any idea why this might be happening? 你知道为什么会这样吗?

EDIT2 EDIT2

Ok, doing some trial/error I managed to discover, you need to import settings from django.conf and reload them (setting._target = None). 好的,做了一些试验/错误,我设法发现,你需要从django.conf导入设置并重新加载它们(setting._target = None)。 And it finally works. 它终于奏效了。

We got it working or at least we think we do. 我们得到了它,或者至少我们认为我们做到了。 We use the script compile-messages from django 0.96 to compile the .po files and have upgraded to django 1.2 using an I18NRequestHandler so I want to confirm it works. 我们使用来自django 0.96的脚本编译消息来编译.po文件,并使用I18NRequestHandler升级到django 1.2,所以我想确认它有效。 You may have a look at our code at http://montao.googlecode.com and we don't use manage.py since we don't use all of django. 您可以在http://montao.googlecode.com查看我们的代码,我们不使用manage.py,因为我们不使用所有的django。 I hope some of this helps. 我希望其中一些有所帮助。 I needed to add an import saying from django.utils.translation import gettext_lazy as _ otherwise most django 0.96 was easy to upgrade to 1.2. 我需要添加一个from django.utils.translation import gettext_lazy as _的导入说法from django.utils.translation import gettext_lazy as _否则大多数django 0.96很容易升级到1.2。 To activate the translation we now can use the hl parameter to a HTTP query for instance for greek translations: http://classifiedsmarket.appspot.com/?hl=el and the text in greek displays from the .mo files that were compiled with the script compile-messages.py 为了激活翻译,我们现在可以将hl参数用于HTTP查询,例如希腊语翻译: http//classifiedsmarket.appspot.com/? hl = el和希腊语中显示的.mo文件中的文本脚本compile-messages.py

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

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