Route tab titles through t()

SamLerner - June 2, 2009 - 18:11
Project:Tabs panel style
Version:6.x-1.x-dev
Component:Code
Category:bug report
Priority:normal
Assigned:Unassigned
Status:needs work
Description

I found that the tab titles are not run through t() and therefore can't be translated. I'm attaching a patch that fixes this.

#1

SamLerner - June 2, 2009 - 18:12

Attaching patch for D5.

AttachmentSize
panels_tabs_i18n.patch 471 bytes

#2

Wim Leers - June 2, 2009 - 20:17
Title:Adding internationalization to tab titles» Route tab titles through t()
Category:support request» bug report
Status:needs review» fixed

Thanks! Committed to D5 and D6:

http://drupal.org/cvs?commit=219944
http://drupal.org/cvs?commit=219946

#3

dereine - June 4, 2009 - 19:50

what happens if the title of the content is dynamic? for example if a pane title is a node title

#4

Wim Leers - June 4, 2009 - 22:25

Then no translation will be found and all will be fine.

And yes, this is somewhat tricky, but Drupal's language/translation system doesn't properly support dynamic strings. Or at least it doesn't distinguish very clearly between them.

Or am I missing something? That's very well possible, I no experience with multilingual Drupal.

#5

dereine - June 4, 2009 - 22:41
Status:fixed» needs work

i know a site where some developers runned everything througth t() and this broke the site full, because the locale cache kills the performance.

and here is the code in the locale function:

<?php
   
// Either we have no such source string, or no translation
   
else {
     
$result = db_query("SELECT lid, source FROM {locales_source} WHERE source = '%s'", $string);
     
// We have no such translation
     
if ($obj = db_fetch_object($result)) {
        if (
$locale) {
         
db_query("INSERT INTO {locales_target} (lid, locale, translation) VALUES (%d, '%s', '')", $obj->lid, $locale);
        }
      }
?>

So if not translation can be found, its insert into the locales_target Database, and this is horrible :(
I set it to code needs work

#6

dereine - June 4, 2009 - 22:42

additional, i don't understand why this should be done by tabs panel style, this could be also done by panels

#7

Wim Leers - June 5, 2009 - 00:56

(I had typed this message and then closed the browser window. Stupid. That's what you get for working this late.)

#5: I had no idea it worked that way. It looks … weird to me that it works that way (that's a euphemism for "plain stupid" by the way). I'm pretty sure that I've done this incorrectly in just about every module of mine then.
But … how else can you do dynamic string translation in Drupal?

#6: Agreed. Patch reverted: http://drupal.org/cvs?commit=220972, http://drupal.org/cvs?commit=220974.

#8

dereine - June 5, 2009 - 06:25

thats what i18n does

there is a function tt() which works like t() but it uses a identifier like taxonomy:term:$tid

#9

Wim Leers - June 5, 2009 - 10:27

But the tt() function isn't in core. So … that'd be ugly. Are there clear docs on this anywhere?

#10

Wim Leers - October 15, 2009 - 09:18
Version:5.x-1.5» 6.x-1.x-dev

#11

nedjo - October 20, 2009 - 23:37

See http://drupal.org/node/304002 for some documentation.

 
 

Drupal is a registered trademark of Dries Buytaert.