doulangpeng3933 2011-05-12 07:45
浏览 45
已采纳

Symfony,sfDoctrineGuardPlugin和翻译(I18N / I10N)

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.

  • 写回答

1条回答 默认 最新

  • dongtanhe4607 2011-05-12 20:23
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?