开发者

Symfony, sfDoctrineGuardPlugin and translations (I18N / I10N)

开发者 https://www.devze.com 2023-03-05 20:42 出处:网络
Recently I have been struggling with the sfDoctrineGuardPlugin available for Symfony. The issue is with translation of the plugin.

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):

Symfony, sfDoctrineGuardPlugin and translations (I18N / I10N)

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开发者_StackOverflow/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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消