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,103 @@
CONTENTS OF THIS FILE
---------------------
* Introduction
* Requirements
* Recommended modules
* Installation
* Configuration
* Maintainers
INTRODUCTION
------------
The Taxonomy translation module, part of the Internationalization
(https://www.drupal.org/project/i18n) package, provides multiple options to
translate taxonomy vocabularies and terms. For each vocabulary, there are four
types of behaviors to choose from: Language-independent terms, Language-specific
terms, Localized terms, and Mixed-language vocabulary.
* For a full description of the module visit:
https://www.drupal.org/node/1114016
* 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 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
-------------
Language-independent terms - only vocabulary will be translatable.
1. Navigate to Structure > Taxonomy.
2. Select the "edit vocabulary" link.
3. Select the "No multilingual options for terms".
Language-specific terms - vocabulary is only used for content in that language.
The terms will only be available if the term language matches the UI language.
1. Navigate to Structure > Taxonomy and select the "edit vocabulary link".
2. Choose "Fixed Language" and a Language drop-down field will be displayed.
3. Select the language.
4. Select "Fixed Language" and Save.
Localized terms - Terms are common for all languages, but their name and
description may be localized.
1. Navigate to Structure > Taxonomy > vocabulary-to-edit > Edit.
2. Select "Localize" and select Save.
3. Edit a term and there will be a Translate tab. Select this tab.
4. Select Translate, translate the Name and Description, select
"Save translation", and repeat for all languages.
5. Repeat the process for all terms.
6. Navigate to Structure > Content types > term-to-edit > Manage display.
7. By default, the term reference is set to Link. Change this to "Link
(localized)" and Save.
The vocabulary will be appropriate for the language.
Mixed-language vocabulary - Use for vocabularies with terms in multiple
languages.
1. Navigate to Structure > Taxonomy > vocabulary-to-edit > Edit.
2. Select the Translate radio button and Save.
3. Edit a vocabulary term and there will be a new Language field. Choose a
language and then select Save and translate.
4. There are two options, the user can either select "Add translation link" or
the user can select an existing term in the Select translations form.
5. Create translations for the terms and add terms for specific languages only.
Now if the user edits a node associated with this vocabulary, only the relevant
terms will appear.
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

@@ -11,9 +11,8 @@ files[] = i18n_taxonomy.pages.inc
files[] = i18n_taxonomy.admin.inc
files[] = i18n_taxonomy.test
; 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

@@ -213,7 +213,12 @@ function i18n_taxonomy_field_formatter_view($entity_type, $entity, $field, $inst
);
}
else {
$term = $item['taxonomy_term'];
if (isset($item['taxonomy_term'])) {
$term = $item['taxonomy_term'];
}
else {
$term = taxonomy_term_load($item['tid']);
}
$uri = entity_uri('taxonomy_term', $term);
$element[$delta] = array(
'#type' => 'link',
@@ -372,10 +377,19 @@ function i18n_taxonomy_field_prepare_translation($entity_type, $entity, $field,
* The array of valid terms for this field, keyed by term id.
*/
function i18n_taxonomy_allowed_values($field) {
global $language;
$options = array();
foreach ($field['settings']['allowed_values'] as $tree) {
if ($vocabulary = taxonomy_vocabulary_machine_name_load($tree['vocabulary'])) {
if ($terms = taxonomy_get_tree($vocabulary->vid, $tree['parent'])) {
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);
}
else {
$terms = taxonomy_get_tree($vocabulary->vid, $tree['parent']);
}
if ($terms) {
foreach ($terms as $term) {
$options[$term->tid] = str_repeat('-', $term->depth) . i18n_taxonomy_term_name($term);
}
@@ -742,6 +756,28 @@ function i18n_taxonomy_form_taxonomy_form_term_alter(&$form, &$form_state) {
// Add language field or not depending on taxonomy mode.
switch (i18n_taxonomy_vocabulary_mode($vocabulary->vid)) {
case I18N_MODE_TRANSLATE:
// Set $form_state['storage'] default as empty array because we will add
// the translation and target from $_GET. So we still have it when the
// page partially reloads with ajax.
if(!isset($form_state['storage'])) {
$form_state['storage'] = array();
}
// get translation from $_GET or $form_state['storage']
$translation = null;
if(isset($_GET['translation'])) {
$translation = $_GET['translation'];
$form_state['storage']['translation'] = $translation;
} else if(isset($form_state['storage']) && isset($form_state['storage']['translation'])){
$translation = $form_state['storage']['translation'];
}
// get target from $_GET or $form_state['storage']
$target = null;
if(isset($_GET['target'])) {
$target = $_GET['target'];
$form_state['storage']['target'] = $target;
} else if(isset($form_state['storage']) && isset($form_state['storage']['target'])){
$target = $form_state['storage']['target'];
}
$form['language'] = array(
'#description' => t('This term belongs to a multilingual vocabulary. You can set a language for it.'),
) + i18n_element_language_select($term);
@@ -749,7 +785,7 @@ function i18n_taxonomy_form_taxonomy_form_term_alter(&$form, &$form_state) {
// If the term to be added will be a translation of a source term,
// set the default value of the option list to the target language and
// create a form element for storing the translation set of the source term.
if (empty($term->tid) && isset($_GET['translation']) && isset($_GET['target']) && ($source_term = taxonomy_term_load($_GET['translation'])) && ($target_language = i18n_language_object($_GET['target']))) {
if (empty($term->tid) && isset($translation) && isset($target) && ($source_term = taxonomy_term_load($translation)) && ($target_language = i18n_language_object($target))) {
// Set context language to target language.
i18n_language_context($target_language);
@@ -991,7 +1027,7 @@ function i18n_taxonomy_translate_terms($taxonomy, $langcode, $fullterms = TRUE)
}
elseif ($term->language && $term->language != $langcode) {
$translation_set = i18n_translation_set_load($term->i18n_tsid);
$translations = $translation_set->get_translations();
$translations = ($translation_set) ? $translation_set->get_translations() : NULL;
if ($translations && !empty($translations[$langcode])) {
$newterm = $translations[$langcode];
@@ -1020,6 +1056,10 @@ function i18n_taxonomy_localize_terms($terms) {
if (!i18n_string_translate_langcode()) {
return $terms;
}
// $terms is not a valid array or term.
if (empty($terms)) {
return $terms;
}
$object_info = i18n_object_info('taxonomy_term');
$list = is_array($terms) ? $terms : array($terms);
foreach ($list as $index => $term) {
@@ -1087,7 +1127,7 @@ function i18n_taxonomy_get_tree($vid, $langcode, $parent = 0, $max_depth = NULL,
$query->join('taxonomy_term_hierarchy', 'h', 'h.tid = t.tid');
$result = $query
->addTag('translatable')
->addTag('term_access')
->addTag('taxonomy_term_access')
->fields('t')
->fields('h', array('parent'))
->condition('t.vid', $vid)
@@ -1216,6 +1256,11 @@ function i18n_taxonomy_field_uuid_presave($entity_type, $entity, $field, $instan
* Implements hook_entity_info_alter().
*/
function i18n_taxonomy_entity_info_alter(&$entity_info) {
if (isset($entity_info['taxonomy_vocabulary'])) {
// Add altered vocabulary schema fields.
$entity_info['taxonomy_vocabulary']['schema_fields_sql']['base table'][] = 'i18n_mode';
$entity_info['taxonomy_vocabulary']['schema_fields_sql']['base table'][] = 'language';
}
if (isset($entity_info['taxonomy_term'])) {
// Core doesn't provide a label callback for taxonomy terms. By setting one
// we can use it to return the correct localized term name.
@@ -1261,3 +1306,22 @@ function i18n_taxonomy_modules_enabled($modules) {
}
}
}
/**
* Implements hook_views_pre_render().
*/
function i18n_taxonomy_views_pre_render(&$view) {
if($view->base_table !== 'rules_scheduler') {
global $language;
foreach ($view->result as $delta => $term){
if (isset($term->tid)) {
i18n_string_translate_langcode($language->language);
$localized_term = i18n_taxonomy_localize_terms(taxonomy_term_load($term->tid));
$term->tid = $localized_term->tid;
$term->taxonomy_term_data_name = $localized_term->name;
$term->taxonomy_term_data_description = $localized_term->description;
}
}
}
}

View File

@@ -100,7 +100,7 @@ function _i18n_taxonomy_autocomplete($langcode, $vids, $tags_typed = '') {
$query = db_select('taxonomy_term_data', 't')
->fields('t', array('tid', 'name'));
$query->addTag('translatable');
$query->addTag('term_access');
$query->addTag('taxonomy_term_access');
// Disable i18n_select for this query
$query->addTag('i18n_select');
// Add language condition

View File

@@ -15,6 +15,10 @@ function i18n_taxonomy_token_info() {
'name' => t("Name (localized)"),
'description' => t("The name of the taxonomy term."),
);
$term['localized-name'] = array(
'name' => t("Name in current language"),
'description' => t("The name of the taxonomy term in current language."),
);
$term['i18n-description'] = array(
'name' => t("Description (localized)"),
'description' => t("The optional description of the taxonomy term."),
@@ -69,6 +73,12 @@ function i18n_taxonomy_tokens($type, $tokens, array $data = array(), array $opti
$replacements[$original] = $sanitize ? check_plain($name) : $name;
break;
case 'localized-name':
$translated_term = i18n_taxonomy_term_get_translation($term, $langcode);
$name = i18n_taxonomy_term_name($translated_term, $langcode);
$replacements[$original] = $sanitize ? check_plain($name) : $name;
break;
case 'i18n-description':
$replacements[$original] = i18n_string_text(array('taxonomy', 'term', $term->tid, 'description'), $term->description, array('langcode' => $langcode, 'format' => $term->format, 'sanitize' => $sanitize, 'cache' => TRUE));
break;