Issue #2394883 by Gábor Hojtsy, plach, jhodgdon: Language setup for entity and field based rendering in views is independent, confusing UI, lacking test coverage

8.0.x
Alex Pott 2015-02-05 10:33:13 +00:00
parent c9cc83577d
commit f100d942e3
188 changed files with 470 additions and 858 deletions

View File

@ -153,8 +153,6 @@ display:
entity_type: node entity_type: node
entity_field: created entity_field: created
title: form title: form
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1: page_1:
display_plugin: page display_plugin: page
id: page_1 id: page_1
@ -162,8 +160,6 @@ display:
position: null position: null
display_options: display_options:
path: test_bulk_form path: test_bulk_form
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_2: page_2:
display_plugin: page display_plugin: page
id: page_2 id: page_2
@ -184,5 +180,3 @@ display:
empty: true empty: true
content: 'This view is empty.' content: 'This view is empty.'
plugin_id: text_custom plugin_id: text_custom
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -136,8 +136,6 @@ display:
empty: { } empty: { }
relationships: { } relationships: { }
arguments: { } arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
feed_items: feed_items:
display_plugin: feed display_plugin: feed
id: feed_items id: feed_items
@ -148,5 +146,3 @@ display:
display_description: '' display_description: ''
defaults: defaults:
arguments: true arguments: true
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -141,16 +141,12 @@ display:
empty: { } empty: { }
relationships: { } relationships: { }
arguments: { } arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
feed_1: feed_1:
display_plugin: feed display_plugin: feed
id: feed_1 id: feed_1
display_title: Feed display_title: Feed
position: 2 position: 2
display_options: display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
style: style:
type: opml type: opml
options: options:
@ -389,8 +385,6 @@ display:
display_title: Page display_title: Page
position: 1 position: 1
display_options: display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: aggregator/sources path: aggregator/sources
menu: menu:
type: normal type: normal

View File

@ -168,8 +168,6 @@ display:
entity_field: description entity_field: description
filters: { } filters: { }
sorts: { } sorts: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
feed_1: feed_1:
display_plugin: feed display_plugin: feed
id: feed_1 id: feed_1
@ -181,5 +179,3 @@ display:
type: aggregator_rss type: aggregator_rss
options: options:
view_mode: default view_mode: default
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -38,13 +38,8 @@ display:
table: views_test_data table: views_test_data
field: name field: name
title: test_view_block title: test_view_block
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
block_1: block_1:
display_plugin: block display_plugin: block
id: block_1 id: block_1
display_title: Block display_title: Block
position: null position: null
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -40,29 +40,18 @@ display:
table: views_test_data table: views_test_data
field: name field: name
title: test_view_block2 title: test_view_block2
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
block_1: block_1:
display_plugin: block display_plugin: block
id: block_1 id: block_1
display_title: Block display_title: Block
position: null position: null
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
block_2: block_2:
display_plugin: block display_plugin: block
id: block_2 id: block_2
display_title: Block display_title: Block
position: null position: null
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
block_3: block_3:
display_plugin: block display_plugin: block
id: block_3 id: block_3
display_title: Block display_title: Block
position: null position: null
display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -52,8 +52,6 @@ display:
plugin_id: numeric plugin_id: numeric
entity_type: block_content entity_type: block_content
entity_field: id entity_field: id
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default

View File

@ -54,8 +54,6 @@ display:
plugin_id: block_content_id plugin_id: block_content_id
entity_type: block_content entity_type: block_content
entity_field: id entity_field: id
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_extenders: { } display_extenders: { }
display_plugin: default display_plugin: default
display_title: Master display_title: Master

View File

@ -126,8 +126,6 @@ display:
footer: { } footer: { }
empty: { } empty: { }
relationships: { } relationships: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_extenders: { } display_extenders: { }
arguments: arguments:
type: type:
@ -178,6 +176,4 @@ display:
position: null position: null
display_options: display_options:
path: test-block_content-view path: test-block_content-view
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_extenders: { } display_extenders: { }

View File

@ -150,9 +150,7 @@ display:
empty: { } empty: { }
relationships: { } relationships: { }
arguments: { } arguments: { }
field_langcode: '***LANGUAGE_language_content***' rendering_language: '***LANGUAGE_entity_translation***'
field_langcode_add_to_query: null
rendering_language: translation_language_renderer
display_extenders: { } display_extenders: { }
page_bf: page_bf:
display_plugin: page display_plugin: page
@ -160,8 +158,6 @@ display:
display_title: 'Body filter page' display_title: 'Body filter page'
position: 1 position: 1
display_options: display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-body-filter path: test-body-filter
display_description: '' display_description: ''
title: 'Test body filters' title: 'Test body filters'
@ -219,8 +215,6 @@ display:
display_title: 'Body filter page Paris' display_title: 'Body filter page Paris'
position: 1 position: 1
display_options: display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-body-paris path: test-body-paris
display_description: '' display_description: ''
title: 'Test body filters' title: 'Test body filters'
@ -278,8 +272,6 @@ display:
display_title: 'Info filter page' display_title: 'Info filter page'
position: 1 position: 1
display_options: display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-info-filter path: test-info-filter
display_description: '' display_description: ''
title: 'Test info filter' title: 'Test info filter'
@ -337,8 +329,6 @@ display:
display_title: 'Info filter page Paris' display_title: 'Info filter page Paris'
position: 1 position: 1
display_options: display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-info-paris path: test-info-paris
display_description: '' display_description: ''
title: 'Test info filter' title: 'Test info filter'

View File

@ -22,8 +22,6 @@ display:
plugin_id: block_content_type plugin_id: block_content_type
entity_type: block_content entity_type: block_content
entity_field: type entity_field: type
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default

View File

@ -234,8 +234,6 @@ display:
content: 'No comments available.' content: 'No comments available.'
tokenize: false tokenize: false
plugin_id: text_custom plugin_id: text_custom
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
block_1: block_1:
display_plugin: block display_plugin: block
id: block_1 id: block_1
@ -244,7 +242,5 @@ display:
display_options: display_options:
block_description: 'Recent comments' block_description: 'Recent comments'
block_category: 'Lists (Views)' block_category: 'Lists (Views)'
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
allow: allow:
items_per_page: true items_per_page: true

View File

@ -352,8 +352,6 @@ display:
break_phrase: false break_phrase: false
not: false not: false
plugin_id: numeric plugin_id: numeric
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_extenders: { } display_extenders: { }
rest_export_1: rest_export_1:
display_plugin: rest_export display_plugin: rest_export
@ -361,8 +359,6 @@ display:
display_title: 'REST export' display_title: 'REST export'
position: 1 position: 1
display_options: display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: node/%node/comments path: node/%node/comments
pager: pager:
type: some type: some

View File

@ -147,8 +147,6 @@ display:
footer: { } footer: { }
empty: { } empty: { }
arguments: { } arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1: page_1:
display_plugin: page display_plugin: page
id: page_1 id: page_1
@ -156,5 +154,3 @@ display:
position: 1 position: 1
display_options: display_options:
path: test-comment-row path: test-comment-row
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -63,8 +63,6 @@ display:
entity_field: subject entity_field: subject
filters: { } filters: { }
sorts: { } sorts: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
feed_1: feed_1:
display_plugin: feed display_plugin: feed
id: feed_1 id: feed_1
@ -72,5 +70,3 @@ display:
position: null position: null
display_options: display_options:
path: test-comment-rss path: test-comment-rss
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -55,8 +55,6 @@ display:
type: default type: default
row: row:
type: 'entity:node' type: 'entity:node'
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default

View File

@ -147,17 +147,13 @@ display:
footer: { } footer: { }
empty: { } empty: { }
arguments: { } arguments: { }
field_langcode: '***LANGUAGE_language_content***' rendering_language: '***LANGUAGE_entity_translation***'
field_langcode_add_to_query: null
rendering_language: translation_language_renderer
page_bf: page_bf:
display_plugin: page display_plugin: page
id: page_bf id: page_bf
display_title: 'Body Comida' display_title: 'Body Comida'
position: 1 position: 1
display_options: display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-body-filter path: test-body-filter
display_description: '' display_description: ''
filters: filters:
@ -214,8 +210,6 @@ display:
display_title: 'Body Paris' display_title: 'Body Paris'
position: 1 position: 1
display_options: display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-body-paris path: test-body-paris
display_description: '' display_description: ''
filters: filters:
@ -272,8 +266,6 @@ display:
display_title: 'Title Comida' display_title: 'Title Comida'
position: 1 position: 1
display_options: display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-title-filter path: test-title-filter
display_description: '' display_description: ''
page_tp: page_tp:
@ -282,8 +274,6 @@ display:
display_title: 'Title Paris' display_title: 'Title Paris'
position: 1 position: 1
display_options: display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-title-paris path: test-title-paris
display_description: '' display_description: ''
filters: filters:

