I have a website in two languages using i18n - there is a content type for events that has a field for a link to a map to the event. I would like this link text to always appear as "Map of event location" in English, but as the same text in Spanish when we're on the Spanish side of the site. Is this possible?

Comments

iNade’s picture

Subscribing.

fmjrey’s picture

Version: 6.x-2.6 » 6.x-2.9
Category: support » feature

I also would like to be able to localize link title (or anchor text to be precise).

jcfiala’s picture

Assigned: Unassigned » jcfiala
Status: Active » Postponed (maintainer needs more info)

I'm not really sure how to do the localizing - it was my thought that the cck module handled that for fields if you're using localization. Anyone able to point me to helpful resources, that would be nice.

Patches are quite welcome too!

dafeder’s picture

The text needs to be run through the t() function to make it available to the translation system. So, if you just add the t() function anywhere you return something like $element['#item']['display_title'] it should become translatable.

dafeder’s picture

For instance:

--- link.module (saved version)
+++ (current document)
@@ -536,11 +536,11 @@
 function theme_link_formatter_default($element) {
   // Display a normal link if both title and URL are available.
   if (!empty($element['#item']['display_title']) && !empty($element['#item']['url'])) {
-    return l($element['#item']['display_title'], $element['#item']['url'], $element['#item']);
+    return l(t($element['#item']['display_title']), $element['#item']['url'], $element['#item']);
   }
   // If only a title, display the title.
   elseif (!empty($element['#item']['display_title'])) {
-    return check_plain($element['#item']['display_title']);
+    return check_plain(t($element['#item']['display_title']));
   }
 }
 
@@ -581,7 +581,7 @@
 
   $output = '';
   $output .= '<div class="link-item '. $class .'">';
-  $output .= '<div class="link-title">'. (empty($element['#item']['title']) ? '' : $element['#item']['display_title']) .'</div>';
+  $output .= '<div class="link-title">'. (empty($element['#item']['title']) ? '' : t($element['#item']['display_title'])) .'</div>';
   $output .= '<div class="link-url">'. l($element['#item']['display_url'], $element['#item']['url'], $element['#item']) .'</div>';
   $output .= '</div>';
   return $output;
iNade’s picture

So what about this, six month later ?

Just asking.

mxt’s picture

Please, I need this feature too.

Like fmjrey said, there have to be the possibility to localize link title (or anchor text to be precise).

Is the example posted by dafeder enough to implement this feature?

Thank you very much for your work!

mxt’s picture

Component: Miscellaneous » Code
Category: feature » bug
Priority: Normal » Major
Status: Postponed (maintainer needs more info) » Active

I think this issue has to be marked as BUG because, de facto, this module cannot be used in multilingual websites.

mortician’s picture

Another solution?

dqd’s picture

Priority: Major » Normal
Status: Active » Fixed

fixed in latest dev. please report back fo any leftovers.

Status: Fixed » Closed (fixed)

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