I am stuck with translation of user relationships module in one place: When you want to approve or disapprove/cancel a relationship, you are taken to the form to be seen in the attached screenshot. When I looked into Localization for this form, I found: "Are you sure you want to @action the request to create a %relationship_name relationship to !name?"
Now the problem is in the @action. It has the possible values approve, disapprove, cancel, that are not translatable. I tried to find out where the variable $action comes from, and the only thing i coud find (searching for "approve" "disapprove") was in user_relationships_hooks.inc on line 220:
if (in_array(arg(4), array('approve', 'disapprove', 'cancel'))) {
$items[] = array(
'path' => "user/{$id}/relationships/requested",
'title' => t('Approve Relationship'),
'access' => $access || ($id == $user->uid),
'type' => MENU_CALLBACK,
'callback' => 'drupal_get_form',
'callback arguments' => array('user_relationships_pending_requested', arg(4), $id, arg(5)),
);
}
With my noob programmer mind I tried to wrap t() functions around the values of the array in the if statement in the first line. But this does no work, obviously it breaks a menu callback or something.
Maybe this is the wrong place to look, but I'd just like to be able to translate the words approve, disapprove and cancel, because otherwise it is very hard to understand for users who don't speak English.
| Comment | File | Size | Author |
|---|---|---|---|
| #5 | user-relationships-forms-inc.patch | 1016 bytes | eigentor |
| #4 | user_relationships_forms.inc_.340202.patch | 1.15 KB | jaydub |
Comments
Comment #1
eigentor commentedComment #2
alex.k commentedSorry for delay in answering. I can see how this is suboptimal with regards to translation... really since there are just 3 actions, it's easiest to not play this trick with substituting it into the string, and instead have three different strings for each case. Are you ok with modifying the module, and submitting a patch?
Also in parallel just curious, why you are still translating for 5.x, is it a new site?
Comment #3
eigentor commentedWell, though hardly being a dev at all, I'll try to create that patch. A nice challenge for me ;)
Well, D5 - I took over that project, and it is quite a messy site with lots of customization, modules and custom blocks, Views theming a.s.o. Will be quite an effort to update. I doubt the client will ever pay that... They are used to PHPBB and a heavily modified Version of that that is impossible to update... I guess many a site will remain in D5 forever for this kind of reason.
Comment #4
jaydub commentedI'm not totally sure on this patch as it's more of a quick look at what should work but I'm afraid to say I can't test this immediately.
Comment #5
eigentor commentedActually I already created a patch that works. Sorry for delay in upload. This patch works when the words "approve" "disapprove" and "cancel" have already been translated in another string.
Only the file "user_relationships_forms.inc" is patched. The whole thing is so simple you can easily change the two files by hand. It is just wrapping a t() function around $action two times.
Comment #6
alex.k commentedCommitted a third (sorry folks) implementation, it just provides three strings for the three messages depending on $action. Just thinking it is easier to translate a complete sentence into most languages, rather than pick up translations of single words which might need to be different in different contexts.
D6 branch also updated similarly. Thank you both for looking into it.