Hi

After user signup to some event, he/she can see his/her details with words: Name and Phone.
But this words are nontransable (either you have gettext for it) because in your module code you are using variable instead this string:

example:
case 'table':
static $rows = array();
// Loop through each first level element.
foreach ($data as $key => $value) {
// Element is nested, render it recursively.
if (is_array($value)) {
$rows[] = array('

');
signup_build_signup_data($value, 'table');
}
else {
$rows[] = array($key .':', check_plain($value));
}
}

problem is row: $rows[] = array($key .':', check_plain($value));
where you are using variable $key, which is without gettext. It will be always "Name" and "Phone"

thanks
Igor
somvprahe.sk

Comments

dww’s picture

Title: wrong using variables » can't translate labels on the signup form?
Category: bug » support
Status: Active » Closed (works as designed)

(Side note: I hate the way the signup form is generated via a theme function). As far as I knew, the fact that the values for the #title attributes in the theme function are being wrapped in t(), would be good enough to translate the phrases. There have been successful translations of this module, and no one has complained before. So, you must either have not tried it yourself, or you're doing something wrong. But, it's impossible to put t() around a variable, and I have to loop over the form elements at that point. So, there's really nothing to fix here.

dww’s picture

Assigned: Unassigned » dww
Category: support » bug
Status: Closed (works as designed) » Needs review
StatusFileSize
new3.26 KB
new2.65 KB

My apologies to both igorik and olio. It seems there's an edge-case of using t() where it's ok to pass a variable through t() which I had never read, and which is contradicted by the potx.php extractor script:

http://api.drupal.org/api/function/t/6

The only case in which variables can be passed safely through t() is when code-based versions of the same strings will be passed through t() (or otherwise extracted) elsewhere.

If you use t() like this, running potx.php will generate error messages:

Processing signup.module...
Invalid marker content in signup.module:2468
* t($key)

Invalid marker content in signup.module:2520
* t($key)

Invalid marker content in signup.module:2552
* t($key)

However, it seems from reading those docs like using t() like this should actually be ok. Hrm.

In this case, so long as you properly use t() in the theme_signup_user_form() function, and ensure that all of your array keys in that form match the English versions of the titles of the form elements, it should work to wrap t() around the $key whenever it's printed in the theme functions related to the custom signup data. I've updated the comment above theme_signup_user_form() to try to make this clear, and point out that the array key must match the value in the #title attribute inside the t().

Untested patches for both D5--2 and D6--1, but it seems like this should do the trick.

dww’s picture

After an illuminating thread on the translators' list, here's a new set of patches that avoids the potx warnings. The thread also confirms that this should all work the same in D5 and D6, even though the docs changed in D6. Finally, I found a spot in the D6 views handler for the custom data that still wasn't using t() (and refactored it into a shared theme function, since it really is generating markup and should be directly themeable anyway).

dww’s picture

Status: Needs review » Fixed

Committed to HEAD, DRUPAL-6--1, and DRUPAL-5--2.

Status: Fixed » Closed (fixed)

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