Hello,

We're creating a website using profile2_regpath module and we noticed that the title of the user register form can't be translated, to fix that, we embed check_plain($title) with the t() function.

File : profile2_regpath/registration_form.inc
Line : 84

  // Set title.
  drupal_set_title(t(check_plain($title)));

And now we can translate the title using the translate interface of Drupal.

Hope it will be helpfull ;)

Bye!

Comments

grasmash’s picture

Status: Reviewed & tested by the community » Fixed

Thanks for the tip.

The best way to do this would be:

drupal_set_title(t('@title', array('@title' => $title)));

Technically, you're not supposed to run functions inside of t(). Using the '@' character before a t() variable will run it through check_plain() automatically. I've made this change and pushed it to dev.

Thanks!

gghh2’s picture

Thanks for your "pragmatic" adwise !

guillaume.d’s picture

Hi,

@madmatter23 : The problem i see putting '@title' inside t() is that we going to have only the string '@title' to translate in the interface (and not the 'real' one). For example if we have the title 'Create new Teenager account' on a form and another form with 'Create new Elected account', we want to translate specifically these titles and we can't use '@title'.

To fix that we can put the real title in the translate method, like this:


  $title = check_plain( $title );
  drupal_set_title( t($title) );

Bye :)

guillaume.d’s picture

Status: Fixed » Reviewed & tested by the community
grasmash’s picture

Status: Reviewed & tested by the community » Fixed

Change committed. Thanks!

Automatically closed -- issue fixed for 2 weeks with no activity.