View File

@ -130,8 +130,6 @@ display:
empty: { } empty: { }
relationships: { } relationships: { }
arguments: { } arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1: page_1:
display_plugin: page display_plugin: page
id: page_1 id: page_1
@ -139,5 +137,3 @@ display:
position: 1 position: 1
display_options: display_options:
path: test-contact-link path: test-contact-link
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -104,8 +104,6 @@ display:
value: 'No people available.' value: 'No people available.'
format: plain_text format: plain_text
plugin_id: text plugin_id: text
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1: page_1:
display_plugin: page display_plugin: page
id: page_1 id: page_1
@ -113,5 +111,3 @@ display:
position: null position: null
display_options: display_options:
path: test-entity-translations-link path: test-entity-translations-link
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -56,8 +56,6 @@ display:
field: wid field: wid
order: ASC order: ASC
plugin_id: standard plugin_id: standard
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1: page_1:
display_plugin: page display_plugin: page
id: page_1 id: page_1
@ -65,5 +63,3 @@ display:
position: null position: null
display_options: display_options:
path: test-dblog path: test-dblog
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -109,8 +109,6 @@ display:
plugin_id: date plugin_id: date
entity_type: node entity_type: node
entity_field: created entity_field: created
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
entity_reference_1: entity_reference_1:
display_plugin: entity_reference display_plugin: entity_reference
id: entity_reference_1 id: entity_reference_1
@ -127,5 +125,3 @@ display:
type: none type: none
options: options:
offset: 0 offset: 0
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -55,8 +55,6 @@ display:
field: field_test field: field_test
relationship: none relationship: none
plugin_id: standard plugin_id: standard
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default
@ -72,8 +70,6 @@ display:
field: reverse_field_test field: reverse_field_test
relationship: none relationship: none
plugin_id: standard plugin_id: standard
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: embed display_plugin: embed
display_title: Embed display_title: Embed
id: embed_1 id: embed_1

View File

@ -58,8 +58,6 @@ display:
type: default type: default
row: row:
type: fields type: fields
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default

View File

@ -680,8 +680,6 @@ display:
arguments: { } arguments: { }
group_by: true group_by: true
show_admin_links: true show_admin_links: true
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1: page_1:
display_plugin: page display_plugin: page
id: page_1 id: page_1
@ -709,8 +707,6 @@ display:
group_type: group group_type: group
admin_label: 'File usage' admin_label: 'File usage'
required: false required: false
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_2: page_2:
display_plugin: page display_plugin: page
id: page_2 id: page_2
@ -1060,5 +1056,3 @@ display:
group_type: group group_type: group
admin_label: 'File usage' admin_label: 'File usage'
required: true required: true
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -47,8 +47,6 @@ display:
relationship: none relationship: none
table: views_test_data table: views_test_data
plugin_id: numeric plugin_id: numeric
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default

View File

@ -148,5 +148,3 @@ display:
plugin_id: numeric plugin_id: numeric
filters: { } filters: { }
sorts: { } sorts: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -165,8 +165,6 @@ display:
empty: { } empty: { }
relationships: { } relationships: { }
fields: { } fields: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
block_1: block_1:
id: block_1 id: block_1
display_title: Block display_title: Block
@ -196,8 +194,6 @@ display:
specify_validation: true specify_validation: true
plugin_id: date_year_month plugin_id: date_year_month
entity_type: node entity_type: node
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1: page_1:
id: page_1 id: page_1
display_title: Page display_title: Page
@ -208,5 +204,3 @@ display:
type: views_query type: views_query
options: { } options: { }
path: archive path: archive
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -501,8 +501,6 @@ display:
operator: AND operator: AND
groups: groups:
1: AND 1: AND
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default
@ -523,8 +521,6 @@ display:
description: 'Find and manage content' description: 'Find and manage content'
menu_name: admin menu_name: admin
weight: -10 weight: -10
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: page display_plugin: page
display_title: Page display_title: Page
id: page_1 id: page_1

View File

@ -413,8 +413,6 @@ display:
plugin_id: standard plugin_id: standard
arguments: { } arguments: { }
display_extenders: { } display_extenders: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
use_more: true use_more: true
use_more_always: true use_more_always: true
use_more_text: More use_more_text: More
@ -425,7 +423,3 @@ display:
id: block_1 id: block_1
display_title: Block display_title: Block
position: 1 position: 1
display_options:
display_extenders: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -233,8 +233,6 @@ display:
relationships: { } relationships: { }
fields: { } fields: { }
arguments: { } arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default
@ -266,13 +264,9 @@ display:
options: options:
relationship: none relationship: none
view_mode: rss view_mode: rss
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1: page_1:
display_options: display_options:
path: node path: node
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: page display_plugin: page
display_title: Page display_title: Page
id: page_1 id: page_1

View File

