updated i18n, views, imagestyleflush, field_group

patch views_rss_media
This commit is contained in:
2019-05-14 10:14:51 +02:00
parent 9adc940a67
commit c97e0f8ba1
142 changed files with 4489 additions and 786 deletions

View File

@@ -0,0 +1,94 @@
CONTENTS OF THIS FILE
---------------------
* Introduction
* Requirements
* Recommended modules
* Installation
* Configuration
* Maintainers
INTRODUCTION
------------
The String translation module, part of the Internationalization
(https://www.drupal.org/project/i18n) package, provides support for other
modules to translate user-defined strings. This is an API module that must be
enabled only when required by other modules in the i18n package.
* For a full description of the module, visit this page:
https://www.drupal.org/node/1279668
* To submit bug reports and feature suggestions, or to track changes:
https://www.drupal.org/project/issues/i18n
REQUIREMENTS
------------
This module requires the following module:
* 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
INSTALLATION
------------
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
-------------
Strings will be translated from the source languages. By default the source
language is the site's default language, so changing the default language could
break these translations.
1. The user can set which language is used as the source language via
Administration > Configuration > Regional and language > Multilingual
settings > Strings. By default, only plain strings are enabled, so regular
blocks are not fully translatable.
2. To allow Filtered HTML, Full HTML or Plain text select the appropriate radio
box(es) and Save configuration.
3. To select the strings to be translated navigate to Administration >
Configuration > Regional and language > Translate interface and select on
Stings vertical tab. From here the user can select which text groups to
translate and select the Refresh strings tab.
FAQ
---
The String translation module allows you to configure which text formats are
translatable. Formats like PHP Filter and Full HTML are translated before they
are processed, so allowing a translator to edit these can be a security risk.
This is particularly problematic when importing translations in bulk from a CSV
file, since the translator's access to the import formats isn't verified by
Drupal. After updating this setting, be sure to refresh the strings via
Administration > Configuration > Regional and language > Translate interface >
Strings so that strings in forbidden formats are deleted.
MAINTAINERS
-----------
* Jose Reyero - https://www.drupal.org/u/jose-reyero
* Florian Weber (webflo) - https://www.drupal.org/u/webflo
* Peter Philipp - https://www.drupal.org/u/das-peter
* Joseph Olstad - https://www.drupal.org/u/joseph.olstad
* Nathaniel Catchpole - https://www.drupal.org/u/catch

View File

@@ -703,9 +703,19 @@ class i18n_string_textgroup_default {
// Create source string so we get an lid
$this->save_source($string);
}
// Convert objectid to objectkey if it's numeric.
if (!isset($string->objectkey)) {
$string->objectkey = (int)$string->objectid;
if (is_numeric($string->objectid)) {
$string->objectkey = (int)$string->objectid;
}
}
// Make sure objectkey is numeric.
if (!is_numeric($string->objectkey)) {
$string->objectkey = 0;
}
if (!isset($string->format)) {
$string->format = '';
}
@@ -1166,10 +1176,17 @@ class i18n_string_object_wrapper extends i18n_object_wrapper {
$info = is_array($info) ? $info : array('title' => $info);
$field_name = isset($info['field']) ? $info['field'] : $field;
$value = $this->get_field($field_name);
if (is_array($value) && isset($value['value'])) {
$format = isset($value['format']) ? $value['format'] : NULL;
$value = $value['value'];
}
else {
$format = isset($info['format']) ? $this->get_field($info['format']) : NULL;
}
$strings[$this->get_textgroup()][$string_type][$object_id][$field] = array(
'string' => is_array($value) || isset($info['empty']) && $value === $info['empty'] ? NULL : $value,
'title' => $info['title'],
'format' => isset($info['format']) ? $this->get_field($info['format']) : NULL,
'format' => $format,
'name' => array_merge($object_keys, array($field)),
);
}
@@ -1481,7 +1498,12 @@ class i18n_string_textgroup_cached extends i18n_string_textgroup_default {
foreach ($context as $key => $value) {
if ($value != '*') {
$try = array_merge($context, array($key => '*'));
return $this->multiple_cache_get($try);
$cached_results = $this->multiple_cache_get($try);
// Now filter the ones that actually match.
if (!empty($cached_results)) {
$cached_results = $this->string_filter($cached_results, $context);
}
return $cached_results;
}
}
}

View File

@@ -10,9 +10,8 @@ files[] = i18n_string.inc
files[] = i18n_string.test
configure = admin/config/regional/i18n/strings
; Information added by Drupal.org packaging script on 2015-05-07
version = "7.x-1.13"
; Information added by Drupal.org packaging script on 2018-08-17
version = "7.x-1.26"
core = "7.x"
project = "i18n"
datestamp = "1430999922"
datestamp = "1534531985"

View File

@@ -94,6 +94,7 @@ function i18n_string_schema() {
),
'objectindex' => array(
'type' => 'int',
'size' => 'big',
'not null' => TRUE,
'default' => 0,
'description' => 'Integer value of Object ID.',
@@ -245,6 +246,24 @@ function i18n_string_update_7002() {
}
}
/**
* Removed due to buggy upgrade for #2200647.
*/
function i18n_string_update_7003() {
}
/**
* Change objectindex from int to bigint.
*/
function i18n_string_update_7004() {
db_change_field('i18n_string', 'objectindex', 'objectindex', array(
'type' => 'int',
'size' => 'big',
'not null' => TRUE,
'default' => 0,
'description' => 'Integer value of Object ID.',
));
}
/**
* Notes for update script

View File

@@ -118,13 +118,14 @@ function i18n_string_menu() {
'file' => 'i18n_string.admin.inc',
'access arguments' => array('translate interface'),
);
$items['admin/config/regional/i18n/strings'] = array(
'title' => 'Strings',
'description' => 'Options for user defined strings.',
'weight' => 20,
'type' => MENU_LOCAL_TASK,
'page callback' => 'drupal_get_form',
'page arguments' => array('variable_edit_form', array('i18n_string_allowed_formats', 'i18n_string_source_language')),
'page arguments' => array('variable_edit_form', array('i18n_string_allowed_formats', 'i18n_string_source_language', 'i18n_string_textgroup_class_[textgroup]')),
'access arguments' => array('administer site configuration'),
);
// AJAX callback path for strings.
@@ -258,6 +259,34 @@ function i18n_string_locale_translate_import_form_submit($form, &$form_state) {
}
}
/**
* Implements hook_element_info_alter().
*
* We need to do this on the element info level as wysiwyg also does so and form
* API (incorrectly) does not merge in the defaults for values that are arrays.
*/
function i18n_string_element_info_alter(&$types) {
$types['text_format']['#pre_render'][] = 'i18n_string_pre_render_text_format';
}
/**
* The '#pre_render' function to alter the text format element in a translation.
* The text format for a translation is taken form the original, so the text
* format drop down should be disabled.
*
* @param array $element
* The text_format element which will be rendered.
*
* @return array
* The altered text_format element with a disabled "Text format" select.
*/
function i18n_string_pre_render_text_format($element) {
if (!empty($element['#i18n_string_is_translation'])) {
$element['format']['format']['#attributes']['disabled'] = TRUE;
}
return $element;
}
/**
* Check if translation is required for this language code.
*
@@ -334,7 +363,10 @@ function i18n_string_update_context($oldname, $newname) {
}
/**
* Get textgroup handler
* Get textgroup handler.
*
* @return i18n_string_textgroup_default
*
*/
function i18n_string_textgroup($textgroup) {
$groups = &drupal_static(__FUNCTION__);
@@ -488,6 +520,19 @@ function i18n_string_group_info($group = NULL, $property = NULL, $default = NULL
}
}
/**
* Implements hook_i18n_string_info_alter().
*
* Set determined classes to use for the text group.
*/
function i18n_string_i18n_string_info_alter(&$info) {
foreach (array_keys($info) as $name) {
// If class is not defined. Classes from other modules, fixed classes and etc.
if (!isset($info[$name]['class'])) {
$info[$name]['class'] = variable_get('i18n_string_textgroup_class_' . $name, 'i18n_string_textgroup_default');
}
}
}
/**
* Translate / update multiple strings
@@ -519,11 +564,12 @@ function i18n_string_multiple($operation, $name, $strings, $options = array()) {
*
* This function is intended to return translations for plain strings that have NO text format
*
* @param $name
* @param array|string name
* Array or string concatenated with ':' that contains textgroup and string context
* @param $string
* String in default language or array of strings to be translated
* @param $options
* @param array|string $string
* A string in the default language, a string wth format (array with keys
* value and format),or an array of strings (without format) to be translated.
* @param array $options
* An associative array of additional options, with the following keys:
* - 'langcode' (defaults to the current language) The language code to translate to a language other than what is used to display the page.
* - 'filter' Filtering callback to apply to the translated string only
@@ -531,8 +577,13 @@ function i18n_string_multiple($operation, $name, $strings, $options = array()) {
* - 'callback' Callback to apply to the result (both to translated or untranslated string
* - 'sanitize' Whether to filter the translation applying the text format if any, default is TRUE
* - 'sanitize default' Whether to filter the default value if no translation found, default is FALSE
*
* @return string
*/
function i18n_string_translate($name, $string, $options = array()) {
if (is_array($string) && isset($string['value'])) {
$string = $string['value'];
}
if (is_array($string)) {
return i18n_string_translate_list($name, $string, $options);
}
@@ -583,10 +634,17 @@ function i18n_string_translate_access($string_format, $account = NULL) {
* Message if the user cannot translate that string.
*/
function i18n_string_translate_check_string($i18nstring, $account = NULL) {
if (!user_access('translate interface', $account) || !user_access('translate user-defined strings', $account)) {
// Check block translation permissions.
if ($i18nstring->textgroup == 'blocks') {
if (!user_access('translate interface', $account) && !user_access('translate blocks', $account)) {
return t('This is a user-defined string within a block. You are not allowed to translate blocks.');
}
}
elseif (!user_access('translate interface', $account) || !user_access('translate user-defined strings', $account)) {
return t('This is a user-defined string. You are not allowed to translate these strings.');
}
elseif (!empty($i18nstring->format)) {
if (!empty($i18nstring->format)) {
if (!i18n_string_allowed_format($i18nstring->format)) {
$format = filter_format_load($i18nstring->format);
return t('This string uses the %name text format. Strings with this format are not allowed for translation.', array('%name' => $format->name));

View File

@@ -170,14 +170,16 @@ function i18n_string_translate_page_form_base($form, $langcode, $redirect = NULL
/**
* Create field elements for strings
*
* @param i18n_string_object[] $strings
* @param string $langcode
*
* @return array
*/
function i18n_string_translate_page_form_strings($strings, $langcode) {
$formats = filter_formats();
global $user;
$form = array();
foreach ($strings as $item) {
// We may have a source or not. Load it, our string may get the format from it.
$source = $item->get_source();
$format_id = $source ? $source->format : $item->format;
$description = '';
// Check permissions to translate this string, depends on format, etc..
if ($message = $item->check_translate_access()) {
// We'll display a disabled element with the reason it cannot be translated.
@@ -188,27 +190,31 @@ function i18n_string_translate_page_form_strings($strings, $langcode) {
$disabled = FALSE;
$description = '';
// If we don't have a source and it can be translated, we create it.
if (!$source) {
if (!$item->get_source()) {
// Enable messages just as a reminder these strings are not being updated properly.
$status = $item->update(array('messages' => TRUE));
if ($status === FALSE || $status === SAVED_DELETED) {
// We don't have a source string so nothing to translate here
$disabled = TRUE;
}
else {
$source = $item->get_source();
}
}
}
$default_value = $item->format_translation($langcode, array('langcode' => $langcode, 'sanitize' => FALSE, 'debug' => FALSE));
$available_formats = array_keys(filter_formats($user));
if (!in_array($item->format, $available_formats)) {
$item->format = NULL;
}
$form[$item->get_name()] = array(
'#title' => $item->get_title(),
'#type' => 'textarea',
'#type' => $item->format ? 'text_format' : 'textarea',
'#default_value' => $default_value,
'#format' => $item->format,
// This will trigger i18n_string_pre_render_text_format() to actually
// alter the element.
'#i18n_string_is_translation' => TRUE,
'#disabled' => $disabled,
'#description' => $description . _i18n_string_translate_format_help($format_id),
//'#i18n_string_format' => $source ? $source->format : 0,
'#description' => $description,
// If disabled, provide smaller textarea (that can be expanded anyway).
'#rows' => $disabled ? 1 : min(ceil(str_word_count($default_value) / 12), 10),
// Change the parent for disabled strings so we don't get empty values later
@@ -226,6 +232,16 @@ function i18n_string_translate_page_form_submit($form, &$form_state) {
foreach ($form_state['values']['strings'] as $name => $value) {
$count++;
list($textgroup, $context) = i18n_string_context(explode(':', $name));
if (is_array($value)) {
if (isset($value['value'])) {
$value = $value['value'];
$form_state['values']['strings'][$name] = $value;
}
else {
form_set_error("strings][$name", t('Unable to get the translated string value.'));
watchdog('locale', 'Unable to get the translated string value, string array is: %string', array('%string' => var_dump($value)), WATCHDOG_WARNING);
}
}
$result = i18n_string_textgroup($textgroup)->update_translation($context, $form_state['values']['langcode'], $value);
$success += ($result ? 1 : 0);
}

View File

@@ -65,7 +65,7 @@ class i18nStringTestCase extends Drupali18nTestCase {
$this->drupalPost('admin/config/regional/translate/translate', $search, t('Filter'));
$this->clickLink(t('edit'));
// Just add a random translation.
$translation = $this->randomString();
$translation = $this->randomName();
$edit = array();
foreach ($this->getOtherLanguages() as $language) {
$langcode = $language->language;

View File

@@ -34,9 +34,32 @@ function i18n_string_variable_info($options = array()) {
'default' => 0,
'group' => 'debug',
);
$variables['i18n_string_textgroup_class_[textgroup]'] = array(
'title' => t('Class to use for the text group'),
'description' => t('Determines which the class will be use for string translation in the text group.', array(), $options),
'repeat' => array(
'type' => 'select',
'default' => 'i18n_string_textgroup_default',
'options callback' => 'i18n_string_variable_textgroup_class_list',
),
'submit callback' => 'i18n_string_variable_textgroup_class_submit_callback',
'group' => 'i18n',
);
return $variables;
}
/**
* Implements hook_variable_type_info().
*/
function i18n_string_variable_type_info() {
$type['textgroup'] = array(
'title' => t('Text group'),
'type' => 'select',
'options callback' => 'i18n_string_variable_textgroup_list',
);
return $type;
}
/**
* Options callback, format list
*/
@@ -54,4 +77,33 @@ function i18n_string_variable_format_list() {
*/
function i18n_string_variable_format_default() {
return array(filter_fallback_format());
}
}
/**
* Options callback, text groups list.
*/
function i18n_string_variable_textgroup_list() {
$groups = array();
foreach (i18n_string_group_info() as $name => $info) {
$groups[$name] = $info['title'];
}
return $groups;
}
/**
* Options callback, text group classes list.
*/
function i18n_string_variable_textgroup_class_list($variable, $options = array()) {
return array(
'i18n_string_textgroup_default' => t('Text group handler default.', array(), $options),
'i18n_string_textgroup_cached' => t('Text group handler which include persistent caching.', array(), $options),
);
}
/**
* Submit callback. Execute Reset the persistent caches after save the text group class variables.
*/
function i18n_string_variable_textgroup_class_submit_callback($variable, $options, $form, $form_state) {
// Reset the persistent caches.
cache_clear_all('i18n:string:' , 'cache', TRUE);
}