It would be very useful to pass the title through the translate function when the tree is created. I want to use String Overrides module, or just translate interface, and I can't if I don't modify the module code.
This should be the result:
if(!$element['#leaves_only'] || count($term->children) == 0) {
$name = "edit-" . str_replace('_', '-', $element['#field_name']);
$e = array(
'#type' => ($max_choices == 1) ? 'radio' : 'checkbox',
'#title' => t($term->name), <----------- !!
'#on_value' => $term->tid,
'#off_value' => 0,
'#return_value' => $term->tid,
'#parent_values' => $parent_tids,
'#default_value' => isset($value[$term->tid]) ? $term->tid : NULL,
'#attributes' => isset($element['#attributes']) ? $element['#attributes'] : NULL,
'#ajax' => isset($element['#ajax']) ? $element['#ajax'] : NULL,
);
Thank youuuu!
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 1253284-term_reference_tree-i18n-3.patch | 3.01 KB | tnightingale |
| #1 | term_reference_tree-localized-terms-support.patch | 444 bytes | svdhout |
Comments
Comment #1
svdhout commentedI created a quick patch to support localized terms.
It could use improvements, but it gets the job done for
Comment #2
tnightingale commentedJust wanted to point out this fix in i18n #1340858: Language in entity_label() ensures that entity_label('taxonomy_term', $term) (http://api.drupal.org/api/drupal/includes--common.inc/function/entity_la...) will return the localized term name.
The end result is identical to this patch but it implements good practice using core api calls and makes the i18n dependency check is unnecessary.
Comment #3
tnightingale commentedThe patch in #1 wasn't working for us. I have rolled a patch that catches every case of $term->name and replaces it with entity_label('taxonomy_term', $term). As I mentioned in #3, this will result in the correctly localized term name if i18n dev (or the new i18n release when it comes out) is installed.
Comment #4
Marc-Antoine commentedI tested it with the latest i18n and tree ref release and it worked, thank you
Comment #5
bartk commentedThanks for the patch. I've included it in 1.7.
Comment #6
creando sensaciones commentedI hope I'm doing right by opening this thread again.
I'm using version 1.9 and facing the same problem: Localized terms are not translated, whatever I try. With other widgets they are.
I checked the code and found the function patched in #1 and #3 beeing totally different now.
So I guess with changing the method the problem returned.
My side design is very much depending on this amazing module. So I hope I find a way to fix this.
Thanks anyway.
Comment #7
creando sensaciones commentedI found the reason of missing localization in a conflict with the title module: http://drupal.org/node/1865604.
After installing the dev version of the title module everything seems fine.