updated i18n i10n_update workflwo imachecache_actions
This commit is contained in:
@@ -12,47 +12,60 @@ CONTENTS OF THIS FILE
|
||||
INTRODUCTION
|
||||
------------
|
||||
|
||||
The Field translation module, part of the Internationalization (https://www.drupal.org/project/i18n) package, allows for translation of text associated with a field's settings including the label, help text, default value, and list options.
|
||||
The Field translation module, part of the Internationalization
|
||||
(https://www.drupal.org/project/i18n) package, allows for translation of text
|
||||
associated with a field's settings including the label, help text, default
|
||||
value, and list options.
|
||||
|
||||
* For a full description of the module, visit this page https://www.drupal.org/node/1279346
|
||||
* For a full description of the module, visit this page
|
||||
https://www.drupal.org/node/1279346.
|
||||
|
||||
* To submit bug reports and feature suggestions, or to track changes visit https://www.drupal.org/project/issues/i18n
|
||||
* To submit bug reports and feature suggestions, or to track changes visit
|
||||
https://www.drupal.org/project/issues/i18n.
|
||||
|
||||
|
||||
REQUIREMENTS
|
||||
------------
|
||||
|
||||
This module requires the following modules:
|
||||
This module requires the following module:
|
||||
|
||||
Internationalization (https://www.drupal.org/project/i18n)
|
||||
* Internationalization - https://www.drupal.org/project/i18n
|
||||
|
||||
|
||||
RECOMMENDED MODULES
|
||||
-------------------
|
||||
|
||||
* Internationalization Views (https://www.drupal.org/project/i18nviews)
|
||||
* Language Icons (https://www.drupal.org/project/languageicons)
|
||||
* Translation Overview (https://www.drupal.org/project/translation_overview)
|
||||
* Localization Client (https://www.drupal.org/project/l10n_client)
|
||||
* Internationalization contributions (https://www.drupal.org/project/i18n_contrib)
|
||||
* Internationalization Views - https://www.drupal.org/project/i18nviews
|
||||
* Language Icons - https://www.drupal.org/project/languageicons
|
||||
* Translation Overview - https://www.drupal.org/project/translation_overview
|
||||
* Localization Client - https://www.drupal.org/project/l10n_client
|
||||
* Internationalization contributions -
|
||||
https://www.drupal.org/project/i18n_contrib
|
||||
|
||||
|
||||
INSTALLATION
|
||||
------------
|
||||
|
||||
* This is a submodule of the Internationalization module. Install the Internationalization module as you would normally install a contributed Drupal module. Visit https://drupal.org/documentation/install/modules-themes/modules-7 for further information.
|
||||
This is a submodule of the Internationalization module. Install the
|
||||
Internationalization module as you would normally install a contributed Drupal
|
||||
module. Visit https://www.drupal.org/node/895232 for further information.
|
||||
|
||||
|
||||
CONFIGURATION
|
||||
-------------
|
||||
|
||||
1. Enable the Field translation module included with Internationalization.
|
||||
2. Go to Administration > Configuration > Regional and language > Translate interface.
|
||||
3. Click on Filter Translatable Strings field set and limit search to fields.
|
||||
2. Go to Administration > Configuration > Regional and language > Translate
|
||||
interface.
|
||||
3. Select the Filter Translatable Strings field set and limit search to fields.
|
||||
4. Edit the desired field and Save.
|
||||
For the translation to be displayed, you need to use some of the Field Formatters provided by this module whose name usually ends up in 'translated'. For most core fields it is Default translated.
|
||||
|
||||
Note: The Field Translation module does not provide content translation for fields. This functionality is provided by the Entity Translation (ET) module.
|
||||
For the translation to be displayed, the user needs to use some of the Field
|
||||
Formatters provided by this module whose name usually ends up in 'translated'.
|
||||
For most core fields it is Default translated.
|
||||
|
||||
Note: The Field Translation module does not provide content translation for
|
||||
fields. This functionality is provided by the Entity Translation (ET) module.
|
||||
|
||||
|
||||
MAINTAINERS
|
||||
|
||||
@@ -72,7 +72,7 @@ function i18n_field_i18n_string_info() {
|
||||
'description' => t('Configurable fields descriptions, defaults, options, etc.'),
|
||||
'format' => FALSE, // This group doesn't have formatted strings
|
||||
'list' => TRUE, // This group can list all strings
|
||||
'class' => 'i18n_string_textgroup_cached',
|
||||
'class' => variable_get('i18n_string_textgroup_class_field', 'i18n_string_textgroup_cached'),
|
||||
);
|
||||
return $groups;
|
||||
}
|
||||
|
||||
@@ -6,9 +6,8 @@ package = Multilingual - Internationalization
|
||||
core = 7.x
|
||||
files[] = i18n_field.inc
|
||||
files[] = i18n_field.test
|
||||
; Information added by Drupal.org packaging script on 2017-01-31
|
||||
version = "7.x-1.15"
|
||||
; Information added by Drupal.org packaging script on 2020-06-17
|
||||
version = "7.x-1.27"
|
||||
core = "7.x"
|
||||
project = "i18n"
|
||||
datestamp = "1485834792"
|
||||
|
||||
datestamp = "1592373390"
|
||||
|
||||
@@ -194,6 +194,9 @@ function i18n_field_field_widget_form_alter(&$element, &$form_state, $context) {
|
||||
// Single-value file fields and image fields.
|
||||
$alter_element = &$element[0];
|
||||
}
|
||||
elseif ($field['type'] == 'url' && $field['module'] == 'url' && $field['cardinality'] == 1) {
|
||||
$alter_element = &$element;
|
||||
}
|
||||
elseif (isset($element['value'])) {
|
||||
// Number fields. Single-value text fields.
|
||||
$alter_element = &$element['value'];
|
||||
@@ -202,6 +205,10 @@ function i18n_field_field_widget_form_alter(&$element, &$form_state, $context) {
|
||||
// Entityreference fields using the entityreference_autocomplete widget.
|
||||
$alter_element = &$element['target_id'];
|
||||
}
|
||||
elseif ($field['type'] == 'node_reference' && isset($element['nid'])) {
|
||||
// The node_reference fields using the entityreference_autocomplete widget.
|
||||
$alter_element = &$element['nid'];
|
||||
}
|
||||
else {
|
||||
// All other fields.
|
||||
$alter_element = &$element;
|
||||
@@ -456,6 +463,27 @@ function i18n_field_field_info_alter(&$field_info) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Prime the cache to avoid single db queries for entity fields / properties.
|
||||
*
|
||||
* This is mainly uses when large operations are occuring like a flush of the
|
||||
* entity_property_infos().
|
||||
*/
|
||||
function i18n_field_prime_caches() {
|
||||
global $language;
|
||||
static $cache_primed;
|
||||
|
||||
// Fill the cache. This should avoid single db queries when filling the
|
||||
// properties.
|
||||
if (empty($cache_primed)) {
|
||||
$cache_primed = TRUE;
|
||||
$text_group = i18n_string_textgroup('field');
|
||||
// Load all strings at once to avoid callbacks for each individual string.
|
||||
$text_group->load_strings();
|
||||
$text_group->multiple_translation_search(array('type' => '*', 'objectid' => '*', 'property' => '*'), $language->language);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Callback to translate entity property info for a fields.
|
||||
*
|
||||
@@ -478,6 +506,7 @@ function i18n_field_entity_property_callback(&$info, $entity_type, $field, $inst
|
||||
return;
|
||||
}
|
||||
|
||||
i18n_field_prime_caches();
|
||||
$name = $field['field_name'];
|
||||
$property = &$info[$entity_type]['bundles'][$instance['bundle']]['properties'][$name];
|
||||
$property['label'] = i18n_field_translate_property($instance, 'label', $language->language);
|
||||
@@ -491,9 +520,38 @@ function i18n_field_i18n_object_info_alter(&$info) {
|
||||
if ($info = drupal_static('i18n_object_info')) {
|
||||
// Clean static and permanent cache of the data and then re-run the property
|
||||
// building.
|
||||
drupal_static_reset('entity_get_property_info');
|
||||
cache_clear_all('entity_property_info:' . $GLOBALS['language']->language, 'cache');
|
||||
entity_get_property_info();
|
||||
// Use a lock to avoid stampeding.
|
||||
$lock_name = 'i18n_field_entity_property_callback_fallback:' . $GLOBALS['language']->language;
|
||||
// See if another request is already doing this. If so we bail out here as
|
||||
// we won't help with anything at the moment.
|
||||
if (!lock_may_be_available($lock_name)) {
|
||||
return;
|
||||
}
|
||||
if (lock_acquire($lock_name)) {
|
||||
i18n_field_prime_caches();
|
||||
// Inject translated properties.
|
||||
$entity_property_info = entity_get_property_info();
|
||||
foreach ($entity_property_info as $entity_type => $properties) {
|
||||
if (isset($properties['bundles'])) {
|
||||
foreach ($properties['bundles'] as $bundle => $bundle_properties) {
|
||||
if ($bundle_properties['properties']) {
|
||||
foreach ($bundle_properties['properties'] as $bundle_property => $bundle_property_info) {
|
||||
if ($instance = field_info_instance($entity_type, $bundle_property, $bundle)) {
|
||||
$property = &$entity_property_info[$entity_type]['bundles'][$instance['bundle']]['properties'][$bundle_property];
|
||||
$property['label'] = i18n_field_translate_property($instance, 'label', $GLOBALS['language']->language);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// Inject into static cache.
|
||||
$entity_get_property_info = &drupal_static('entity_get_property_info', array());
|
||||
$entity_get_property_info = $entity_property_info;
|
||||
// Write permanent cache.
|
||||
cache_set('entity_property_info:' . $GLOBALS['language']->language, $entity_property_info);
|
||||
lock_release($lock_name);
|
||||
}
|
||||
}
|
||||
else {
|
||||
watchdog('i18n_field', 'Unable to run fall-back handling for entity property translation due missing "i18n_object_info" cache', array(), WATCHDOG_WARNING);
|
||||
@@ -511,4 +569,4 @@ function i18n_field_module_implements_alter(&$implementations, $hook) {
|
||||
unset($implementations['i18n_field']);
|
||||
$implementations['i18n_field'] = $group;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user