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.
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
Comment | File | Size | Author |
---|---|---|---|
#2 | tablefield-translate_headers-2327349-2.patch | 677 bytes | vitalie |
tablefield-allow-to-translate-headers.patch | 680 bytes | lsokolowski | |
Comments
Comment #1
bisonbleu CreditAttribution: bisonbleu commentedI 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?
Comment #2
vitalie CreditAttribution: vitalie commentedAlso 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.
Comment #3
bisonbleu CreditAttribution: bisonbleu commentedPatch in #2 works great for headers. Thanks @vitalie !
Comment #4
lolandese CreditAttribution: lolandese at HCL Technologies Limited commentedTaken from t | bootstrap.inc | Drupal 7.x | Drupal API:
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.