Drupal: update module - i18n

This commit is contained in:
Robert 2021-05-24 15:13:00 +02:00
parent 3df4aee5ef
commit e9708f5d4d
26 changed files with 216 additions and 63 deletions

View File

@ -8,8 +8,8 @@ files[] = i18n_object.inc
files[] = i18n.test
configure = admin/config/regional/i18n
; Information added by Drupal.org packaging script on 2020-06-17
version = "7.x-1.27"
; Information added by Drupal.org packaging script on 2021-04-26
version = "7.x-1.31"
core = "7.x"
project = "i18n"
datestamp = "1592373390"
datestamp = "1619398284"

View File

@ -233,7 +233,7 @@ function i18n_langcode($langcode = NULL) {
/**
* Implements hook_help().
*/
function i18n_help($path = 'admin/help#i18n', $arg) {
function i18n_help($path, $arg) {
switch ($path) {
case 'admin/help#i18n' :
$output = '<p>' . t('This module improves support for multilingual content in Drupal sites:') . '</p>';

View File

@ -8,8 +8,8 @@ files[] = i18n_block.inc
files[] = i18n_block.test
; Information added by Drupal.org packaging script on 2020-06-17
version = "7.x-1.27"
; Information added by Drupal.org packaging script on 2021-04-26
version = "7.x-1.31"
core = "7.x"
project = "i18n"
datestamp = "1592373390"
datestamp = "1619398284"

View File

@ -111,7 +111,7 @@ function i18n_block_block_list_alter(&$blocks) {
}
/**
* Implements hook_block_view().
* Implements hook_block_view_alter().
*/
function i18n_block_block_view_alter(&$data, $block) {
if (!empty($block->i18n_mode)) {

View File

@ -5,8 +5,8 @@ dependencies[] = i18n_string
package = Multilingual - Internationalization
core = 7.x
; Information added by Drupal.org packaging script on 2020-06-17
version = "7.x-1.27"
; Information added by Drupal.org packaging script on 2021-04-26
version = "7.x-1.31"
core = "7.x"
project = "i18n"
datestamp = "1592373390"
datestamp = "1619398284"

View File

@ -6,8 +6,8 @@ package = Multilingual - Internationalization
core = 7.x
files[] = i18n_field.inc
files[] = i18n_field.test
; Information added by Drupal.org packaging script on 2020-06-17
version = "7.x-1.27"
; Information added by Drupal.org packaging script on 2021-04-26
version = "7.x-1.31"
core = "7.x"
project = "i18n"
datestamp = "1592373390"
datestamp = "1619398284"

View File

@ -176,7 +176,7 @@ function i18n_field_field_widget_form_alter(&$element, &$form_state, $context) {
global $language;
// Don't translate if the widget is being shown on the field edit form.
if ($form_state['build_info']['form_id'] == 'field_ui_field_edit_form') {
if (isset($form_state['build_info']['form_id']) && $form_state['build_info']['form_id'] == 'field_ui_field_edit_form') {
return;
}
@ -398,12 +398,16 @@ function i18n_field_instance_update_strings($instance) {
* (number or text), values of the array are the display labels.
*/
function i18n_field_translate_allowed_values($field, $langcode = NULL) {
if (!empty($field['settings']['allowed_values'])) {
return i18n_string_translate(array('field', $field['field_name'], '#allowed_values'), $field['settings']['allowed_values'], array('langcode' => $langcode, 'sanitize' => FALSE));
}
else {
$allowed_values = list_allowed_values($field);
if (!$allowed_values) {
return array();
}
// Do not attempt to translate options from a callback.
$function = $field['settings']['allowed_values_function'];
if (!empty($function) && function_exists($function)) {
return $allowed_values;
}
return i18n_string_translate(array('field', $field['field_name'], '#allowed_values'), $allowed_values, array('langcode' => $langcode, 'sanitize' => FALSE));
}
/**

View File

@ -7,8 +7,8 @@ package = Multilingual - Internationalization
core = 7.x
files[] = i18n_forum.test
; Information added by Drupal.org packaging script on 2020-06-17
version = "7.x-1.27"
; Information added by Drupal.org packaging script on 2021-04-26
version = "7.x-1.31"
core = "7.x"
project = "i18n"
datestamp = "1592373390"
datestamp = "1619398284"

View File

@ -10,8 +10,8 @@ core = 7.x
files[] = i18n_menu.inc
files[] = i18n_menu.test
; Information added by Drupal.org packaging script on 2020-06-17
version = "7.x-1.27"
; Information added by Drupal.org packaging script on 2021-04-26
version = "7.x-1.31"
core = "7.x"
project = "i18n"
datestamp = "1592373390"
datestamp = "1619398284"

View File

@ -9,8 +9,8 @@ configure = admin/config/regional/i18n/node
files[]=i18n_node.test
files[]=i18n_node.variable.inc
; Information added by Drupal.org packaging script on 2020-06-17
version = "7.x-1.27"
; Information added by Drupal.org packaging script on 2021-04-26
version = "7.x-1.31"
core = "7.x"
project = "i18n"
datestamp = "1592373390"
datestamp = "1619398284"

View File

@ -260,7 +260,7 @@ function i18n_node_permission() {
function i18n_node_node_view($node, $view_mode, $langcode) {
if (i18n_node_type_enabled($node)) {
$extra_fields_display_settings = field_extra_fields_get_display('node', $node->type, $view_mode);
if ($extra_fields_display_settings['language']['visible']) {
if (isset($extra_fields_display_settings['language']['visible']) && $extra_fields_display_settings['language']['visible']) {
$node->content['language'] = array(
'#type' => 'item',
'#title' => t('Language'),

View File

@ -260,7 +260,7 @@ function i18n_node_nid2autocomplete($nid) {
*
* We also handle autocomplete values (title [nid:x]) and validate the form
*/
function i18n_node_autocomplete2nid($name, $field = NULL, $type, $language) {
function i18n_node_autocomplete2nid($name, $field, $type, $language) {
if (!empty($name)) {
preg_match('/^(?:\s*|(.*) )?\[\s*nid\s*:\s*(\d+)\s*\]$/', $name, $matches);
if (!empty($matches)) {

View File

@ -6,8 +6,8 @@ core = 7.x
files[] = i18n_path.inc
files[] = i18n_path.test
; Information added by Drupal.org packaging script on 2020-06-17
version = "7.x-1.27"
; Information added by Drupal.org packaging script on 2021-04-26
version = "7.x-1.31"
core = "7.x"
project = "i18n"
datestamp = "1592373390"
datestamp = "1619398284"

View File

@ -4,8 +4,8 @@ dependencies[] = i18n
package = Multilingual - Internationalization
core = 7.x
; Information added by Drupal.org packaging script on 2020-06-17
version = "7.x-1.27"
; Information added by Drupal.org packaging script on 2021-04-26
version = "7.x-1.31"
core = "7.x"
project = "i18n"
datestamp = "1592373390"
datestamp = "1619398284"

View File

@ -6,8 +6,8 @@ core = 7.x
configure = admin/config/regional/i18n/select
files[] = i18n_select.test
; Information added by Drupal.org packaging script on 2020-06-17
version = "7.x-1.27"
; Information added by Drupal.org packaging script on 2021-04-26
version = "7.x-1.31"
core = "7.x"
project = "i18n"
datestamp = "1592373390"
datestamp = "1619398284"

View File

@ -10,8 +10,8 @@ files[] = i18n_string.inc
files[] = i18n_string.test
configure = admin/config/regional/i18n/strings
; Information added by Drupal.org packaging script on 2020-06-17
version = "7.x-1.27"
; Information added by Drupal.org packaging script on 2021-04-26
version = "7.x-1.31"
core = "7.x"
project = "i18n"
datestamp = "1592373390"
datestamp = "1619398284"

View File

@ -153,6 +153,15 @@ function i18n_string_menu_alter(&$items) {
'file' => 'i18n_string.pages.inc',
'file path' => drupal_get_path('module', 'i18n_string'),
);
$items['admin/config/regional/translate/translate'] = array(
'title' => 'Translate',
'weight' => 10,
'type' => MENU_LOCAL_TASK,
'page callback' => 'i18n_string_locale_translate_seek_screen',
'access arguments' => array('translate interface'),
'file' => 'i18n_string.pages.inc',
'file path' => drupal_get_path('module', 'i18n_string'),
);
}
/**

View File

@ -459,3 +459,143 @@ function _i18n_string_translate_format_help($format_id) {
}
return $output;
}
/**
* String search & translate screen.
*
* Almost exactly the same as the core locale module's implementation, but
* taking i18n_string_source_language into account for the languages column.
*/
function i18n_string_locale_translate_seek_screen() {
// Add CSS.
drupal_add_css(drupal_get_path('module', 'locale') . '/locale.css');
$elements = drupal_get_form('locale_translation_filter_form');
$output = drupal_render($elements);
$output .= _i18n_string_locale_translate_seek();
return $output;
}
/**
* Perform a string search and display results in a table
*/
function _i18n_string_locale_translate_seek() {
$output = '';
// We have at least one criterion to match
if (!($query = _locale_translate_seek_query())) {
$query = array(
'translation' => 'all',
'group' => 'all',
'language' => 'all',
'string' => '',
);
}
$sql_query = db_select('locales_source', 's');
$limit_language = NULL;
if ($query['language'] != 'en' && $query['language'] != 'all') {
$sql_query->leftJoin('locales_target', 't', "t.lid = s.lid AND t.language = :langcode", array(':langcode' => $query['language']));
$limit_language = $query['language'];
}
else {
$sql_query->leftJoin('locales_target', 't', 't.lid = s.lid');
}
$sql_query->fields('s', array('source', 'location', 'context', 'lid', 'textgroup'));
$sql_query->fields('t', array('translation', 'language'));
// Compute LIKE section.
switch ($query['translation']) {
case 'translated':
$sql_query->condition('t.translation', '%' . db_like($query['string']) . '%', 'LIKE');
$sql_query->orderBy('t.translation', 'DESC');
break;
case 'untranslated':
$sql_query->condition(db_and()
->condition('s.source', '%' . db_like($query['string']) . '%', 'LIKE')
->isNull('t.translation')
);
$sql_query->orderBy('s.source');
break;
case 'all' :
default:
$condition = db_or()
->condition('s.source', '%' . db_like($query['string']) . '%', 'LIKE');
if ($query['language'] != 'en') {
// Only search in translations if the language is not forced to English.
$condition->condition('t.translation', '%' . db_like($query['string']) . '%', 'LIKE');
}
$sql_query->condition($condition);
break;
}
// Add a condition on the text group.
if (!empty($query['group']) && $query['group'] != 'all') {
$sql_query->condition('s.textgroup', $query['group']);
}
$sql_query = $sql_query->extend('PagerDefault')->limit(50);
$locales = $sql_query->execute();
$groups = module_invoke_all('locale', 'groups');
$header = array(t('Text group'), t('String'), t('Context'), ($limit_language) ? t('Language') : t('Languages'), array('data' => t('Operations'), 'colspan' => '2'));
$strings = array();
foreach ($locales as $locale) {
if (!isset($strings[$locale->lid])) {
$strings[$locale->lid] = array(
'group' => $locale->textgroup,
'languages' => array(),
'location' => $locale->location,
'source' => $locale->source,
'context' => $locale->context,
);
}
if (isset($locale->language)) {
$strings[$locale->lid]['languages'][$locale->language] = $locale->translation;
}
}
$rows = array();
foreach ($strings as $lid => $string) {
$rows[] = array(
$groups[$string['group']],
array('data' => check_plain(truncate_utf8($string['source'], 150, FALSE, TRUE)) . '<br /><small>' . $string['location'] . '</small>'),
$string['context'],
array('data' => _i18n_string_locale_translate_language_list($string, $limit_language), 'align' => 'center'),
array('data' => l(t('edit'), "admin/config/regional/translate/edit/$lid", array('query' => drupal_get_destination())), 'class' => array('nowrap')),
array('data' => l(t('delete'), "admin/config/regional/translate/delete/$lid", array('query' => drupal_get_destination())), 'class' => array('nowrap')),
);
}
$output .= theme('table', array('header' => $header, 'rows' => $rows, 'empty' => t('No strings available.')));
$output .= theme('pager');
return $output;
}
/**
* List languages in search result table.
*/
function _i18n_string_locale_translate_language_list($string, $limit_language) {
// Add CSS.
drupal_add_css(drupal_get_path('module', 'locale') . '/locale.css');
// Include both translated and not yet translated target languages in the
// list. The source language is English for built-in strings and the default
// language for other strings.
$languages = language_list();
$default = language_default();
$omit = $string['group'] == 'default' ? 'en' : variable_get('i18n_string_source_language', $default->language);
unset($languages[$omit]);
$output = '';
foreach ($languages as $langcode => $language) {
if (!$limit_language || $limit_language == $langcode) {
$output .= (!empty($string['languages'][$langcode])) ? $langcode . ' ' : "<em class=\"locale-untranslated\">$langcode</em> ";
}
}
return $output;
}

View File

@ -10,8 +10,8 @@ files[] = i18n_sync.install
files[] = i18n_sync.module.inc
files[] = i18n_sync.node.inc
files[] = i18n_sync.test
; Information added by Drupal.org packaging script on 2020-06-17
version = "7.x-1.27"
; Information added by Drupal.org packaging script on 2021-04-26
version = "7.x-1.31"
core = "7.x"
project = "i18n"
datestamp = "1592373390"
datestamp = "1619398284"

View File

@ -11,8 +11,8 @@ files[] = i18n_taxonomy.pages.inc
files[] = i18n_taxonomy.admin.inc
files[] = i18n_taxonomy.test
; Information added by Drupal.org packaging script on 2020-06-17
version = "7.x-1.27"
; Information added by Drupal.org packaging script on 2021-04-26
version = "7.x-1.31"
core = "7.x"
project = "i18n"
datestamp = "1592373390"
datestamp = "1619398284"

View File

@ -383,8 +383,8 @@ function i18n_taxonomy_allowed_values($field) {
if ($vocabulary = taxonomy_vocabulary_machine_name_load($tree['vocabulary'])) {
if (i18n_taxonomy_vocabulary_mode($vocabulary->vid) == I18N_MODE_TRANSLATE) {
$parent = i18n_taxonomy_translation_term_tid($tree['parent'], NULL, $tree['parent']);
$language = i18n_language_context();
$terms = i18n_taxonomy_get_tree($vocabulary->vid, $language->language, $parent);
$context_language = i18n_language_context();
$terms = i18n_taxonomy_get_tree($vocabulary->vid, $context_language->language, $parent);
}
else {
$terms = taxonomy_get_tree($vocabulary->vid, $tree['parent']);

View File

@ -12,7 +12,7 @@ an Entity thus leveraging all the power of the Entity API.
It also provides some basic storage for translation sets and a generator of new translation set id.
However, each module is responsible for storing which objects belong to which translation set for which
it needs to verride some methods of the base i18n_translation_set class.
it needs to override some methods of the base i18n_translation_set class.
- load_translations()
- save_translations()

View File

@ -6,8 +6,8 @@ core = 7.x
files[] = i18n_translation.inc
; Information added by Drupal.org packaging script on 2020-06-17
version = "7.x-1.27"
; Information added by Drupal.org packaging script on 2021-04-26
version = "7.x-1.31"
core = "7.x"
project = "i18n"
datestamp = "1592373390"
datestamp = "1619398284"

View File

@ -4,8 +4,8 @@ core = 7.x
package = Multilingual - Internationalization
dependencies[] = i18n_variable
; Information added by Drupal.org packaging script on 2020-06-17
version = "7.x-1.27"
; Information added by Drupal.org packaging script on 2021-04-26
version = "7.x-1.31"
core = "7.x"
project = "i18n"
datestamp = "1592373390"
datestamp = "1619398284"

View File

@ -10,8 +10,8 @@ configure = admin/config/regional/i18n/variable
files[] = i18n_variable.class.inc
files[] = i18n_variable.test
; Information added by Drupal.org packaging script on 2020-06-17
version = "7.x-1.27"
; Information added by Drupal.org packaging script on 2021-04-26
version = "7.x-1.31"
core = "7.x"
project = "i18n"
datestamp = "1592373390"
datestamp = "1619398284"

View File

@ -7,8 +7,8 @@ package = Testing
core = 6.x
hidden = TRUE
; Information added by Drupal.org packaging script on 2020-06-17
version = "7.x-1.27"
; Information added by Drupal.org packaging script on 2021-04-26
version = "7.x-1.31"
core = "7.x"
project = "i18n"
datestamp = "1592373390"
datestamp = "1619398284"