Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
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.
Comment | File | Size | Author |
---|---|---|---|
#19 | 368510.patch | 6.04 KB | aufumy |
#18 | 368510.patch | 6.04 KB | aufumy |
#11 | content_profile_i18n_2.patch | 4.44 KB | andreiashu |
#7 | content_profile_i18n.patch | 4.4 KB | andreiashu |
#1 | content_profile.patch | 3.07 KB | neochief |
Comments
Comment #1
neochief CreditAttribution: neochief commentedMy 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.
Comment #2
fagoWhy 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...
Comment #3
fago>+ 'title' => 'Translate '. check_plain(drupal_ucfirst($type_name)),
This should be run through t() correctly using placeholders.
Comment #4
neochief CreditAttribution: neochief commentedYes, 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?
Comment #5
fago@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.
Comment #6
chaloalvarezj CreditAttribution: chaloalvarezj commentedThank 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)
Comment #7
andreiashu CreditAttribution: andreiashu commentedComment #8
andreiashu CreditAttribution: andreiashu commentedReally don't know why my comment wasn't inserted along with the attach... :(
Comment #9
neochief CreditAttribution: neochief commentedIt's a bug of d.org
Comment #10
andreiashu CreditAttribution: andreiashu commented@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.
Comment #11
andreiashu CreditAttribution: andreiashu commentedComment #12
strellman CreditAttribution: strellman commentedHow 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.
Comment #13
arhak CreditAttribution: arhak commentedif 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
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
Comment #14
arhak CreditAttribution: arhak commentedin the preprocess function it would be
Comment #15
arhak CreditAttribution: arhak commentedNOTE: 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 supportComment #16
arhak CreditAttribution: arhak commentedBTW 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
Comment #17
mairav CreditAttribution: mairav commentedThanks @arhak, I applyed the changes you suggest in comment #13 and works fine! Thank you very much.
Comment #18
aufumy CreditAttribution: aufumy commentedThis 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
Comment #19
aufumy CreditAttribution: aufumy commentedFixed small typo.
Comment #20
fagoThe content_profile_tt() approach looks certainly good. Is the patch still up2date? Any testers?
Comment #21
markus_petrux CreditAttribution: markus_petrux commentedI 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".
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
Comment #22
FiNeX CreditAttribution: FiNeX commentedI'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.
Comment #23
BoobaaSubscribing.
Comment #24
Anonymous (not verified) CreditAttribution: Anonymous commentedsubscribing
Comment #25
bisonbleu CreditAttribution: bisonbleu commentedPatch 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!