Hi Kevin,

It would be good to have this translation possibility.
Can you please add it to next stable version?

diff --git a/sites/all/modules/tablefield/tablefield.module b/sites/all/modules/tablefield/tablefield.module
index b97238d..a7e0818 100644
--- a/sites/all/modules/tablefield/tablefield.module
+++ b/sites/all/modules/tablefield/tablefield.module
@@ -791,6 +791,8 @@ function tablefield_rationalize_table($tablefield) {
       // $cell[1] is row count $cell[2] is col count
       if ((int) $cell[1] < $count_rows && (int) $cell['2'] < $count_cols) {
         $tabledata[$cell[1]][$cell[2]] = $value;
+        // Allow to translate just table headers via 'Translate interface'
+        if ( (int) $cell[1] == 0 ) { $tabledata[$cell[1]][$cell[2]] = t($value); }
       }
     }
   }

If it will be ok, or better/simpler solution, we can just add this:

+       $tabledata[$cell[1]][$cell[2]] = t($value);

..and be happy with simple translation of all values in the table, but I'm not sure if it's actually reasonable.

What do you think?

Best Regards
Luke

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

bisonbleu’s picture

I too would like to be able to translate just the table headers.

@lsokolowski, I've applied your patch but cannot find the table headers strings when I search for them in the Translate Interface UI (admin/config/regional/translate/translate). Ant ideas why and/or suggestions?

vitalie’s picture

Also would like to have this option. Here's an alternative patch. It passes headers through t() function in field_formatter_view function, so before display. This would allow introduction of another field formatter specifically for this use case and still leave the untranslatable one there. The patch does not do that however, since I think translatable headers is good to have in all cases.

bisonbleu’s picture

Patch in #2 works great for headers. Thanks @vitalie !

lolandese’s picture

Priority: Major » Normal
Status: Active » Closed (won't fix)

Taken from t | bootstrap.inc | Drupal 7.x | Drupal API:

You should never use t() to translate variables.

Furthermore t() is intended for translation of the interface. Content should be translated through regular 'content translation' that has its own mechanism.

That would not prohibit anyone from using the patch posted here at ones own discretion and is therefore still useful. It would just not be recommended to commit it to the module for the reasons just mentioned.