Hello

If you have a multilang site, there's no any posibility to translate a profile title on user's page. I made a patch to fix this.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

neochief’s picture

Title: Unable to translate profile title on user's page » Profile translation
FileSize
3.07 KB

My solution wasn't complete.
1) Profile tabs can not be localized
2) I noticed that there are no "Translate" tab on profile pages, if you're using multilang. I've added it.

Here's a complete patch.

fago’s picture

Status: Needs review » Needs work

Why can't we reuse the callbacks from the translation module?

>1) Profile tabs can not be localized

We can't run them through t(), only fixed texts should be run through t(). For this there is tt() from the i18n module, so we would need to integrate with that. Probably best is to add a wrapper for tt() that checks whether i18n is active...

fago’s picture

>+ 'title' => 'Translate '. check_plain(drupal_ucfirst($type_name)),

This should be run through t() correctly using placeholders.

neochief’s picture

Yes, I agree that this looks a bit hacky. Just wanted to get some feedback.

We can't reuse translation callbacks, because we're loosing all tabs from user scope.

As for tt()... well, I didn't know about it until today :) I supose it bring dependency to i18n?

fago’s picture

@dependency for localisation:
>Probably best is to add a wrapper for tt() that checks whether i18n is active...

We should do that wrapper which checks for i18n and if not available just passes the string through. This way we can avoid the dependency. Then we should run all node type names through it.

@profile translation:
I'm a bit unsure if we should put that in the "base" module, as it should be kept as small and simple as possible. However as of now the patch is rather small and I don't think we need later more to support profile translation? Opinions?

Also I wonder if the translation tab should just beside of the usual tab or it would make sense to create sub-tabs?

@patch:
I think it also misses a check whether the node type is translatable. Does the translation overview work right even there is no node yet? Does it make sense to show it if there is none?

Quite some questions, so perhaps we start with the localisation task first, which is more important in my eyes.

chaloalvarezj’s picture

Thank you for the patch.. I applied the patch in #1, and the content profile title on user's page is indeed translated, but only when the link is placed as a tab. When the link is placed as a sub tab of the used edit tab, the title remains untranslated... I have tried placing the t() function on different places without success...

Any help will be appreciated...

P.S. I have also changed the following:

$text = t($element['#admin'] ? "Create the user's @profile_node." : "Create your @profile_node.", array('@profile_node' => node_get_types('name', $type)));

TO

$text = t($element['#admin'] ? "Create the user's @profile_node." : "Create your @profile_node.", array('@profile_node' => t(node_get_types('name', $type))));

Which will make the "Create your @profile_node" string, translatable (Maybe not the best way to do it, but it worked)

andreiashu’s picture

andreiashu’s picture

Really don't know why my comment wasn't inserted along with the attach... :(

neochief’s picture

It's a bug of d.org

andreiashu’s picture

@neochief: thanks, i hope it is solved soon :) it is a little bit frustrating to loose your comments

@#5
1. @dependency for localisation: i added the function cp_tt. it checks for the existence of function 'tt' and then proceeds accordingly
2. @profile translation: my opinion is that we should move it into another module and maybe have subtabs.
3. @"it also misses a check whether the node type is translatable." - i did not take care of this yet

I'll attach the patch soon.

andreiashu’s picture

strellman’s picture

How about a different approach?

Since the tabs and edit tabs do not follow the normal pattern within Drupal, your average user might not look for a profile tab in the right place anyway, no matter where you put it.
Show a tab at the user's page
Show a secondary tab below the user's edit tab

What if you created a regular menu item for the navigation menu called "My profile" right after "My account". Menus can be easily translated and the profile display would have a normal edit tab. Us non-programmers can't do it because we can't supply a path that includes the user number into the D6 menu system.

arhak’s picture

Status: Needs work » Needs review

if you are looking to change content type titles then enable i18ncontent module and work with translations through tt("nodetype:type:$type:title"

for having this fixed it would be enough to change the .tpl
appending a conditional before print $title

  <?php if (module_exists('i18ncontent')) $title = tt("nodetype:type:$type:name", $title); ?>
  <?php print $title; ?>

this will work for users needing this

nevertheless, it should be done right in the preprocess function

but as you can see, there is no need for such a complicated patch on this

arhak’s picture

in the preprocess function it would be

  $title = node_get_types('name', $node->type);
  if (module_exists('i18ncontent')) $title = tt("nodetype:type:$type:name", $title);
  $variables['title'] = check_plain($title);
arhak’s picture

Title: Unable to translate profile title on user's page » Profile translation

NOTE: only apply ONE of these solutions #13 OR #14, but not both of them at the same time

ALSO NOTE: if your site has been running with different default languages you might find some others problems, I'm working on a patch to attempt some support on this, but I don't promise anything, since switching default language shouldn't be done

EDIT: #582438: improve content types UI support

arhak’s picture

Title: Profile translation » Unable to translate profile title on user's page

BTW my comments are with respect the original issue
since there is another issue dealing with the more general solution #461262: Content profile can't handle translated profiles

mairav’s picture

Title: Profile translation » Unable to translate profile title on user's page

Thanks @arhak, I applyed the changes you suggest in comment #13 and works fine! Thank you very much.

aufumy’s picture

FileSize
6.04 KB

This patch is similar to #11, in that it has a wrapper for tt(), and uses it for translating node types.

Some differences
* does not have the other hook_menu item content_profile_translation_node_overview
* the wrapper function uses module_exists(), no need for static variable, as module_exists() already does this

aufumy’s picture

Title: Unable to translate profile title on user's page » Translate node types
Version: 6.x-1.0-beta3 » 6.x-1.x-dev
FileSize
6.04 KB

Fixed small typo.

fago’s picture

The content_profile_tt() approach looks certainly good. Is the patch still up2date? Any testers?

markus_petrux’s picture

Status: Needs review » Needs work

I just tested the patch in #19 and works, except for a couple of things:

1) typo in content_profile_menu_tt() using "title" where it should use "name".

 function content_profile_menu_tt($type, $name) {
-  return drupal_ucfirst(check_plain(content_profile_tt("nodetype:type:$type:title", $name)));
+  return drupal_ucfirst(check_plain(content_profile_tt("nodetype:type:$type:name", $name)));
 }

2) I would prefer not to use content_profile_tt() in content_profile_user(). Why?

Because I think user module in Drupal 6 core has a bug in the way it builds the menu items for user profile categories. user module uses check_plain() as the title callback for these menu items, therefore it does not use t(), hence these menu items will never be translated. If we use content_profile_tt() here, they will be shown in the language which is active when the menu is rebuilt. However, I think content profile was ok passing the original type name, and it is Drupal core that needs to be fixed. For the title callback of these menu items, it should use a function that invokes t(), and the check_plain(). I do not know if this bug has been reported to Drupal core, though. :-/

[EDIT] I just created a bug report about this problem in user module:

- #696924: Menu items for user categories cannot be translated

FiNeX’s picture

I've tried the http://drupal.org/files/issues/368510_0.patch patch, but when the user edit his content profile node, it isn't possible to edit the second language.

Boobaa’s picture

Subscribing.

Anonymous’s picture

subscribing

bisonbleu’s picture

Patch in #19 + fixing typo as suggested in #21 applied to content_profile-6.x-1.x-dev. works for me.

I have a multilingual Ubercart setup that uses Content profile and ANT. The name of the content type I use as a content profile for users (User folder), although properly translated, would'not change as expected when changing from English to French UI. Now it does.

Thanks!