@ -306,8 +306,6 @@ display:
footer: { } footer: { }
empty: { } empty: { }
sorts: { } sorts: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
filters: filters:
langcode: langcode:
id: langcode id: langcode
@ -406,8 +404,6 @@ display:
default: default default: default
page_1: page_1 page_1: page_1
inherit_arguments: false inherit_arguments: false
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1: page_1:
id: page_1 id: page_1
display_title: Page display_title: Page
@ -424,5 +420,3 @@ display:
weight: 0 weight: 0
menu_name: main menu_name: main
parent: '' parent: ''
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -245,7 +245,7 @@ class NodeTranslationUITest extends ContentTranslationUITest {
// Enable the translation language renderer. // Enable the translation language renderer.
$view = \Drupal::entityManager()->getStorage('view')->load('frontpage'); $view = \Drupal::entityManager()->getStorage('view')->load('frontpage');
$display = &$view->getDisplay('default'); $display = &$view->getDisplay('default');
$display['display_options']['rendering_language'] = 'translation_language_renderer'; $display['display_options']['rendering_language'] = '***LANGUAGE_entity_translation***';
$view->save(); $view->save();
// Need to check from the beginning, including the base_path, in the url // Need to check from the beginning, including the base_path, in the url

View File

@ -68,8 +68,6 @@ display:
relationships: { } relationships: { }
fields: { } fields: { }
arguments: { } arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default
@ -95,8 +93,6 @@ display:
menu_name: tools menu_name: tools
weight: 0 weight: 0
context: '1' context: '1'
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: page display_plugin: page
display_title: Page display_title: Page
id: page_1 id: page_1

View File

@ -162,17 +162,13 @@ display:
empty: { } empty: { }
relationships: { } relationships: { }
arguments: { } arguments: { }
field_langcode: '***LANGUAGE_language_content***' rendering_language: '***LANGUAGE_entity_translation***'
field_langcode_add_to_query: null
rendering_language: translation_language_renderer
page_bf: page_bf:
display_plugin: page display_plugin: page
id: page_bf id: page_bf
display_title: 'Body filter page' display_title: 'Body filter page'
position: 1 position: 1
display_options: display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-body-filter path: test-body-filter
display_description: '' display_description: ''
title: 'Test body filters' title: 'Test body filters'
@ -240,8 +236,6 @@ display:
display_title: 'Body filter page Paris' display_title: 'Body filter page Paris'
position: 1 position: 1
display_options: display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-body-paris path: test-body-paris
display_description: '' display_description: ''
title: 'Test body filters' title: 'Test body filters'
@ -309,8 +303,6 @@ display:
display_title: 'Title filter page' display_title: 'Title filter page'
position: 1 position: 1
display_options: display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-title-filter path: test-title-filter
display_description: '' display_description: ''
title: 'Test title filter' title: 'Test title filter'
@ -378,8 +370,6 @@ display:
display_title: 'Title filter page Paris' display_title: 'Title filter page Paris'
position: 1 position: 1
display_options: display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-title-paris path: test-title-paris
display_description: '' display_description: ''
title: 'Test title filter' title: 'Test title filter'

View File

@ -22,8 +22,6 @@ display:
plugin_id: node_type plugin_id: node_type
entity_type: node entity_type: node
entity_field: type entity_field: type
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default

View File

@ -65,8 +65,6 @@ display:
type: default type: default
row: row:
type: fields type: fields
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default

View File

@ -282,14 +282,10 @@ display:
plugin_id: language plugin_id: language
entity_type: node entity_type: node
entity_field: langcode entity_field: langcode
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1: page_1:
display_plugin: page display_plugin: page
id: page_1 id: page_1
display_title: Page display_title: Page
position: 1 position: 1
display_options: display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-language path: test-language

View File

@ -45,8 +45,6 @@ display:
plugin_id: standard plugin_id: standard
entity_type: node entity_type: node
entity_field: nid entity_field: nid
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1: page_1:
display_plugin: page display_plugin: page
id: page_1 id: page_1
@ -54,5 +52,3 @@ display:
position: null position: null
display_options: display_options:
path: test-node-bulk-form path: test-node-bulk-form
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -52,8 +52,6 @@ display:
plugin_id: node_nid plugin_id: node_nid
entity_type: node entity_type: node
entity_field: nid entity_field: nid
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default

View File

@ -52,8 +52,6 @@ display:
plugin_id: node_nid plugin_id: node_nid
entity_type: node entity_type: node
entity_field: nid entity_field: nid
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default

View File

@ -47,8 +47,6 @@ display:
style: style:
type: default type: default
title: test_node_row_plugin title: test_node_row_plugin
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default
@ -56,8 +54,6 @@ display:
page_1: page_1:
display_options: display_options:
path: test-node-row-plugin path: test-node-row-plugin
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: page display_plugin: page
display_title: Page display_title: Page
id: page_1 id: page_1

View File

@ -197,8 +197,6 @@ display:
plugin_id: node_type plugin_id: node_type
entity_type: node entity_type: node
entity_field: type entity_field: type
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1: page_1:
display_plugin: page display_plugin: page
id: page_1 id: page_1
@ -206,5 +204,3 @@ display:
position: null position: null
display_options: display_options:
path: test-node-view path: test-node-view
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -137,13 +137,9 @@ display:
operator: AND operator: AND
groups: groups:
1: AND 1: AND
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1: page_1:
display_options: display_options:
path: test_status_extra path: test_status_extra
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: page display_plugin: page
display_title: Page display_title: Page
id: page_1 id: page_1

View File

@ -192,8 +192,6 @@ display:
not: false not: false
plugin_id: number_list_field plugin_id: number_list_field
display_extenders: { } display_extenders: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
block_1: block_1:
display_plugin: block display_plugin: block
id: block_1 id: block_1
@ -201,5 +199,3 @@ display:
position: 1 position: 1
display_options: display_options:
display_extenders: { } display_extenders: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -191,8 +191,6 @@ display:
break_phrase: false break_phrase: false
plugin_id: string_list_field plugin_id: string_list_field
display_extenders: { } display_extenders: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
block_1: block_1:
display_plugin: block display_plugin: block
id: block_1 id: block_1
@ -200,5 +198,3 @@ display:
position: 1 position: 1
display_options: display_options:
display_extenders: { } display_extenders: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -196,8 +196,6 @@ display:
relationships: { } relationships: { }
arguments: { } arguments: { }
display_extenders: { } display_extenders: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
block_1: block_1:
display_plugin: block display_plugin: block
id: block_1 id: block_1
@ -205,5 +203,3 @@ display:
position: 1 position: 1
display_options: display_options:
display_extenders: { } display_extenders: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -44,8 +44,6 @@ display:
entity_field: id entity_field: id
title: 'Test serialize' title: 'Test serialize'
arguments: { } arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
rest_export_1: rest_export_1:
display_plugin: rest_export display_plugin: rest_export
id: rest_export_1 id: rest_export_1
@ -55,5 +53,3 @@ display:
defaults: defaults:
access: false access: false
path: test/serialize/entity path: test/serialize/entity
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -67,8 +67,6 @@ display:
plugin_id: date plugin_id: date
title: 'Test serialize' title: 'Test serialize'
arguments: { } arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
rest_export_1: rest_export_1:
display_plugin: rest_export display_plugin: rest_export
id: rest_export_1 id: rest_export_1
@ -86,8 +84,6 @@ display:
type: serializer type: serializer
row: row:
type: data_field type: data_field
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
rest_export_2: rest_export_2:
display_plugin: rest_export display_plugin: rest_export
id: rest_export_2 id: rest_export_2
@ -107,5 +103,3 @@ display:
type: serializer type: serializer
row: row:
type: data_field type: data_field
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -112,8 +112,6 @@ display:
entity_field: body entity_field: body
title: 'Test serialize' title: 'Test serialize'
arguments: { } arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
rest_export_1: rest_export_1:
display_plugin: rest_export display_plugin: rest_export
id: rest_export_1 id: rest_export_1
@ -131,5 +129,3 @@ display:
type: serializer type: serializer
row: row:
type: data_field type: data_field
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -244,8 +244,6 @@ display:
order: DESC order: DESC
entity_type: node entity_type: node
entity_field: created entity_field: created
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1: page_1:
display_plugin: page display_plugin: page
id: page_1 id: page_1
@ -253,5 +251,3 @@ display:
position: null position: null
display_options: display_options:
path: test_statistics_integration path: test_statistics_integration
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -235,8 +235,6 @@ display:
empty: { } empty: { }
relationships: { } relationships: { }
fields: { } fields: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
feed_1: feed_1:
id: feed_1 id: feed_1
display_title: Feed display_title: Feed
@ -282,8 +280,6 @@ display:
options: options:
relationship: none relationship: none
view_mode: default view_mode: default
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1: page_1:
id: page_1 id: page_1
display_title: Page display_title: Page
@ -294,5 +290,3 @@ display:
type: views_query type: views_query
options: { } options: { }
path: taxonomy/term/% path: taxonomy/term/%
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -161,6 +161,4 @@ display:
plugin_id: taxonomy plugin_id: taxonomy
entity_type: taxonomy_term entity_type: taxonomy_term
entity_field: tid entity_field: tid
field_langcode: '***LANGUAGE_site_default***' rendering_language: '***LANGUAGE_entity_translation***'
field_langcode_add_to_query: null
rendering_language: translation_language_renderer

View File

@ -135,16 +135,12 @@ display:
empty: { } empty: { }
relationships: { } relationships: { }
arguments: { } arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_dc: page_dc:
display_plugin: page display_plugin: page
id: page_dc id: page_dc
display_title: 'Description Comida' display_title: 'Description Comida'
position: 3 position: 3
display_options: display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_description: '' display_description: ''
path: test-desc-filter path: test-desc-filter
filters: filters:
@ -201,8 +197,6 @@ display:
display_title: 'Description Comida' display_title: 'Description Comida'
position: 3 position: 3
display_options: display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_description: '' display_description: ''
path: test-desc-paris path: test-desc-paris
filters: filters:
@ -259,8 +253,6 @@ display:
display_title: 'Field Comida' display_title: 'Field Comida'
position: 3 position: 3
display_options: display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_description: '' display_description: ''
path: test-field-filter path: test-field-filter
filters: filters:
@ -317,8 +309,6 @@ display:
display_title: 'Field Paris' display_title: 'Field Paris'
position: 3 position: 3
display_options: display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_description: '' display_description: ''
path: test-field-paris path: test-field-paris
filters: filters:
@ -375,8 +365,6 @@ display:
display_title: 'Name Comida' display_title: 'Name Comida'
position: 1 position: 1
display_options: display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-name-filter path: test-name-filter
display_description: '' display_description: ''
page_np: page_np:
@ -385,8 +373,6 @@ display:
display_title: 'Name Paris' display_title: 'Name Paris'
position: 1 position: 1
display_options: display_options:
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
path: test-name-paris path: test-name-paris
display_description: '' display_description: ''
filters: filters:

View File

@ -177,5 +177,3 @@ display:
empty: { } empty: { }
relationships: { } relationships: { }
arguments: { } arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -73,8 +73,6 @@ display:
style: style:
type: default type: default
title: test_groupwise title: test_groupwise
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default

View File

@ -83,8 +83,6 @@ display:
type: default type: default
row: row:
type: 'entity:node' type: 'entity:node'
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default

View File

@ -131,5 +131,3 @@ display:
required: true required: true
plugin_id: standard plugin_id: standard
arguments: { } arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -154,5 +154,3 @@ display:
empty: { } empty: { }
relationships: { } relationships: { }
arguments: { } arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -181,5 +181,3 @@ display:
validate_options: { } validate_options: { }
plugin_id: tracker_user_uid plugin_id: tracker_user_uid
entity_type: node entity_type: node
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -815,8 +815,6 @@ display:
operator: AND operator: AND
groups: groups:
1: AND 1: AND
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_extenders: { } display_extenders: { }
page_1: page_1:
display_plugin: page display_plugin: page
@ -841,6 +839,4 @@ display:
weight: 0 weight: 0
defaults: defaults:
show_admin_links: false show_admin_links: false
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_extenders: { } display_extenders: { }

View File

@ -166,8 +166,6 @@ display:
empty: { } empty: { }
relationships: { } relationships: { }
arguments: { } arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
block_1: block_1:
display_plugin: block display_plugin: block
id: block_1 id: block_1
@ -177,5 +175,3 @@ display:
display_description: 'A list of new users' display_description: 'A list of new users'
block_description: 'Who''s new' block_description: 'Who''s new'
block_category: User block_category: User
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -196,8 +196,6 @@ display:
plugin_id: text_custom plugin_id: text_custom
relationships: { } relationships: { }
arguments: { } arguments: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
who_s_online_block: who_s_online_block:
display_plugin: block display_plugin: block
id: who_s_online_block id: who_s_online_block
@ -206,5 +204,3 @@ display:
display_options: display_options:
block_description: 'Who''s online' block_description: 'Who''s online'
display_description: 'A list of users that are currently logged in.' display_description: 'A list of users that are currently logged in.'
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -28,8 +28,6 @@ display:
type: default type: default
row: row:
type: fields type: fields
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default

View File

@ -32,8 +32,6 @@ display:
type: default type: default
row: row:
type: fields type: fields
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default
@ -41,8 +39,6 @@ display:
page_1: page_1:
display_options: display_options:
path: test-role path: test-role
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: page display_plugin: page
display_title: Page display_title: Page
id: page_1 id: page_1

View File

@ -138,5 +138,3 @@ display:
plugin_id: user_permissions plugin_id: user_permissions
filters: { } filters: { }
sorts: { } sorts: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -140,5 +140,3 @@ display:
plugin_id: standard plugin_id: standard
entity_type: user entity_type: user
entity_field: uid entity_field: uid
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -86,8 +86,6 @@ display:
style: style:
type: default type: default
title: test_groupwise_user title: test_groupwise_user
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default

View File

@ -58,8 +58,6 @@ display:
type: default type: default
row: row:
type: fields type: fields
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default

View File

@ -55,8 +55,6 @@ display:
plugin_id: boolean plugin_id: boolean
entity_type: user entity_type: user
entity_field: status entity_field: status
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1: page_1:
display_plugin: page display_plugin: page
id: page_1 id: page_1
@ -64,5 +62,3 @@ display:
position: null position: null
display_options: display_options:
path: test-user-bulk-form path: test-user-bulk-form
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -43,8 +43,6 @@ display:
entity_type: user entity_type: user
entity_field: changed entity_field: changed
filters: { } filters: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default
@ -52,8 +50,6 @@ display:
page_1: page_1:
display_options: display_options:
path: test_user_changed path: test_user_changed
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: page display_plugin: page
display_title: Page display_title: Page
id: page_1 id: page_1

View File

@ -130,5 +130,3 @@ display:
plugin_id: date plugin_id: date
entity_type: user entity_type: user
entity_field: created entity_field: created
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -49,8 +49,6 @@ display:
anonymous: '0' anonymous: '0'
entity_type: user entity_type: user
entity_field: uid entity_field: uid
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default
@ -58,8 +56,6 @@ display:
page_1: page_1:
display_options: display_options:
path: test_user_name path: test_user_name
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: page display_plugin: page
display_title: Page display_title: Page
id: page_1 id: page_1

View File

@ -111,8 +111,6 @@ display:
options: options:
default_field_elements: true default_field_elements: true
hide_empty: false hide_empty: false
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default

View File

@ -32,8 +32,6 @@ display:
plugin_id: user_uid plugin_id: user_uid
entity_type: user entity_type: user
entity_field: uid entity_field: uid
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default

View File

@ -34,8 +34,6 @@ display:
type: default type: default
row: row:
type: fields type: fields
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default

View File

@ -34,8 +34,6 @@ display:
type: default type: default
row: row:
type: fields type: fields
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default

View File

@ -157,8 +157,6 @@ display:
entity_field: status entity_field: status
sorts: { } sorts: { }
title: test_user_role title: test_user_role
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
page_1: page_1:
display_plugin: page display_plugin: page
id: page_1 id: page_1
@ -166,5 +164,3 @@ display:
position: null position: null
display_options: display_options:
path: test-views-handler-field-role path: test-views-handler-field-role
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

View File

@ -53,8 +53,6 @@ display:
type: default type: default
row: row:
type: fields type: fields
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default

View File

@ -247,12 +247,6 @@ views_display:
hide_attachment_summary: hide_attachment_summary:
type: boolean type: boolean
label: 'Hide attachments in summary' label: 'Hide attachments in summary'
field_langcode:
type: string
label: 'Field langcode'
field_langcode_add_to_query:
type: string
label: 'Add the field language to the query'
rendering_language: rendering_language:
type: string type: string
label: 'Entity language' label: 'Entity language'

View File

@ -0,0 +1,51 @@
<?php
/**
* @file
* Contains \Drupal\views\Entity\Render\ConfigurableLanguageRenderer.
*/
namespace Drupal\views\Entity\Render;
use Drupal\Core\Entity\EntityTypeInterface;
use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable;
/**
* Renders entities in a configured language.
*/
class ConfigurableLanguageRenderer extends RendererBase {
/**
* A specific language code for rendering if available.
*
* @var string|null
*/
protected $langcode;
/**
* Constructs a renderer object.
*
* @param \Drupal\views\ViewExecutable $view
* The entity row being rendered.
* @param \Drupal\Core\Language\LanguageManagerInterface $language_manager
* The language manager.
* @param \Drupal\Core\Entity\EntityTypeInterface $entity_type
* The entity type.
* @param string|null $langcode
* A specific language code to set, if available.
*/
public function __construct(ViewExecutable $view, LanguageManagerInterface $language_manager, EntityTypeInterface $entity_type, $langcode) {
parent::__construct($view, $language_manager, $entity_type);
$this->langcode = $langcode;
}
/**
* {@inheritdoc}
*/
public function getLangcode(ResultRow $row) {
return $this->langcode;
}
}

View File

@ -1,26 +0,0 @@
<?php
/**
* @file
* Contains \Drupal\views\Entity\Render\CurrentLanguageRenderer.
*/
namespace Drupal\views\Entity\Render;
use Drupal\views\ResultRow;
/**
* Renders entities in the current language.
*/
class CurrentLanguageRenderer extends RendererBase {
/**
* Returns NULL so that the current language is used.
*
* @param \Drupal\views\ResultRow $row
* The result row.
*/
protected function getLangcode(ResultRow $row) {
}
}

View File

@ -15,15 +15,9 @@ use Drupal\views\ResultRow;
class DefaultLanguageRenderer extends RendererBase { class DefaultLanguageRenderer extends RendererBase {
/** /**
* Returns the language code associated to the given row. * {@inheritdoc}
*
* @param \Drupal\views\ResultRow $row
* The result row.
*
* @return string
* A language code.
*/ */
protected function getLangcode(ResultRow $row) { public function getLangcode(ResultRow $row) {
return $row->_entity->getUntranslated()->language()->getId(); return $row->_entity->getUntranslated()->language()->getId();
} }

View File

@ -0,0 +1,92 @@
<?php
/**
* @file
* Contains \Drupal\views\Entity\Render\EntityTranslationRenderTrait.
*/
namespace Drupal\views\Entity\Render;
use Drupal\views\Plugin\views\PluginBase;
/**
* Trait used to instantiate the view's entity language render.
*/
trait EntityTranslationRenderTrait {
/**
* The renderer to be used to render the entity row.
*
* @var \Drupal\views\Entity\Render\RendererBase
*/
protected $entityLanguageRenderer;
/**
* Returns the current renderer.
*
* @return \Drupal\views\Entity\Render\RendererBase
* The configured renderer.
*/
protected function getEntityTranslationRenderer() {
if (!isset($this->entityLanguageRenderer)) {
$view = $this->getView();
$rendering_language = $view->display_handler->getOption('rendering_language');
$langcode = NULL;
$dynamic_renderers = array(
'***LANGUAGE_entity_translation***' => 'TranslationLanguageRenderer',
'***LANGUAGE_entity_default***' => 'DefaultLanguageRenderer',
);
if (isset($dynamic_renderers[$rendering_language])) {
// Dynamic language set based on result rows or instance defaults.
$renderer = $dynamic_renderers[$rendering_language];
}
else {
if (strpos($rendering_language, '***LANGUAGE_') !== FALSE) {
$langcode = PluginBase::queryLanguageSubstitutions()[$rendering_language];
}
else {
// Specific langcode set.
$langcode = $rendering_language;
}
$renderer = 'ConfigurableLanguageRenderer';
}
$class = '\Drupal\views\Entity\Render\\' . $renderer;
$entity_type = $this->getEntityManager()->getDefinition($this->getEntityTypeId());
$this->entityLanguageRenderer = new $class($view, $this->getLanguageManager(), $entity_type, $langcode);
}
return $this->entityLanguageRenderer;
}
/**
* Returns the entity type identifier.
*
* @return string
* The entity type identifier.
*/
abstract public function getEntityTypeId();
/**
* Returns the entity manager.
*
* @return \Drupal\Core\Entity\EntityManagerInterface
* The entity manager.
*/
abstract protected function getEntityManager();
/**
* Returns the language manager.
*
* @return \Drupal\Core\Language\LanguageManagerInterface
* The language manager.
*/
abstract protected function getLanguageManager();
/**
* Returns the top object of a view.
*
* @return \Drupal\views\ViewExecutable
* The view object.
*/
abstract protected function getView();
}

View File

@ -23,7 +23,7 @@ abstract class RendererBase {
* *
* @var \Drupal\views\ViewExecutable * @var \Drupal\views\ViewExecutable
*/ */
public $view = NULL; public $view;
/** /**
* The language manager. * The language manager.
@ -62,6 +62,17 @@ abstract class RendererBase {
$this->entityType = $entity_type; $this->entityType = $entity_type;
} }
/**
* Returns the language code associated to the given row.
*
* @param \Drupal\views\ResultRow $row
* The result row.
*
* @return string
* A language code.
*/
abstract public function getLangcode(ResultRow $row);
/** /**
* Alters the query if needed. * Alters the query if needed.
* *

View File

@ -13,7 +13,7 @@ use Drupal\views\ResultRow;
/** /**
* Renders entity translations in their active language. * Renders entity translations in their active language.
*/ */
class TranslationLanguageRenderer extends DefaultLanguageRenderer { class TranslationLanguageRenderer extends RendererBase {
/** /**
* Stores the field alias of the langcode column. * Stores the field alias of the langcode column.
@ -71,7 +71,7 @@ class TranslationLanguageRenderer extends DefaultLanguageRenderer {
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
protected function getLangcode(ResultRow $row) { public function getLangcode(ResultRow $row) {
return isset($row->{$this->langcodeAlias}) ? $row->{$this->langcodeAlias} : $this->languageManager->getDefaultLanguage()->getId(); return isset($row->{$this->langcodeAlias}) ? $row->{$this->langcodeAlias} : $this->languageManager->getDefaultLanguage()->getId();
} }

View File

@ -51,6 +51,13 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
*/ */
const INCLUDE_NEGOTIATED = 16; const INCLUDE_NEGOTIATED = 16;
/**
* Include entity row languages when listing languages.
*
* @see \Drupal\views\Plugin\views\PluginBase::listLanguages()
*/
const INCLUDE_ENTITY = 32;
/** /**
* Query string to indicate the site default language. * Query string to indicate the site default language.
* *
@ -490,16 +497,25 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
* note that this is not included in STATE_ALL. * note that this is not included in STATE_ALL.
* - \Drupal\views\Plugin\views\PluginBase::INCLUDE_NEGOTIATED: Add * - \Drupal\views\Plugin\views\PluginBase::INCLUDE_NEGOTIATED: Add
* negotiated language types. * negotiated language types.
* - \Drupal\views\Plugin\views\PluginBase::INCLUDE_ENTITY: Add
* entity row language types. Note that these are only supported for
* display options, not substituted in queries.
* *
* @return array * @return array
* An array of language names, keyed by the language code. Negotiated and * An array of language names, keyed by the language code. Negotiated and
* special languages have special codes that are substituted in queries by * special languages have special codes that are substituted in queries by
* static::queryLanguageSubstitutions(). * PluginBase::queryLanguageSubstitutions().
*/ */
protected function listLanguages($flags = LanguageInterface::STATE_ALL) { protected function listLanguages($flags = LanguageInterface::STATE_ALL) {
$manager = \Drupal::languageManager(); $manager = \Drupal::languageManager();
$list = array(); $list = array();
// The entity languages should come first, if requested.
if ($flags & PluginBase::INCLUDE_ENTITY) {
$list['***LANGUAGE_entity_translation***'] = $this->t('Content language of view row');
$list['***LANGUAGE_entity_default***'] = $this->t('Original language of content in view row');
}
// The Language Manager class takes care of the STATE_SITE_DEFAULT case. // The Language Manager class takes care of the STATE_SITE_DEFAULT case.
// It comes in with ID set to LanguageInterface::LANGCODE_SITE_DEFAULT. // It comes in with ID set to LanguageInterface::LANGCODE_SITE_DEFAULT.
// Since this is not a real language, surround it by '***LANGUAGE_...***', // Since this is not a real language, surround it by '***LANGUAGE_...***',
@ -521,7 +537,7 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
// IDs by '***LANGUAGE_...***', to avoid query collisions. // IDs by '***LANGUAGE_...***', to avoid query collisions.
if (isset($type['name'])) { if (isset($type['name'])) {
$id = '***LANGUAGE_' . $id . '***'; $id = '***LANGUAGE_' . $id . '***';
$list[$id] = $this->t('Language selected for !type', array('!type' => $type['name'])); $list[$id] = $this->t('!type language selected for page', array('!type' => $type['name']));
} }
} }
} }
@ -533,7 +549,7 @@ abstract class PluginBase extends ComponentPluginBase implements ContainerFactor
* Returns substitutions for Views queries for languages. * Returns substitutions for Views queries for languages.
* *
* This is needed so that the language options returned by * This is needed so that the language options returned by
* $this->listLanguages() are able to be used in queries. It is called * PluginBase::listLanguages() are able to be used in queries. It is called
* by the Views module implementation of hook_views_query_substitutions() * by the Views module implementation of hook_views_query_substitutions()
* to get the language-related substitutions. * to get the language-related substitutions.
* *

View File

@ -195,15 +195,6 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
$this->unpackOptions($this->options, $options); $this->unpackOptions($this->options, $options);
} }
// Convert the field_langcode and field_language_add_to_query settings.
$field_langcode = $this->getOption('field_langcode');
$field_language_add_to_query = $this->getOption('field_language_add_to_query');
if (isset($field_langcode)) {
$this->setOption('field_langcode', $field_langcode);
$this->setOption('field_langcode_add_to_query', $field_language_add_to_query);
$changed = TRUE;
}
// Mark the view as changed so the user has a chance to save it. // Mark the view as changed so the user has a chance to save it.
if ($changed) { if ($changed) {
$this->view->changed = TRUE; $this->view->changed = TRUE;
@ -539,14 +530,8 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
'group_by' => array( 'group_by' => array(
'default' => FALSE, 'default' => FALSE,
), ),
'field_langcode' => array(
'default' => '***LANGUAGE_language_content***',
),
'field_langcode_add_to_query' => array(
'default' => TRUE,
),
'rendering_language' => array( 'rendering_language' => array(
'default' => 'translation_language_renderer', 'default' => '***LANGUAGE_entity_translation***',
), ),
// These types are all plugins that can have individual settings // These types are all plugins that can have individual settings
@ -1175,15 +1160,9 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
$rendering_language_options = $this->buildRenderingLanguageOptions(); $rendering_language_options = $this->buildRenderingLanguageOptions();
$options['rendering_language'] = array( $options['rendering_language'] = array(
'category' => 'language', 'category' => 'language',
'title' => $this->t('Entity Language'), 'title' => $this->t('Rendering Language'),
'value' => $rendering_language_options[$this->getOption('rendering_language')], 'value' => $rendering_language_options[$this->getOption('rendering_language')],
); 'desc' => $this->t('All content that supports translations will be displayed in the selected language.'),
$language_options = $this->listLanguages(LanguageInterface::STATE_ALL | LanguageInterface::STATE_SITE_DEFAULT | PluginBase::INCLUDE_NEGOTIATED);
$options['field_langcode'] = array(
'category' => 'language',
'title' => $this->t('Field Language'),
'value' => $language_options[$this->getOption('field_langcode')],
'desc' => $this->t('All fields that support translations will be displayed in the selected language.'),
); );
} }
@ -1533,36 +1512,15 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
$this->view->query->buildOptionsForm($form['query']['options'], $form_state); $this->view->query->buildOptionsForm($form['query']['options'], $form_state);
} }
break; break;
case 'field_langcode':
$form['#title'] .= $this->t('Field Language');
if ($this->isBaseTableTranslatable()) {
$languages = $this->listLanguages(LanguageInterface::STATE_ALL | LanguageInterface::STATE_SITE_DEFAULT | PluginBase::INCLUDE_NEGOTIATED);
$form['field_langcode'] = array(
'#type' => 'select',
'#title' => $this->t('Field Language'),
'#description' => $this->t('All fields which support translations will be displayed in the selected language.'),
'#options' => $languages,
'#default_value' => $this->getOption('field_langcode'),
);
$form['field_langcode_add_to_query'] = array(
'#type' => 'checkbox',
'#title' => $this->t('When needed, add the field language condition to the query'),
'#default_value' => $this->getOption('field_langcode_add_to_query'),
);
}
else {
$form['field_language']['#markup'] = $this->t("You don't have translatable entity types.");
}
break;
case 'rendering_language': case 'rendering_language':
$form['#title'] .= $this->t('Entity Language'); $form['#title'] .= $this->t('Rendering language');
if ($this->isBaseTableTranslatable()) { if ($this->isBaseTableTranslatable()) {
$options = $this->buildRenderingLanguageOptions(); $options = $this->buildRenderingLanguageOptions();
$form['rendering_language'] = array( $form['rendering_language'] = array(
'#type' => 'select', '#type' => 'select',
'#options' => $options, '#options' => $options,
'#title' => $this->t('Entity language'), '#title' => $this->t('Rendering language'),
'#description' => $this->t('All content that supports translations will be displayed in the selected language.'),
'#default_value' => $this->getOption('rendering_language'), '#default_value' => $this->getOption('rendering_language'),
); );
} }
@ -1882,10 +1840,6 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
case 'group_by': case 'group_by':
$this->setOption($section, $form_state->getValue($section)); $this->setOption($section, $form_state->getValue($section));
break; break;
case 'field_langcode':
$this->setOption('field_langcode', $form_state->getValue('field_langcode'));
$this->setOption('field_langcode_add_to_query', $form_state->getValue('field_langcode_add_to_query'));
break;
case 'rendering_language': case 'rendering_language':
$this->setOption('rendering_language', $form_state->getValue('rendering_language')); $this->setOption('rendering_language', $form_state->getValue('rendering_language'));
break; break;
@ -2515,11 +2469,7 @@ abstract class DisplayPluginBase extends PluginBase implements DisplayPluginInte
*/ */
protected function buildRenderingLanguageOptions() { protected function buildRenderingLanguageOptions() {
// @todo Consider making these plugins. See https://drupal.org/node/2173811. // @todo Consider making these plugins. See https://drupal.org/node/2173811.
return array( return $this->listLanguages(LanguageInterface::STATE_CONFIGURABLE | LanguageInterface::STATE_SITE_DEFAULT | PluginBase::INCLUDE_NEGOTIATED | PluginBase::INCLUDE_ENTITY);
'current_language_renderer' => $this->t('Current language'),
'default_language_renderer' => $this->t('Default language'),
'translation_language_renderer' => $this->t('Translation language'),
);
} }
/** /**

View File

@ -11,9 +11,6 @@ use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\Xss as CoreXss; use Drupal\Component\Utility\Xss as CoreXss;
use Drupal\Core\Entity\EntityInterface; use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Entity\EntityStorageInterface;
use Drupal\Core\Field\BaseFieldDefinition;
use Drupal\Core\Field\FieldConfigInterface;
use Drupal\Core\Field\FieldStorageDefinitionInterface; use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Field\FieldTypePluginManagerInterface; use Drupal\Core\Field\FieldTypePluginManagerInterface;
use Drupal\Core\Field\FormatterPluginManager; use Drupal\Core\Field\FormatterPluginManager;
@ -24,15 +21,12 @@ use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\Core\Render\Element; use Drupal\Core\Render\Element;
use Drupal\Core\Render\RendererInterface; use Drupal\Core\Render\RendererInterface;
use Drupal\Core\Session\AccountInterface; use Drupal\Core\Session\AccountInterface;
use Drupal\field\FieldStorageConfigInterface;
use Drupal\field\Views\FieldAPIHandlerTrait; use Drupal\field\Views\FieldAPIHandlerTrait;
use Drupal\views\Entity\Render\EntityTranslationRenderTrait;
use Drupal\views\Plugin\CacheablePluginInterface; use Drupal\views\Plugin\CacheablePluginInterface;
use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\Plugin\views\field\FieldPluginBase;
use Drupal\views\Plugin\views\field\MultiItemsFieldHandlerInterface;
use Drupal\views\ResultRow; use Drupal\views\ResultRow;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Drupal\views\Views;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
/** /**
@ -45,6 +39,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* @ViewsField("field") * @ViewsField("field")
*/ */
class Field extends FieldPluginBase implements CacheablePluginInterface, MultiItemsFieldHandlerInterface { class Field extends FieldPluginBase implements CacheablePluginInterface, MultiItemsFieldHandlerInterface {
use EntityTranslationRenderTrait;
use FieldAPIHandlerTrait; use FieldAPIHandlerTrait;
@ -203,6 +198,33 @@ class Field extends FieldPluginBase implements CacheablePluginInterface, MultiIt
} }
} }
/**
* {@inheritdoc}
*/
public function getEntityTypeId() {
return $this->getEntityType();
}
/**
* {@inheritdoc}
*/
protected function getEntityManager() {
return $this->entityManager;
}
/**
* {@inheritdoc}
*/
protected function getLanguageManager() {
return $this->languageManager;
}
/**
* {@inheritdoc}
*/
protected function getView() {
return $this->view;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -247,24 +269,10 @@ class Field extends FieldPluginBase implements CacheablePluginInterface, MultiIt
if ($this->add_field_table($use_groupby)) { if ($this->add_field_table($use_groupby)) {
$this->ensureMyTable(); $this->ensureMyTable();
$this->addAdditionalFields($fields); $this->addAdditionalFields($fields);
}
// If we are grouping by something on this field, we want to group by // Let the configured entity translation renderer alter the query if needed.
// the displayed value, which is translated. So, we need to figure out $this->getEntityTranslationRenderer()->query($this->query);
// which language should be used to translate the value. See also
// $this->field_langcode().
$field = $field_definition;
if ($field->isTranslatable() && !empty($this->view->display_handler->options['field_langcode_add_to_query'])) {
$column = $this->tableAlias . '.langcode';
$langcode = $this->view->display_handler->options['field_langcode'];
$substitutions = static::queryLanguageSubstitutions();
if (isset($substitutions[$langcode])) {
$langcode = $substitutions[$langcode];
}
$placeholder = $this->placeholder();
$langcode_fallback_candidates = $this->languageManager->getFallbackCandidates(array('langcode' => $langcode, 'operation' => 'views_query', 'data' => $this));
$this->query->addWhereExpression(0, "$column IN($placeholder) OR $column IS NULL", array($placeholder => $langcode_fallback_candidates));
}
}
} }
/** /**
@ -758,7 +766,7 @@ class Field extends FieldPluginBase implements CacheablePluginInterface, MultiIt
function process_entity(ResultRow $values, EntityInterface $entity) { function process_entity(ResultRow $values, EntityInterface $entity) {
$processed_entity = clone $entity; $processed_entity = clone $entity;
$langcode = $this->field_langcode($processed_entity); $langcode = $this->getFieldLangcode($processed_entity, $values);
$processed_entity = $processed_entity->getTranslation($langcode); $processed_entity = $processed_entity->getTranslation($langcode);
// If we are grouping, copy our group fields into the cloned entity. // If we are grouping, copy our group fields into the cloned entity.
@ -886,16 +894,23 @@ class Field extends FieldPluginBase implements CacheablePluginInterface, MultiIt
} }
/** /**
* Return the language code of the language the field should be displayed in, * Return the code of the language the field should be displayed in.
* according to the settings. *
* @param \Drupal\Core\Entity\EntityInterface $entity
* The entity object the field value being processed is attached to.
* @param \Drupal\views\ResultRow $row
* The result row the field value being processed belongs to.
*
* @return string
* The field language code.
*/ */
function field_langcode(EntityInterface $entity) { protected function getFieldLangcode(EntityInterface $entity, ResultRow $row) {
if ($this->getFieldDefinition()->isTranslatable()) { if ($this->getFieldDefinition()->isTranslatable()) {
$langcode = $this->view->display_handler->options['field_langcode']; // Even if the current field is not attached to the main entity, we use it
$substitutions = static::queryLanguageSubstitutions(); // to determine the field language, as we assume the same language should
if (isset($substitutions[$langcode])) { // be used for all values belonging to a single row, when possible. Below
$langcode = $substitutions[$langcode]; // we apply language fallback to ensure a valid value is always picked.
} $langcode = $this->getEntityTranslationRenderer()->getLangcode($row);
// Give the Entity Field API a chance to fallback to a different language // Give the Entity Field API a chance to fallback to a different language
// (or LanguageInterface::LANGCODE_NOT_SPECIFIED), in case the field has // (or LanguageInterface::LANGCODE_NOT_SPECIFIED), in case the field has

View File

@ -8,10 +8,10 @@
namespace Drupal\views\Plugin\views\row; namespace Drupal\views\Plugin\views\row;
use Drupal\Component\Utility\String; use Drupal\Component\Utility\String;
use Drupal\Core\DependencyInjection\Container;
use Drupal\Core\Entity\EntityManagerInterface; use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\Core\Form\FormStateInterface; use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Language\LanguageManagerInterface; use Drupal\Core\Language\LanguageManagerInterface;
use Drupal\views\Entity\Render\EntityTranslationRenderTrait;
use Drupal\views\Plugin\views\display\DisplayPluginBase; use Drupal\views\Plugin\views\display\DisplayPluginBase;
use Drupal\views\ViewExecutable; use Drupal\views\ViewExecutable;
use Symfony\Component\DependencyInjection\ContainerInterface; use Symfony\Component\DependencyInjection\ContainerInterface;
@ -25,6 +25,7 @@ use Symfony\Component\DependencyInjection\ContainerInterface;
* ) * )
*/ */
class EntityRow extends RowPluginBase { class EntityRow extends RowPluginBase {
use EntityTranslationRenderTrait;
/** /**
* The table the entity is using for storage. * The table the entity is using for storage.
@ -54,13 +55,6 @@ class EntityRow extends RowPluginBase {
*/ */
protected $entityType; protected $entityType;
/**
* The renderer to be used to render the entity row.
*
* @var \Drupal\views\Entity\Rendering\RendererBase
*/
protected $renderer;
/** /**
* The entity manager. * The entity manager.
* *
@ -109,6 +103,34 @@ class EntityRow extends RowPluginBase {
return new static($configuration, $plugin_id, $plugin_definition, $container->get('entity.manager'), $container->get('language_manager')); return new static($configuration, $plugin_id, $plugin_definition, $container->get('entity.manager'), $container->get('language_manager'));
} }
/**
* {@inheritdoc}
*/
public function getEntityTypeId() {
return $this->entityType->id();
}
/**
* {@inheritdoc}
*/
protected function getEntityManager() {
return $this->entityManager;
}
/**
* {@inheritdoc}
*/
protected function getLanguageManager() {
return $this->languageManager;
}
/**
* {@inheritdoc}
*/
protected function getView() {
return $this->view;
}
/** /**
* Overrides Drupal\views\Plugin\views\row\RowPluginBase::defineOptions(). * Overrides Drupal\views\Plugin\views\row\RowPluginBase::defineOptions().
*/ */
@ -145,26 +167,12 @@ class EntityRow extends RowPluginBase {
} }
} }
/**
* Returns the current renderer.
*
* @return \Drupal\views\Entity\Render\RendererBase
* The configured renderer.
*/
protected function getRenderer() {
if (!isset($this->renderer)) {
$class = '\Drupal\views\Entity\Render\\' . Container::camelize($this->displayHandler->getOption('rendering_language'));
$this->renderer = new $class($this->view, $this->languageManager, $this->entityType);
}
return $this->renderer;
}
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
public function query() { public function query() {
parent::query(); parent::query();
$this->getRenderer()->query($this->view->getQuery()); $this->getEntityTranslationRenderer()->query($this->view->getQuery());
} }
/** /**
@ -173,7 +181,7 @@ class EntityRow extends RowPluginBase {
public function preRender($result) { public function preRender($result) {
parent::preRender($result); parent::preRender($result);
if ($result) { if ($result) {
$this->getRenderer()->preRender($result); $this->getEntityTranslationRenderer()->preRender($result);
} }
} }
@ -181,7 +189,7 @@ class EntityRow extends RowPluginBase {
* Overrides Drupal\views\Plugin\views\row\RowPluginBase::render(). * Overrides Drupal\views\Plugin\views\row\RowPluginBase::render().
*/ */
public function render($row) { public function render($row) {
return $this->getRenderer()->render($row); return $this->getEntityTranslationRenderer()->render($row);
} }
/** /**

View File

@ -25,7 +25,7 @@ class RowEntityRenderersTest extends ViewUnitTestBase {
* *
* @var array * @var array
*/ */
public static $modules = array('field', 'filter', 'text', 'node', 'user', 'language', 'entity_reference'); public static $modules = array('field', 'filter', 'text', 'node', 'user', 'language', 'entity_reference', 'views_test_language');
/** /**
* Views used by this test. * Views used by this test.
@ -41,6 +41,13 @@ class RowEntityRenderersTest extends ViewUnitTestBase {
*/ */
protected $langcodes; protected $langcodes;
/**
* An array of titles for each node per language.
*
* @var array
*/
protected $expected;
/** /**
* {@inheritdoc} * {@inheritdoc}
*/ */
@ -66,13 +73,8 @@ class RowEntityRenderersTest extends ViewUnitTestBase {
$node_type = NodeType::create(array('type' => 'test')); $node_type = NodeType::create(array('type' => 'test'));
$node_type->setDisplaySubmitted(FALSE); $node_type->setDisplaySubmitted(FALSE);
$node_type->save(); $node_type->save();
}
/** $this->values = array();
* Tests the entity row renderers.
*/
public function testRenderers() {
$values = array();
$controller = \Drupal::entityManager()->getStorage('node'); $controller = \Drupal::entityManager()->getStorage('node');
$langcode_index = 0; $langcode_index = 0;
@ -85,19 +87,45 @@ class RowEntityRenderersTest extends ViewUnitTestBase {
foreach ($langcodes as $langcode) { foreach ($langcodes as $langcode) {
// Ensure we have a predictable result order. // Ensure we have a predictable result order.
$values[$i][$langcode] = $i . '-' . $langcode . '-' . $this->randomMachineName(); $this->values[$i][$langcode] = $i . '-' . $langcode . '-' . $this->randomMachineName();
if ($langcode != $default_langcode) { if ($langcode != $default_langcode) {
$node->addTranslation($langcode, array('title' => $values[$i][$langcode])); $node->addTranslation($langcode, array('title' => $this->values[$i][$langcode]));
} }
else { else {
$node->setTitle($values[$i][$langcode]); $node->setTitle($this->values[$i][$langcode]);
} }
$node->save(); $node->save();
} }
} }
}
/**
* Tests the entity row renderers.
*/
public function testEntityRenderers() {
$this->checkLanguageRenderers('page_1', $this->values);
}
/**
* Tests the field row renderers.
*/
public function testFieldRenderers() {
$this->checkLanguageRenderers('page_2', $this->values);
}
/**
* Checks that the language renderer configurations work as expected.
*
* @param string $display
* Name of display to test with.
* @param array $values
* An array of node information which are each an array of node titles
* associated with language keys appropriate for the translation of that
* node.
*/
protected function checkLanguageRenderers($display, $values) {
$expected = array( $expected = array(
$values[0]['en'], $values[0]['en'],
$values[0]['en'], $values[0]['en'],
@ -109,7 +137,7 @@ class RowEntityRenderersTest extends ViewUnitTestBase {
$values[2]['en'], $values[2]['en'],
$values[2]['en'], $values[2]['en'],
); );
$this->assertTranslations('current_language_renderer', $expected, 'The current language renderer behaves as expected.'); $this->assertTranslations($display, '***LANGUAGE_language_content***', $expected, 'The current language renderer behaves as expected.');
$expected = array( $expected = array(
$values[0]['en'], $values[0]['en'],
@ -122,7 +150,7 @@ class RowEntityRenderersTest extends ViewUnitTestBase {
$values[2]['l1'], $values[2]['l1'],
$values[2]['l1'], $values[2]['l1'],
); );
$this->assertTranslations('default_language_renderer', $expected, 'The default language renderer behaves as expected.'); $this->assertTranslations($display, '***LANGUAGE_entity_default***', $expected, 'The default language renderer behaves as expected.');
$expected = array( $expected = array(
$values[0]['en'], $values[0]['en'],
@ -135,12 +163,40 @@ class RowEntityRenderersTest extends ViewUnitTestBase {
$values[2]['l0'], $values[2]['l0'],
$values[2]['l1'], $values[2]['l1'],
); );
$this->assertTranslations('translation_language_renderer', $expected, 'The translation language renderer behaves as expected.'); $this->assertTranslations($display, '***LANGUAGE_entity_translation***', $expected, 'The translation language renderer behaves as expected.');
$expected = array(
$values[0][$this->langcodes[0]],
$values[0][$this->langcodes[0]],
$values[0][$this->langcodes[0]],
$values[1][$this->langcodes[0]],
$values[1][$this->langcodes[0]],
$values[1][$this->langcodes[0]],
$values[2][$this->langcodes[0]],
$values[2][$this->langcodes[0]],
$values[2][$this->langcodes[0]],
);
$this->assertTranslations($display, '***LANGUAGE_site_default***', $expected, 'The site default language renderer behaves as expected.');
$expected = array(
$values[0]['l0'],
$values[0]['l0'],
$values[0]['l0'],
$values[1]['l0'],
$values[1]['l0'],
$values[1]['l0'],
$values[2]['l0'],
$values[2]['l0'],
$values[2]['l0'],
);
$this->assertTranslations($display, 'l0', $expected, 'The language specific renderer behaves as expected.');
} }
/** /**
* Checks that the view results match the expected values. * Checks that the view results match the expected values.
* *
* @param string $display
* Name of display to test with.
* @param string $renderer_id * @param string $renderer_id
* The id of the renderer to be tested. * The id of the renderer to be tested.
* @param array $expected * @param array $expected
@ -153,20 +209,27 @@ class RowEntityRenderersTest extends ViewUnitTestBase {
* @return bool * @return bool
* TRUE if the assertion succeeded, FALSE otherwise. * TRUE if the assertion succeeded, FALSE otherwise.
*/ */
protected function assertTranslations($renderer_id, array $expected, $message = '', $group = 'Other') { protected function assertTranslations($display, $renderer_id, array $expected, $message = '', $group = 'Other') {
$view = Views::getView('test_entity_row_renderers'); $view = Views::getView('test_entity_row_renderers');
$view->setDisplay($display);
$view->getDisplay()->setOption('rendering_language', $renderer_id); $view->getDisplay()->setOption('rendering_language', $renderer_id);
$view->preview(); $view->preview();
$result = TRUE; $result = FALSE;
foreach ($view->result as $index => $row) { foreach ($expected as $index => $expected_output) {
$build = $view->rowPlugin->render($row); if (!empty($view->result[$index])) {
$build = $view->rowPlugin->render($view->result[$index]);
$output = drupal_render($build); $output = drupal_render($build);
$result = strpos($output, $expected[$index]) !== FALSE; $result = strpos($output, $expected_output) !== FALSE;
if (!$result) { if (!$result) {
break; break;
} }
} }
else {
$result = FALSE;
break;
}
}
return $this->assertTrue($result, $message, $group); return $this->assertTrue($result, $message, $group);
} }

View File

@ -24,8 +24,6 @@ display:
type: default type: default
row: row:
type: fields type: fields
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default

View File

@ -59,8 +59,6 @@ display:
type: default type: default
row: row:
type: fields type: fields
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default

View File

@ -49,8 +49,6 @@ display:
table: views_test_data table: views_test_data
plugin_id: numeric plugin_id: numeric
use_ajax: true use_ajax: true
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default
@ -58,8 +56,6 @@ display:
page_1: page_1:
display_options: display_options:
path: test_ajax_view path: test_ajax_view
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: page display_plugin: page
display_title: Page display_title: Page
id: page_1 id: page_1

View File

@ -91,8 +91,6 @@ display:
type: views_query type: views_query
row: row:
type: fields type: fields
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default

View File

@ -42,8 +42,6 @@ display:
table: views table: views
plugin_id: title plugin_id: title
title: test_title_empty title: test_title_empty
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default
@ -60,8 +58,6 @@ display:
table: views table: views
plugin_id: title plugin_id: title
title: test_title_header title: test_title_header
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: page display_plugin: page
display_title: 'Page 1' display_title: 'Page 1'
id: page_1 id: page_1

View File

@ -43,8 +43,6 @@ display:
view_to_insert: 'test_simple_argument:default' view_to_insert: 'test_simple_argument:default'
inherit_arguments: true inherit_arguments: true
plugin_id: view plugin_id: view
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default

View File

@ -41,8 +41,6 @@ display:
relationship: none relationship: none
table: views_test_data table: views_test_data
plugin_id: numeric plugin_id: numeric
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default
@ -57,8 +55,6 @@ display:
id: date_day id: date_day
table: views_test_data table: views_test_data
plugin_id: date_day plugin_id: date_day
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: embed display_plugin: embed
id: embed_1 id: embed_1
display_title: '' display_title: ''
@ -73,8 +69,6 @@ display:
id: date_month id: date_month
table: views_test_data table: views_test_data
plugin_id: date_month plugin_id: date_month
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: embed display_plugin: embed
id: embed_2 id: embed_2
display_title: '' display_title: ''
@ -89,8 +83,6 @@ display:
id: date_week id: date_week
table: views_test_data table: views_test_data
plugin_id: date_week plugin_id: date_week
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: embed display_plugin: embed
id: embed_3 id: embed_3
display_title: '' display_title: ''
@ -105,8 +97,6 @@ display:
id: date_year id: date_year
table: views_test_data table: views_test_data
plugin_id: date_year plugin_id: date_year
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: embed display_plugin: embed
id: embed_4 id: embed_4
display_title: '' display_title: ''
@ -121,8 +111,6 @@ display:
id: date_year_month id: date_year_month
table: views_test_data table: views_test_data
plugin_id: date_year_month plugin_id: date_year_month
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: embed display_plugin: embed
id: embed_5 id: embed_5
display_title: '' display_title: ''

View File

@ -58,8 +58,6 @@ display:
type: default type: default
row: row:
type: fields type: fields
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default

View File

@ -58,8 +58,6 @@ display:
type: default type: default
row: row:
type: fields type: fields
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null
display_plugin: default display_plugin: default
display_title: Master display_title: Master
id: default id: default

View File

@ -216,5 +216,3 @@ display:
entity_field: uid entity_field: uid
plugin_id: numeric plugin_id: numeric
display_extenders: { } display_extenders: { }
field_langcode: '***LANGUAGE_language_content***'
field_langcode_add_to_query: null

Some files were not shown because too many files have changed in this diff Show More