User Profile - patch to add fields translations
mimamim - February 18, 2009 - 09:33
| Project: | User Profile |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | mimamim |
| Status: | needs review |
| Issue tags: | Drupal 6, i18n, translation, user profile |
Description
Unfortunately, user profile module doesn't looks for translations for field names, list values, category names. This is my patch. Line numbers taken from version 6.8, but it looks like that this patch can be applied also to earlier versions.
File profile.module
function profile_view_field($user, $field), line 264
return $browse ? l($field->title, "profile/$field->name") : check_plain($field->title); return $browse ? l(t($field->title), "profile/$field->name") : check_plain(t($field->title));function profile_view_profile(&$user), line 312
$title = ($field->type != 'checkbox') ? check_plain($field->title) : NULL; $title = ($field->type != 'checkbox') ? check_plain(t($field->title)) : NULL;function _profile_form_explanation($field), line 334
$output = $field->explanation; $output = t($field->explanation);function profile_form_profile($edit, $user, $category, $register = FALSE), line 352
$category = $field->category; $category = t($field->category);
$field->title = t($field->title);line 399
$options[$line] = $line; $options[$line] = t($line); function profile_categories(), line 457
'title' => $category->category, 'title' => t($category->category),file profile.pages.inc, function profile_browse(), line 71:
if ($field->type == 'selection' || $field->type == 'list' || $field->type == 'textfield') {
$title = strtr(check_plain($field->page), array('%value' => theme('placeholder', $value)));
} if ($field->type == 'selection') {
$title = strtr(check_plain(t($field->page)), array('%value' => theme('placeholder', t($value))));
}
else if ($field->type == 'list' || $field->type == 'textfield') {
$title = strtr(check_plain(t($field->page)), array('%value' => theme('placeholder', $value)));
}
#1
file profile.module, function profile_view_field($user, $field), line 262
case 'textfield':case 'selection':
return $browse ? l($value, 'profile/'. $field->name .'/'. $value) : check_plain($value);
case 'textfield':return $browse ? l($value, 'profile/'. $field->name .'/'. $value) : check_plain($value);
case 'selection':
return $browse ? l(t($value), 'profile/'. $field->name .'/'. $value) : check_plain(t($value));
#2
profile.module, function profile_view_profile(&$user), line 318
'#title' => $field->category,'#title' => t($field->category),#3
Thanks :)
They should add this in the next drupal release...
#4
erf line number are not exactly the same in my version, for exemple line 264 :
return $browse ? l($value, 'profile/'. $field->name .'/'. $value) : check_plain($value);I'm not expert in php, I prefer to wait... hopping it will come soon :)
#5
Perfect! Looks to work fine! Thanks :)
#6
Thanks for this. All seems to works - except for the links/buttons under: My Account/Edit Eg, 'Personal Information', 'My Newsletter'...'Account' is the only one that does translate.
Somehow, while messing with Refresh on the Translate Interface and Clear Cache with Devel, I managed to get them all to translate (to French) but then they stuck and wouldn't translate to English! I got them back again after more messing about - but can't make this happen again.
Any help appreciated.
#7
Yes - if I clear the cache while in English - they remain stuck in English after switching to French - and when I clear the cache in French then they stick in French after switching to English. Odd!
I used the String Overrides module to translate the text - that the right way?
#8
Now I've got the categories to translate - but only if I have the sites default language set to English. My sites default needs to be French. Thought the problem might be similar to the Content Types one - http://drupal.org/node/228610 - but that fix doesn't work for this problem. (It's not supposed to be a good idea to keep changing your sites default language anyway.)
#9
You should realy have english as default language, trust me on that!
#10
But if I do, visitors (who will mostly be French) get the front page in En. Can't find away around that apart from setting the default language to Fr.
#11
Here's some more links relating to this problem:
User category (submenu in the user profile) is not translatable - http://drupal.org/node/367323
Profile module translation and selection type "addon" - http://drupal.org/node/400396
Help with this problem appreciated!