Why is t() not working as expected in thre following situation?
I am using Geolocation field module for D7 (drupal.org/project/geolocation). The strings inside this module which are used in the widget don't appear in the translate interface searches. All my other modules' strings are correctly showing up in translate interface. Also the strings coming from JS for that module (that are enclosed in Drupal.t()) works ok.
For example "Get location" string is not translatable.
Here is a part of the module:
function geolocation_googlemaps_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
// In order to make Geolocation field work with the popular Field collection module
// we check if our map widget is part of a Field collection and add the
// #field_parents delta.
if ($instance['entity_type'] == 'field_collection_item') {
$depth = count($element['#field_parents']) - 1;
$parent_delta = $element['#field_parents'][$depth];
$id = $instance['id'] . '-' . $parent_delta . '-' . $delta;
}
else {
$id = $instance['id'] . '-' . $delta;
}
$lat_value = isset($items[$delta]['lat']) ? $items[$delta]['lat'] : NULL;
// To make this widget compatible with geofiled we need to rename the keys for
// longitude. Geofield uses "lon" while Geolocation Field uses "lng".
if ($field['type'] == 'geofield') {
$lng_value = isset($items[$delta]['lon']) ? $items[$delta]['lon'] : NULL;
} else {
$lng_value = isset($items[$delta]['lng']) ? $items[$delta]['lng'] : NULL;
}
$element += array(
'#delta' => $delta,
);
switch ($instance['widget']['type']) {
case 'geolocation_googlemap':
$element['address'] = array(
'#type' => 'item',
'#title' => $element['#title'],
'#prefix' => '<div id="geolocation-address-' . $id . '" class="geolocation-address">',
'#suffix' => '</div>',
'#required' => $instance['required'],
);
$element['address']['field'] = array(
'#type' => 'textfield',
'#maxlength' => 120,
);
$element['address']['geocode'] = array(
'#prefix' => '<span id="geolocation-address-geocode-' . $id . '" class="geolocation-address-geocode">',
'#suffix' => '</span>',
'#markup' => t('Get location'),
);
$element['help'] = array(
'#prefix' => '<div id="geolocation-help-' . $id . '" class="geolocation-help">',
'#suffix' => '</div>',
'#markup' => t('Enter an address / location in the textfield or you can also click on the map to set a marker'),
);
$element['googlemap'] = array(
'#prefix' => '<div id="geolocation-map-' . $id . '" class="geolocation-map" style="width:100%;height:400px;">',
'#suffix' => '</div>',
);
// Presentational item.
$element['latitem'] = array(
'#type' => 'item',
'#title' => t('Latitude:'),
'#prefix' => '<div id="geolocation-lat-item-' . $id . '" class="geolocation-lat-item">',
'#suffix' => '</div>',
'#markup' => '<span class="geolocation-lat-item-value">' . $lat_value . '</span>',
'#required' => $instance['required'],
);
$element['lat'] = array(
'#type' => 'hidden',
'#prefix' => '<div id="geolocation-lat-' . $id . '" class="geolocation-lat">',
'#suffix' => '</div>',
'#default_value' => $lat_value,
);
// Presentational item.
$element['lngitem'] = array(
'#type' => 'item',
'#title' => t('Longitude:'),
'#prefix' => '<div id="geolocation-lng-item-' . $id . '" class="geolocation-lng-item">',
'#suffix' => '</div>',
'#markup' => '<span class="geolocation-lat-item-value">' . $lat_value . '</span>',
'#required' => $instance['required'],
);
$element['lng'] = array(
'#type' => 'hidden',
'#prefix' => '<div id="geolocation-lng-' . $id . '" class="geolocation-lng">',
'#suffix' => '</div>',
'#default_value' => $lng_value,
);
$element['remove'] = array(
'#prefix' => '<div id="geolocation-remove-' . $id . '" class="geolocation-remove"><span>',
'#suffix' => '</span></div>',
'#markup' => t('Remove'),
);
// Attach CSS and JS files via FAPI '#attached'.
$element['googlemap']['#attached']['css'][] = drupal_get_path('module', 'geolocation_googlemaps') . '/geolocation_googlemaps.css';
$element['googlemap']['#attached']['js'][] = array(
'data' => '//maps.google.com/maps/api/js?sensor=false',
'type' => 'external',
);
$element['googlemap']['#attached']['js'][] = array(
'data' => '//www.google.com/jsapi',
'type' => 'external',
);
$element['googlemap']['#attached']['js'][] = array(
'data' => drupal_get_path('module', 'geolocation_googlemaps') . '/geolocation_googlemaps_widget.js',
'type' => 'file',
'scope' => 'footer',
);
// Make defaults available as javascript settings. In JS files use:
// Drupal.settings.mapDefaults.lat
$map_defaults_lat = ($lat_value) ? $lat_value : '';
$map_defaults_lng = ($lng_value) ? $lng_value : '';
$map_defaults = array(
$id => array(
'lat' => $map_defaults_lat,
'lng' => $map_defaults_lng,
),
);
$data = array(
'defaults' => $map_defaults,
'settings' => $instance['widget']['settings'],
);
$element['googlemap']['#attached']['js'][] = array(
'data' => array('geolocation' => $data),
'type' => 'setting',
);
$element['field_type'] = array('#type' => 'value', '#value' => $field['type']);
$element['#element_validate'] = array('geolocation_googlemaps_field_widget_validate');
$element['#element_validate'][] = 'geolocation_googlemaps_field_widget_set_value';
break;
}
return $element;
}