Symfony、sfDoctrineGuardPlugin 和翻译 (I18N / I10N)

发布于 2024-11-06 07:30:33 字数 1355 浏览 0 评论 0原文

最近,我一直在努力解决可用于 sfDoctrineGuardPlugin /www.symfony-project.org" rel="nofollow noreferrer">Symfony。问题在于插件的翻译。

sfDoctrineGuardPlugin 背后的人们显然已经想到了 i18n,因为他们在

我添加了一个挪威语翻译文件(为了简单起见),将其放置在插件 i18n 目录中。一旦我正确翻译了所有项目,我就会将其移出那里,但那是另一个故事了。

我的登录表单(sfDoctrineGuardPlugin 的默认表单)在渲染时看起来像这样(为了简单起见,删除了样式):

Login form as rendered

正如您所看到的,标头元素以及登录按钮都已翻译,但用户名/电子邮件和密码字段并未翻译。

在 sfDoctrineGuardPlugin/lib/form/doctrine/base/BasesfGuardFormSignin.class.php 中存在以下代码:

if (sfConfig::get('app_sf_guard_plugin_allow_login_with_email', true))
{
  $this->widgetSchema['username']->setLabel('Username or E-Mail');
}

这是未翻译的文本元素之一。在我的 sg_guard.nb.xml 中,我已经翻译了 sfDoctrineGuardPlugins svn-repository 中的示例翻译中可以找到的所有字符串。对于上述标签,我有以下内容:

<trans-unit>
  <source>Username or E-Mail</source>
  <target>Brukernavn eller epost</target>
</trans-unit>

我的猜测是,使用 setLabel 向上两个部分可确保 i18n 系统无法将我的翻译插入到应该插入的位置。

sfDoctrineGuardPlugin 是否设置为从 sf_guard.XX.xml 以外的其他目录替换文本?

做了哪些工作来让翻译工作正常进行?如果可以避免的话,我真的不想修改 sfDoctrineGuardPlugin 源(所以我有干净的依赖关系)。

任何指示表示赞赏。

Recently I have been struggling with the sfDoctrineGuardPlugin available for Symfony. The issue is with translation of the plugin.

The people behind sfDoctrineGuardPlugin have obviously thought about i18n, as they have provided some translations in the proper directory in their project. The problem however, is that not all text-elements are translated. More specificly the login / signin-form is only partially translated.

I have added a translation file for Norwegian (and for simplicity) placed it inside the plugins i18n-directory. I will move it out of there as soon as I get all the items properly translated, but that's another story.

My login-form (the default one for sfDoctrineGuardPlugin) looks like this when rendered (styles removed for simplicity):

Login form as rendered

As you can see the header-element as well as the signin-button get translated, but fields for username/email and password does not.

In sfDoctrineGuardPlugin/lib/form/doctrine/base/BasesfGuardFormSignin.class.php the following code is present:

if (sfConfig::get('app_sf_guard_plugin_allow_login_with_email', true))
{
  $this->widgetSchema['username']->setLabel('Username or E-Mail');
}

This is one of the text-elements that are not translated. In my sg_guard.nb.xml I have translated all the strings that can be found in the example translations in sfDoctrineGuardPlugins svn-repository. For the abovementioned label I have the following:

<trans-unit>
  <source>Username or E-Mail</source>
  <target>Brukernavn eller epost</target>
</trans-unit>

My guess is that the use of setLabel two sections up ensures that the i18n-system is unable to insert my translation where it should.

Is sfDoctrineGuardPlugin set to have text replaced from some other catalog than sf_guard.XX.xml?

What have you done to get translations working? I really do not want to modify the sfDoctrineGuardPlugin source if it can be avoided (so I have clean dependencies).

Any pointers are appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

迷鸟归林 2024-11-13 07:30:33

我不确定其确切原因,但如果您将翻译从插件文件夹移到应用程序翻译文件夹中,一切都应该发挥作用。

至少我的 symfony 1.4.11 应用程序是这样。

此致。

I'm not sure about the exact reason for this, but if you move your translations out of plugin folder and into your app translations folder everything should work as charm.

At least this is the case with my symfony 1.4.11 application.

Best regards.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文