class i18n_field in Internationalization 7
Field object
Hierarchy
- class \i18n_object_wrapper
- class \i18n_string_object_wrapper
- class \i18n_field_base
- class \i18n_field
- class \i18n_field_base
- class \i18n_string_object_wrapper
Expanded class hierarchy of i18n_field
3 string references to 'i18n_field'
- i18nFieldTestCase::setUp in i18n_field/
i18n_field.test - Sets up a Drupal site for running functional and integration tests.
- i18n_field_i18n_object_info in i18n_field/
i18n_field.i18n.inc - Implements hook_i18n_object_info().
- i18n_field_i18n_object_info_alter in i18n_field/
i18n_field.module - Implements hook_i18n_object_info_alter().
File
- i18n_field/
i18n_field.inc, line 33 - Field and field instance object handlers
View source
class i18n_field extends i18n_field_base {
/**
* Class constructor
*
* For convenience field objects can be built from field info and from field instance.
*/
public function __construct($type, $key, $object) {
parent::__construct($type, $key, $object);
// If this is a field instance, get field info but add instance data too.
// This instance data will be used to get the paths to get the edit/translate path.
if (isset($this->object['bundle']) && isset($this->object['entity_type'])) {
$this->object = field_info_field($this->object['field_name']) + array(
'bundle' => $this->object['bundle'],
'entity_type' => $object['entity_type'],
);
}
}
/**
* Get edit path for object
*/
public function get_edit_path() {
return $this
->get_base_path() . '/field-settings';
}
/**
* Get translate path for object
*/
public function get_translate_path($langcode = NULL) {
return $this
->get_base_path() . '/translate/field' . ($langcode ? '/' . $langcode : '');
}
/**
* Get string context
*/
public function get_string_context() {
return array(
$this->object['field_name'],
'#field',
);
}
/**
* Get translatable properties
*/
protected function build_properties() {
$properties = parent::build_properties();
$object = $this->object;
// For select fields field:field_name
if (!empty($object['settings']['allowed_values']) && i18n_field_type_info($object['type'], 'translate_options')) {
//return array('field', $field['field_name'], '#allowed_values');
foreach ($object['settings']['allowed_values'] as $key => $value) {
$properties[$this
->get_textgroup()][$object['field_name']]['#allowed_values'][$key] = array(
'title' => t('Option %name', array(
'%name' => $value,
)),
'string' => $value,
);
}
}
return $properties;
}
/**
* Context to be pre-loaded before translation.
*/
protected function get_translate_context($langcode, $options) {
return array(
$this->object['field_name'],
array(
'#field',
'#allowed_values',
),
'*',
);
}
/**
* Set field translation for object.
*
* Mot often, this is a direct field set, but sometimes fields may have different formats.
*
* @param $object
* A clone of the object or array. Field instance.
*/
protected function translate_field(&$object, $i18nstring, $langcode, $options) {
if ($i18nstring->objectid == '#allowed_values') {
$object['settings']['#allowed_values'][$i18nstring->key] = $i18nstring
->format_translation($langcode, $options);
}
else {
parent::translate_field($object, $i18nstring, $langcode, $options);
}
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
i18n_field:: |
protected | function |
Get translatable properties Overrides i18n_string_object_wrapper:: |
|
i18n_field:: |
public | function |
Get edit path for object Overrides i18n_object_wrapper:: |
|
i18n_field:: |
public | function |
Get string context Overrides i18n_string_object_wrapper:: |
|
i18n_field:: |
protected | function |
Context to be pre-loaded before translation. Overrides i18n_string_object_wrapper:: |
|
i18n_field:: |
public | function |
Get translate path for object Overrides i18n_string_object_wrapper:: |
|
i18n_field:: |
protected | function |
Set field translation for object. Overrides i18n_string_object_wrapper:: |
|
i18n_field:: |
public | function |
Class constructor Overrides i18n_object_wrapper:: |
|
i18n_field_base:: |
protected | function | Get base path for object | |
i18n_object_wrapper:: |
protected | property | ||
i18n_object_wrapper:: |
protected | property | ||
i18n_object_wrapper:: |
protected | property | ||
i18n_object_wrapper:: |
protected | property | ||
i18n_object_wrapper:: |
function | Get field value from object/array | ||
i18n_object_wrapper:: |
function | Get string numeric key for indexing. | ||
i18n_object_wrapper:: |
public | function | Get object info | |
i18n_object_wrapper:: |
function | Get key value from object/array | ||
i18n_object_wrapper:: |
public | function | Get language code | |
i18n_object_wrapper:: |
public | function | Get real object or array. | |
i18n_object_wrapper:: |
public | function | Get link for item | 2 |
i18n_object_wrapper:: |
protected | function | Get menu placehoders for object | |
i18n_object_wrapper:: |
public | function | Get object string translation info | |
i18n_object_wrapper:: |
public | function | Get title from item | 2 |
i18n_object_wrapper:: |
function | Menu access callback for mixed translation tab | ||
i18n_object_wrapper:: |
public | function | Get object translation set info | |
i18n_object_wrapper:: |
function | Get translation set id if any | ||
i18n_object_wrapper:: |
public | function | Get object type | |
i18n_object_wrapper:: |
function | Load real object or array. | 1 | |
i18n_object_wrapper:: |
function | Localize object if localizable. | ||
i18n_object_wrapper:: |
protected | function | Replace path with placeholders | |
i18n_object_wrapper:: |
function | Set field value to object/array | ||
i18n_object_wrapper:: |
function | Set translation set id | ||
i18n_object_wrapper:: |
protected | function | Translate access (translation sets) | 2 |
i18n_string_object_wrapper:: |
protected | property | ||
i18n_string_object_wrapper:: |
protected | property | ||
i18n_string_object_wrapper:: |
public | function | Get object translatable properties | |
i18n_string_object_wrapper:: |
public | function | Get object strings for translation | |
i18n_string_object_wrapper:: |
public | function | Get textgroup name | |
i18n_string_object_wrapper:: |
public | function |
Translation mode for object Overrides i18n_object_wrapper:: |
3 |
i18n_string_object_wrapper:: |
public | function | Load all existing strings for this object. | |
i18n_string_object_wrapper:: |
protected | function |
Translate access (localize strings) Overrides i18n_object_wrapper:: |
|
i18n_string_object_wrapper:: |
public | function | Remove all strings for this object. | |
i18n_string_object_wrapper:: |
public | function | Update all strings for this object. | |
i18n_string_object_wrapper:: |
protected | function | Get textgroup object | |
i18n_string_object_wrapper:: |
public | function |
Translate object. Overrides i18n_object_wrapper:: |
|
i18n_string_object_wrapper:: |
protected | function | Translate all properties for object. |