【发布时间】:2011-10-16 19:39:43
【问题描述】:
我的产品必须独立于品牌/徽标,并且应该发送本地化信息。我现在不需要超过 2 个本地化(英语和葡萄牙语),但我以后可能需要更多,所以如果我的应用程序被例如使用,添加翻译应该很容易。俄罗斯网站它应该能够以俄语和使用我的应用程序的网站/品牌的名称发送欢迎电子邮件,所以我想我想要做的是类似于白标产品的东西。我应该为此使用 gettext 吗?
--
message.body = 'Dear '+ad.name+'\nThank you for registering with '+self.current_logo+'! To edit your ad,click edit from the menu.'+ self.current_logo+'/vi/'+ad.key().id() +'\nWe invite you to visit our home page where you can find latest information on new business announcements from us. From there you also can upload videos, music and images. \n1) Contact Preferences - Please Select Your Contact Preferences\nInformation Contact\nIf you like, you can also add us on Facebook: apps.facebook.com/koolbusiness'
-- 例如,当我们添加一个域,然后使用品牌/徽标时的结果:
--------- 转发消息 ---------- 发件人:日期:2011 年 10 月 16 日星期日晚上 7:29 主题:本田 zoomer 收件人: 冰箱@koolbusiness.com
尊敬的 Niklas R 感谢您注册 www.koolbusiness.com!到 编辑您的广告,点击菜单中的编辑。www.koolbusiness.com/vi/4361186 我们邀请您访问我们的主页,在那里您可以找到最新的 有关我们新业务公告的信息。从那里你也 可以上传视频、音乐和图片。 1) 联系方式 - 请 选择您的联系方式偏好信息联系方式如果您愿意,您 也可以在 Facebook 上添加我们:apps.facebook.com/koolbusiness
你怎么看?
这是消息的构建方式。确切的内容并不重要,但重要的是它适用于多种语言。你可以用 gettext 来做,但我认为这个案例很简单,我可以在源代码中做,因为英语和葡萄牙语将在一段时间内成为应用程序的主要语言,然后也许我们添加西班牙语、法语、瑞典语但是编写这些翻译是一项非技术性的工作。
更新
由于 gettext 似乎是我想知道的实现的选择。特别是两件事是是否包含 HTML 以及如何显示特殊字符(如 & 号)。我目前正在使用它来呈现正确的输出,但代码是否正确?
django.po
msgid "Accessories & Parts"
msgstr "Partes & Acessórios"
msgid "Entire Brasil"
msgstr "«Todo Brasil»"
msgid "You can post ads for free. You can search for classified advertisements from professionals as well as private individuals; such as: cars, property, employment, pieces of furniture, electronics and others."
msgstr "<a href='/ai'>Anúncios</a> no site Montao.com.br são colocados manualmente pelo usuário aqui. <br/><a href='/li'>Todos</a> os anúncios são revistos pela equipe do Montao.com.br. O anúncio será visível durante dois messes. Grátis!"
对于新的电子邮件翻译,我可以使用 gettext,但我必须正确获取变量和翻译,这可能会很棘手,但无论如何我正在尝试开始绘制它,以便它可以本地化为多种语言:
msgid "Dear %s\nThank you for registering with %s! To edit your ad,click edit from the menu.%s/vi/%s \nWe invite you to visit our home page where you can find latest information on new business announcements from us. From there you also can upload videos, music and images. \n1) Contact Preferences - Please Select Your Contact Preferences\nInformation Contact\nIf you like, you can also add us on Facebook: apps.facebook.com/koolbusiness"
msgstr ""
但是,我的经验表明,创建 2 个 cron 作业,每个翻译一个,而不是多个翻译一个 cron 作业,因为由于 cookie cooruption 或类似情况,请求可能会意外获取错误的 cookie。所以这个翻译任务也是为了完整性和一致性,即使第一次尝试适用于英语并且很容易扩展到 2 种语言,我认为使用 gettext 进行完整的本地化是一件好事。
【问题讨论】:
标签: python localization gettext