Translation of quicktabs tab text

pndur - November 30, 2008 - 16:28
Project:Quick Tabs
Version:6.x-2.x-dev
Component:User interface
Category:feature request
Priority:normal
Assigned:Unassigned
Status:closed
Description

Can quicktabs tab texts be translated? Or, where can I add this support.

#1

Pasqualle - December 10, 2008 - 20:27

I am not supporting the translation of dynamic texts with the t() function call. But you can do it if you override the theme_quicktabs_tabs() function in your theme's template.php file like yourthemename_quicktabs_tabs().

you will have to copy all the parameters and the full content of this function. and you can apply t() function on $tab['title'] in this function, it is inside the <a> tag.

I will try to make the theme functions easier (maybe create theme templates). There is too many code inside these functions. Please keep in mind that you will have to make the changes in your theme file, when the original function is changed in the module..

#2

pndur - December 6, 2008 - 17:00

Thanks for your response

#3

Pasqualle - December 8, 2008 - 00:22

the given theme function theme_quicktabs_tabs() has been changed in the last commit. if you use it in your theme, then please update.

#4

Pasqualle - December 10, 2008 - 20:25
Category:support request» feature request

The translation of dynamic texts should be done with the i18n_strings module, but it needs additional development. I'll check how can I support the translation of tab titles..

#5

benklocek - March 12, 2009 - 22:20

Any status on the translation of tab text? In another thread/issue (http://drupal.org/node/303453) a possible solution is to allow the tabs to use the title of the content. This would then be the translated text, and allow for normal translation to occur, rather than in a theme, or other place.

#6

sidal1 - May 23, 2009 - 00:37

Hi,

I am trying to translate the tab texts too. I copied the theme_quicktabs_tabs() into my template.php and made the required changes, but Translate Interface cannot find the tab text I want to translate. I know the new function I copied is being used because I appended some random text to tab names and I was able to see them appearing on the tabs. I have a multisite setup with separate databases and my quicktabs module is under sites/all/modules. Can this be the reason? Am i missing anything for this to work?

Thanks a lot!

#7

Pasqualle - May 23, 2009 - 03:26

@sidal1: did you tried it with the Localization client module. That should pick up every string on your screen which is translatable.
The Drupal's built in interface does not find the strings which are not in the database..

#8

sidal1 - May 26, 2009 - 21:58

I could translate them with Localization client module :) Thanks a lot!

#9

jpbhat - June 13, 2009 - 06:32

Hi all how could i use Localization client module to transalte the title of quick tabs

thanks and regards
jp

#10

jpbhat - June 13, 2009 - 06:37

Hi all
I am facing the transaltion in quick tab s title

when i click english language its getting transalted

but when i click different language its not getting translated

i have put my quick tab in panel page

what is the problem weather i am doing right or wrong

pls help out

thanks and regrads
jp

#11

Junro - June 13, 2009 - 13:56

subscribe :)

Tab titles are not translable :(

#12

Pasqualle - June 13, 2009 - 15:28

first step is described in comment #1
second step is the l10n_client module..

what is the question?

#13

Junro - June 13, 2009 - 16:29

No question just subscribing :)

Oh ok sorry,

Just understand we couldn't implant the t() function with dynamic texts in order to make tab titles translation work.

#14

Pasqualle - June 13, 2009 - 19:51

dynamic texts should not be translated with the t() function, but many modules do that. Even I sometimes translate dynamic texts with t(), like using t() on views exposed filters, because it is easy.

The first problem is that the source string won't be automatically registered, so you need to use a tool like l10n_client which can find all translatable strings on the page. The second problem is when you change the source string the translations will be orphaned, and it is quite common to change a dynamic string..

The general solution would be to use the i18nstrings module which is created for dynamic text translation, but that would require additional dependency, and I guess most of the Quick Tabs users do not use the i18n module.

you can read additional info about this problem here: http://groups.drupal.org/node/15177
Please help to push some kind of solution into Drupal 7, and we could have a general solution for D6.. So QT may support translatable tab titles by default..

#15

Junro - June 13, 2009 - 20:03

Thanks a lot for theses explanations.... I understand very well now :)

I will test the solutions you're talked about and report if I find another solutions.

#16

naptown - August 26, 2009 - 17:43

The function override worked for me.

Here is the actual code (replace your theme name) if anyone is interested or doesn't want to dig through the module's code:

function YOURTHEMENAME_quicktabs_tabs($quicktabs, $active_tab = 'none') {
  $output = '';
  $tabs_count = count($quicktabs['tabs']);
  if ($tabs_count <= 0) {
    return $output;
  }

  $index = 1;
  $output .= '<ul class="quicktabs_tabs quicktabs-style-'. drupal_strtolower($quicktabs['style']) .'">';
  foreach ($quicktabs['tabs'] as $i => $tab) {
    $class = 'qtab-'. $i;
    // Add first, last and active classes to the list of tabs to help out themers.
    $class .= ($i == $active_tab ? ' active' : '');
    $class .= ($index == 1 ? ' first' : '');
    $class .= ($index == $tabs_count ? ' last': '');
    $attributes_li = drupal_attributes(array('class' => $class));
    $options = _quicktabs_construct_link_options($quicktabs, $i);
    $output .= '<li'. $attributes_li .'>'. l(t($tab['title']), $_GET['q'], $options) .'</li>';
    $index++;
  }
  $output .= '</ul>';
  return $output;
}

It would be nice to have this integrated within the module as an available option so the template code does not have to change after each upgrade. Maybe in an "Advanced" menu at the bottom of the quicktab parameters or do a check to see if the i18n module is activated, if so, add the t().

#17

blackdog - September 25, 2009 - 13:52
Component:Miscellaneous» User interface
Status:active» needs review

I've taken a stab at this since I need it right now. This patch does not add any dependencies, it checks if function tt (from i18nstrings.module) exists and uses it.

AttachmentSize
quicktabs_i18n.patch 1.9 KB

#18

Pasqualle - September 25, 2009 - 17:48

@blackdog: this patch looks great. Many thanks for jumping on this issue.

small things:
can you replace $i with $tabkey ($i mostly references to integer, but keys used in $quicktabs['tabs'] array could be strings also #332895: render quicktab programatically)

an I would replace

'quicktabs:tab:'.$quicktabs['qtid'].'-'.$i.':title'

with
"quicktabs:tab:{$quicktabs['qtid']}-$tabkey:title"

I think it is more readable..

#19

blackdog - September 26, 2009 - 10:26

Thanks Pasqualle, I've updated patch with your comments.

I'm not sure of you want to change the $i to $tabkey on the whole theme function? I've changed it in the refresh function in this patch.

AttachmentSize
quicktabs_i18n_2.patch 1.9 KB

#20

blackdog - September 26, 2009 - 10:29

Removed unnecessary $i++.

AttachmentSize
quicktabs_i18n_3.patch 1.91 KB

#21

Pasqualle - September 29, 2009 - 02:20
Status:needs review» fixed

thanks, committed a slightly modified version (used double dashes between $qtid--$tabkey)

http://drupal.org/cvs?commit=268838

the quicktab translation support added to the translation_table module also: http://drupal.org/cvs?commit=268836

#22

blackdog - September 29, 2009 - 07:17

Great stuff Pasqualle!

#23

System Message - October 13, 2009 - 07:20
Status:fixed» closed

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

 
 

Drupal is a registered trademark of Dries Buytaert.