Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
project
drupal
Commits
88b40cc6
Commit
88b40cc6
authored
Aug 26, 2012
by
Daniel Wehner
Committed by
Tim Plunkett
Oct 21, 2012
Browse files
Issue
#1605332
by dawehner, tim.plunkett: Adapt language integration to d8.
parent
472311d5
Changes
22
Hide whitespace changes
Inline
Side-by-side
lib/Drupal/views/Plugin/views/cache/CachePluginBase.php
View file @
88b40cc6
...
...
@@ -289,7 +289,7 @@ function get_results_key() {
'build_info'
=>
$build_info
,
'roles'
=>
array_keys
(
$user
->
roles
),
'super-user'
=>
$user
->
uid
==
1
,
// special caching for super user.
'lang
uag
e'
=>
language
(
LANGUAGE_TYPE_INTERFACE
)
->
langcode
,
'lang
cod
e'
=>
language
(
LANGUAGE_TYPE_INTERFACE
)
->
langcode
,
'base_url'
=>
$GLOBALS
[
'base_url'
],
);
foreach
(
array
(
'exposed_info'
,
'page'
,
'sort'
,
'order'
,
'items_per_page'
,
'offset'
)
as
$key
)
{
...
...
@@ -312,7 +312,7 @@ function get_output_key() {
'roles'
=>
array_keys
(
$user
->
roles
),
'super-user'
=>
$user
->
uid
==
1
,
// special caching for super user.
'theme'
=>
$GLOBALS
[
'theme'
],
'lang
uag
e'
=>
language
(
LANGUAGE_TYPE_INTERFACE
)
->
langcode
,
'lang
cod
e'
=>
language
(
LANGUAGE_TYPE_INTERFACE
)
->
langcode
,
'base_url'
=>
$GLOBALS
[
'base_url'
],
);
...
...
lib/Drupal/views/Plugin/views/display/DisplayPluginBase.php
View file @
88b40cc6
...
...
@@ -134,6 +134,15 @@ function init(&$view, &$display, $options = NULL) {
$this
->
unpack_options
(
$this
->
options
,
$options
);
}
// Convert the field_language and field_language_add_to_query settings.
$field_language
=
$this
->
get_option
(
'field_language'
);
$field_language_add_to_query
=
$this
->
get_option
(
'field_language_add_to_query'
);
if
(
isset
(
$field_langcode
))
{
$this
->
set_option
(
'field_langcode'
,
$field_language
);
$this
->
set_option
(
'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.
if
(
$changed
)
{
$this
->
view
->
changed
=
TRUE
;
...
...
@@ -487,11 +496,12 @@ function option_definition() {
'default'
=>
FALSE
,
'bool'
=>
TRUE
,
),
'field_lang
uag
e'
=>
array
(
'field_lang
cod
e'
=>
array
(
'default'
=>
'***CURRENT_LANGUAGE***'
,
),
'field_language_add_to_query'
=>
array
(
'default'
=>
1
,
'field_langcode_add_to_query'
=>
array
(
'default'
=>
TRUE
,
'bool'
=>
TRUE
,
),
// These types are all plugins that can have individual settings
...
...
@@ -1213,11 +1223,10 @@ function options_summary(&$categories, &$options) {
if
(
module_exists
(
'language'
))
{
$languages
=
array_merge
(
$languages
,
language_list
());
}
$field_language
=
array
();
$options
[
'field_language'
]
=
array
(
$options
[
'field_langcode'
]
=
array
(
'category'
=>
'other'
,
'title'
=>
t
(
'Field Language'
),
'value'
=>
$languages
[
$this
->
get_option
(
'field_lang
uag
e'
)],
'value'
=>
$languages
[
$this
->
get_option
(
'field_lang
cod
e'
)],
'desc'
=>
t
(
'All fields which support translations will be displayed in the selected language.'
),
);
...
...
@@ -1607,17 +1616,17 @@ function options_form(&$form, &$form_state) {
);
$languages
=
array_merge
(
$languages
,
views_language_list
());
$form
[
'field_lang
uag
e'
]
=
array
(
$form
[
'field_lang
cod
e'
]
=
array
(
'#type'
=>
'select'
,
'#title'
=>
t
(
'Field Language'
),
'#description'
=>
t
(
'All fields which support translations will be displayed in the selected language.'
),
'#options'
=>
$languages
,
'#default_value'
=>
$this
->
get_option
(
'field_lang
uag
e'
),
'#default_value'
=>
$this
->
get_option
(
'field_lang
cod
e'
),
);
$form
[
'field_lang
uag
e_add_to_query'
]
=
array
(
$form
[
'field_lang
cod
e_add_to_query'
]
=
array
(
'#type'
=>
'checkbox'
,
'#title'
=>
t
(
'When needed, add the field language condition to the query'
),
'#default_value'
=>
$this
->
get_option
(
'field_lang
uag
e_add_to_query'
),
'#default_value'
=>
$this
->
get_option
(
'field_lang
cod
e_add_to_query'
),
);
}
else
{
...
...
@@ -2281,8 +2290,8 @@ function options_submit(&$form, &$form_state) {
$this
->
set_option
(
$section
,
$form_state
[
'values'
][
$section
]);
break
;
case
'field_language'
:
$this
->
set_option
(
'field_lang
uag
e'
,
$form_state
[
'values'
][
'field_lang
uag
e'
]);
$this
->
set_option
(
'field_lang
uag
e_add_to_query'
,
$form_state
[
'values'
][
'field_lang
uag
e_add_to_query'
]);
$this
->
set_option
(
'field_lang
cod
e'
,
$form_state
[
'values'
][
'field_lang
cod
e'
]);
$this
->
set_option
(
'field_lang
cod
e_add_to_query'
,
$form_state
[
'values'
][
'field_lang
cod
e_add_to_query'
]);
break
;
case
'use_ajax'
:
case
'hide_attachment_summary'
:
...
...
lib/Views/field/Plugin/views/field/Field.php
View file @
88b40cc6
...
...
@@ -223,26 +223,26 @@ function query($use_groupby = FALSE) {
$this
->
ensure_my_table
();
$this
->
add_additional_fields
(
$fields
);
// Filter by lang
uag
e, if field translation is enabled.
// Filter by lang
cod
e, if field translation is enabled.
$field
=
$this
->
field_info
;
if
(
field_is_translatable
(
$entity_type
,
$field
)
&&
!
empty
(
$this
->
view
->
display_handler
->
options
[
'field_lang
uag
e_add_to_query'
]))
{
$column
=
$this
->
table_alias
.
'.lang
uag
e'
;
if
(
field_is_translatable
(
$entity_type
,
$field
)
&&
!
empty
(
$this
->
view
->
display_handler
->
options
[
'field_lang
cod
e_add_to_query'
]))
{
$column
=
$this
->
table_alias
.
'.lang
cod
e'
;
// By the same reason as field_language the field might be LANGUAGE_NOT_SPECIFIED in reality so allow it as well.
// @see this::field_lang
uag
e()
$default_lang
uag
e
=
language_default
()
->
langcode
;
$lang
uag
e
=
str_replace
(
array
(
'***CURRENT_LANGUAGE***'
,
'***DEFAULT_LANGUAGE***'
),
array
(
drupal_container
()
->
get
(
LANGUAGE_TYPE_CONTENT
)
->
langcode
,
$default_lang
uag
e
),
$this
->
view
->
display_handler
->
options
[
'field_lang
uag
e'
]);
// @see this::field_lang
cod
e()
$default_lang
cod
e
=
language_default
()
->
langcode
;
$lang
cod
e
=
str_replace
(
array
(
'***CURRENT_LANGUAGE***'
,
'***DEFAULT_LANGUAGE***'
),
array
(
drupal_container
()
->
get
(
LANGUAGE_TYPE_CONTENT
)
->
langcode
,
$default_lang
cod
e
),
$this
->
view
->
display_handler
->
options
[
'field_lang
cod
e'
]);
$placeholder
=
$this
->
placeholder
();
$lang
uag
e_fallback_candidates
=
array
(
$lang
uag
e
);
$lang
cod
e_fallback_candidates
=
array
(
$lang
cod
e
);
if
(
variable_get
(
'locale_field_language_fallback'
,
TRUE
))
{
require_once
DRUPAL_ROOT
.
'/includes/language.inc'
;
$lang
uag
e_fallback_candidates
=
array_merge
(
$lang
uag
e_fallback_candidates
,
language_fallback_get_candidates
());
$lang
cod
e_fallback_candidates
=
array_merge
(
$lang
cod
e_fallback_candidates
,
language_fallback_get_candidates
());
}
else
{
$lang
uag
e_fallback_candidates
[]
=
LANGUAGE_NOT_SPECIFIED
;
$lang
cod
e_fallback_candidates
[]
=
LANGUAGE_NOT_SPECIFIED
;
}
$this
->
query
->
add_where_expression
(
0
,
"
$column
IN(
$placeholder
) OR
$column
IS NULL"
,
array
(
$placeholder
=>
$lang
uag
e_fallback_candidates
));
$this
->
query
->
add_where_expression
(
0
,
"
$column
IN(
$placeholder
) OR
$column
IS NULL"
,
array
(
$placeholder
=>
$lang
cod
e_fallback_candidates
));
}
}
...
...
@@ -719,7 +719,7 @@ function get_value($values, $field = NULL) {
$entity
=
clone
$values
->
_field_data
[
$this
->
field_alias
][
'entity'
];
$entity_type
=
$values
->
_field_data
[
$this
->
field_alias
][
'entity_type'
];
$langcode
=
$this
->
field_lang
uag
e
(
$entity_type
,
$entity
);
$langcode
=
$this
->
field_lang
cod
e
(
$entity_type
,
$entity
);
// If we are grouping, copy our group fields into the cloned entity.
// It's possible this will cause some weirdness, but there's only
// so much we can hope to do.
...
...
@@ -840,7 +840,7 @@ function set_items($values, $row_id) {
return
array
();
}
$langcode
=
$this
->
field_lang
uag
e
(
$entity_type
,
$entity
);
$langcode
=
$this
->
field_lang
cod
e
(
$entity_type
,
$entity
);
$render_array
=
field_view_field
(
$entity_type
,
$entity
,
$this
->
definition
[
'field_name'
],
$display
,
$langcode
);
$items
=
array
();
...
...
@@ -906,20 +906,20 @@ function add_self_tokens(&$tokens, $item) {
* Return the language code of the language the field should be displayed in,
* according to the settings.
*/
function
field_lang
uag
e
(
$entity_type
,
$entity
)
{
function
field_lang
cod
e
(
$entity_type
,
$entity
)
{
if
(
field_is_translatable
(
$entity_type
,
$this
->
field_info
))
{
$default_lang
uag
e
=
language_default
()
->
langcode
;
$lang
uag
e
=
str_replace
(
array
(
'***CURRENT_LANGUAGE***'
,
'***DEFAULT_LANGUAGE***'
),
array
(
drupal_container
()
->
get
(
LANGUAGE_TYPE_CONTENT
)
->
langcode
,
$default_lang
uag
e
),
$default_lang
cod
e
=
language_default
()
->
langcode
;
$lang
cod
e
=
str_replace
(
array
(
'***CURRENT_LANGUAGE***'
,
'***DEFAULT_LANGUAGE***'
),
array
(
drupal_container
()
->
get
(
LANGUAGE_TYPE_CONTENT
)
->
langcode
,
$default_lang
cod
e
),
$this
->
view
->
display_handler
->
options
[
'field_language'
]);
// Give the Field Language API a chance to fallback to a different language
// (or LANGUAGE_NOT_SPECIFIED), in case the field has no data for the selected language.
// field_view_field() does this as well, but since the returned language code
// is used before calling it, the fallback needs to happen explicitly.
$lang
uag
e
=
field_language
(
$entity_type
,
$entity
,
$this
->
field_info
[
'field_name'
],
$lang
uag
e
);
$lang
cod
e
=
field_language
(
$entity_type
,
$entity
,
$this
->
field_info
[
'field_name'
],
$lang
cod
e
);
return
$lang
uag
e
;
return
$lang
cod
e
;
}
else
{
return
LANGUAGE_NOT_SPECIFIED
;
...
...
lib/Views/locale/Plugin/views/argument/Language.php
View file @
88b40cc6
...
...
@@ -2,10 +2,10 @@
/**
* @file
* Definition of Views\l
ocal
e\Plugin\views\argument\Language.
* Definition of Views\l
anguag
e\Plugin\views\argument\Language.
*/
namespace
Views\l
ocal
e\Plugin\views\argument
;
namespace
Views\l
anguag
e\Plugin\views\argument
;
use
Drupal\views\Plugin\views\argument\ArgumentPluginBase
;
use
Drupal\Core\Annotation\Plugin
;
...
...
@@ -16,22 +16,18 @@
* @ingroup views_argument_handlers
*
* @Plugin(
* id = "
locale_
language",
* module = "l
ocal
e"
* id = "language",
* module = "l
anguag
e"
* )
*/
class
Language
extends
ArgumentPluginBase
{
function
construct
()
{
parent
::
construct
(
'language'
);
}
/**
* Override the behavior of summary_name(). Get the user friendly version
* of the language.
*/
function
summary_name
(
$data
)
{
return
$this
->
locale_
language
(
$data
->
{
$this
->
name_alias
});
return
$this
->
language
(
$data
->
{
$this
->
name_alias
});
}
/**
...
...
@@ -39,10 +35,10 @@ function summary_name($data) {
* of the language.
*/
function
title
()
{
return
$this
->
locale_
language
(
$this
->
argument
);
return
$this
->
language
(
$this
->
argument
);
}
function
locale_
language
(
$langcode
)
{
function
language
(
$langcode
)
{
$languages
=
views_language_list
();
return
isset
(
$languages
[
$langcode
])
?
$languages
[
$langcode
]
:
t
(
'Unknown language'
);
}
...
...
lib/Views/locale/Plugin/views/field/Language.php
View file @
88b40cc6
...
...
@@ -2,10 +2,10 @@
/**
* @file
* Definition of Views\l
ocal
e\Plugin\views\field\Language.
* Definition of Views\l
anguag
e\Plugin\views\field\Language.
*/
namespace
Views\l
ocal
e\Plugin\views\field
;
namespace
Views\l
anguag
e\Plugin\views\field
;
use
Drupal\views\Plugin\views\field\FieldPluginBase
;
use
Drupal\Core\Annotation\Plugin
;
...
...
@@ -16,8 +16,8 @@
* @ingroup views_field_handlers
*
* @Plugin(
* id = "
locale_
language",
* module = "l
ocal
e"
* id = "language",
* module = "l
anguag
e"
* )
*/
class
Language
extends
FieldPluginBase
{
...
...
@@ -40,9 +40,11 @@ function options_form(&$form, &$form_state) {
}
function
render
(
$values
)
{
$languages
=
locale_language_list
(
empty
(
$this
->
options
[
'native_language'
])
?
'name'
:
'native'
);
// @todo: Drupal Core dropped native language until config translation is
// ready, see http://drupal.org/node/1616594.
$value
=
$this
->
get_value
(
$values
);
return
isset
(
$languages
[
$value
])
?
$languages
[
$value
]
:
''
;
$language
=
language_load
(
$value
);
return
$language
?
$language
->
name
:
''
;
}
}
lib/Views/locale/Plugin/views/field/NodeLanguage.php
View file @
88b40cc6
...
...
@@ -2,10 +2,10 @@
/**
* @file
* Definition of Views\
local
e\Plugin\views\field\
Node
Language.
* Definition of Views\
nod
e\Plugin\views\field\Language.
*/
namespace
Views\
local
e\Plugin\views\field
;
namespace
Views\
nod
e\Plugin\views\field
;
use
Views\node\Plugin\views\field\Node
;
use
Drupal\Core\Annotation\Plugin
;
...
...
@@ -17,10 +17,10 @@
*
* @Plugin(
* id = "node_language",
* module = "
local
e"
* module = "
nod
e"
* )
*/
class
Node
Language
extends
Node
{
class
Language
extends
Node
{
function
option_definition
()
{
$options
=
parent
::
option_definition
();
...
...
@@ -40,9 +40,11 @@ function options_form(&$form, &$form_state) {
}
function
render
(
$values
)
{
$languages
=
views_language_list
(
empty
(
$this
->
options
[
'native_language'
])
?
'name'
:
'native'
);
// @todo: Drupal Core dropped native language until config translation is
// ready, see http://drupal.org/node/1616594.
$value
=
$this
->
get_value
(
$values
);
$value
=
isset
(
$languages
[
$value
])
?
$languages
[
$value
]
:
''
;
$language
=
language_load
(
$value
);
$value
=
$language
?
$language
->
name
:
''
;
return
$this
->
render_link
(
$value
,
$values
);
}
...
...
lib/Views/locale/Plugin/views/filter/Language.php
View file @
88b40cc6
...
...
@@ -2,13 +2,13 @@
/**
* @file
* Definition of Views\l
ocal
e\Plugin\views\filter\Language.
* Definition of Views\l
anguag
e\Plugin\views\filter\Language.
*/
namespace
Views\l
ocal
e\Plugin\views\filter
;
namespace
Views\l
anguag
e\Plugin\views\filter
;
use
Drupal\Core\Annotation\Plugin
;
use
Drupal\views\Plugin\views\filter\InOperator
;
use
Drupal\Core\Annotation\Plugin
;
/**
* Filter by language.
...
...
@@ -16,8 +16,8 @@
* @ingroup views_filter_handlers
*
* @Plugin(
* id = "
locale_
language",
* module = "l
ocal
e"
* id = "language",
* module = "l
anguag
e"
* )
*/
class
Language
extends
InOperator
{
...
...
lib/Views/locale/Plugin/views/filter/NodeLanguage.php
deleted
100644 → 0
View file @
472311d5
<?php
/**
* @file
* Definition of Views\locale\Plugin\views\filter\NodeLanguage.
*/
namespace
Views\locale\Plugin\views\filter
;
use
Drupal\Core\Annotation\Plugin
;
use
Drupal\views\Plugin\views\filter\InOperator
;
/**
* Filter by language.
*
* @ingroup views_filter_handlers
*
* @Plugin(
* id = "node_language",
* module = "locale"
* )
*/
class
NodeLanguage
extends
InOperator
{
function
get_value_options
()
{
if
(
!
isset
(
$this
->
value_options
))
{
$this
->
value_title
=
t
(
'Language'
);
$languages
=
array
(
'***CURRENT_LANGUAGE***'
=>
t
(
"Current user's language"
),
'***DEFAULT_LANGUAGE***'
=>
t
(
"Default site language"
),
LANGUAGE_NOT_SPECIFIED
=>
t
(
'No language'
)
);
$languages
=
array_merge
(
$languages
,
views_language_list
());
$this
->
value_options
=
$languages
;
}
}
}
lib/Views/node/Plugin/views/argument/Language.php
deleted
100644 → 0
View file @
472311d5
<?php
/**
* @file
* Definition of Views\node\Plugin\views\argument\Language.
*/
namespace
Views\node\Plugin\views\argument
;
use
Drupal\views\Plugin\views\argument\ArgumentPluginBase
;
use
Drupal\Core\Annotation\Plugin
;
/**
* Argument handler to accept a language.
*
* @Plugin(
* id = "node_language",
* module = "node"
* )
*/
class
Language
extends
ArgumentPluginBase
{
function
construct
()
{
parent
::
construct
(
'language'
);
}
/**
* Override the behavior of summary_name(). Get the user friendly version
* of the language.
*/
function
summary_name
(
$data
)
{
return
$this
->
node_language
(
$data
->
{
$this
->
name_alias
});
}
/**
* Override the behavior of title(). Get the user friendly version of the
* node type.
*/
function
title
()
{
return
$this
->
node_language
(
$this
->
argument
);
}
function
node_language
(
$langcode
)
{
$languages
=
views_language_list
();
return
isset
(
$languages
[
$langcode
])
?
$languages
[
$langcode
]
:
t
(
'Unknown language'
);
}
}
lib/Views/node/Plugin/views/field/Node.php
View file @
88b40cc6
...
...
@@ -30,7 +30,7 @@ function init(&$view, &$options) {
if
(
!
empty
(
$this
->
options
[
'link_to_node'
]))
{
$this
->
additional_fields
[
'nid'
]
=
array
(
'table'
=>
'node'
,
'field'
=>
'nid'
);
if
(
module_exists
(
'translation'
))
{
$this
->
additional_fields
[
'lang
uag
e'
]
=
array
(
'table'
=>
'node'
,
'field'
=>
'lang
uag
e'
);
$this
->
additional_fields
[
'lang
cod
e'
]
=
array
(
'table'
=>
'node'
,
'field'
=>
'lang
cod
e'
);
}
}
}
...
...
@@ -65,11 +65,11 @@ function render_link($data, $values) {
if
(
$data
!==
NULL
&&
$data
!==
''
)
{
$this
->
options
[
'alter'
][
'make_link'
]
=
TRUE
;
$this
->
options
[
'alter'
][
'path'
]
=
"node/"
.
$this
->
get_value
(
$values
,
'nid'
);
if
(
isset
(
$this
->
aliases
[
'lang
uag
e'
]))
{
if
(
isset
(
$this
->
aliases
[
'lang
cod
e'
]))
{
$languages
=
language_list
();
$lang
uag
e
=
$this
->
get_value
(
$values
,
'lang
uag
e'
);
if
(
isset
(
$languages
[
$lang
uag
e
]))
{
$this
->
options
[
'alter'
][
'language'
]
=
$languages
[
$lang
uag
e
];
$lang
cod
e
=
$this
->
get_value
(
$values
,
'lang
cod
e'
);
if
(
isset
(
$languages
[
$lang
cod
e
]))
{
$this
->
options
[
'alter'
][
'language'
]
=
$languages
[
$lang
cod
e
];
}
else
{
unset
(
$this
->
options
[
'alter'
][
'language'
]);
...
...
lib/Views/node/Plugin/views/field/Revision.php
View file @
88b40cc6
...
...
@@ -28,7 +28,7 @@ function init(&$view, &$options) {
$this
->
additional_fields
[
'vid'
]
=
'vid'
;
$this
->
additional_fields
[
'nid'
]
=
'nid'
;
if
(
module_exists
(
'translation'
))
{
$this
->
additional_fields
[
'lang
uag
e'
]
=
array
(
'table'
=>
'node'
,
'field'
=>
'lang
uag
e'
);
$this
->
additional_fields
[
'lang
cod
e'
]
=
array
(
'table'
=>
'node'
,
'field'
=>
'lang
cod
e'
);
}
}
}
...
...
@@ -63,10 +63,10 @@ function render_link($data, $values) {
$vid
=
$this
->
get_value
(
$values
,
'vid'
);
$this
->
options
[
'alter'
][
'path'
]
=
"node/"
.
$nid
.
'/revisions/'
.
$vid
.
'/view'
;
if
(
module_exists
(
'translation'
))
{
$lang
uag
e
=
$this
->
get_value
(
$values
,
'lang
uag
e'
);
$lang
cod
e
=
$this
->
get_value
(
$values
,
'lang
cod
e'
);
$languages
=
language_list
();
if
(
isset
(
$languages
[
$lang
uag
e
]))
{
$this
->
options
[
'alter'
][
'lang
uag
e'
]
=
$languages
[
$lang
uag
e
];
if
(
isset
(
$languages
[
$lang
cod
e
]))
{
$this
->
options
[
'alter'
][
'lang
cod
e'
]
=
$languages
[
$lang
cod
e
];
}
}
}
...
...
lib/Views/translation/Plugin/views/field/NodeLinkTranslate.php
View file @
88b40cc6
...
...
@@ -26,7 +26,7 @@ function render_link($data, $values) {
// ensure user has access to edit this node.
$node
=
$this
->
get_value
(
$values
);
$node
->
status
=
1
;
// unpublished nodes ignore access control
if
(
empty
(
$node
->
lang
uag
e
)
||
!
translation_supported_type
(
$node
->
type
)
||
!
node_access
(
'view'
,
$node
)
||
!
user_access
(
'translate content'
))
{
if
(
empty
(
$node
->
lang
cod
e
)
||
!
translation_supported_type
(
$node
->
type
)
||
!
node_access
(
'view'
,
$node
)
||
!
user_access
(
'translate content'
))
{
return
;
}
...
...
lib/Views/translation/Plugin/views/field/NodeTranslationLink.php
View file @
88b40cc6
...
...
@@ -27,7 +27,7 @@ function construct() {
$this
->
additional_fields
[
'nid'
]
=
'nid'
;
$this
->
additional_fields
[
'tnid'
]
=
'tnid'
;
$this
->
additional_fields
[
'title'
]
=
'title'
;
$this
->
additional_fields
[
'lang
uag
e'
]
=
'lang
uag
e'
;
$this
->
additional_fields
[
'lang
cod
e'
]
=
'lang
cod
e'
;
}
function
query
()
{
...
...
@@ -45,7 +45,7 @@ function render_link($data, $values) {
$tnid
=
$this
->
get_value
(
$values
,
'tnid'
);
// Only load translations if the node isn't in the current language.
if
(
$this
->
get_value
(
$values
,
'lang
uag
e'
)
!=
$language_interface
->
langcode
)
{
if
(
$this
->
get_value
(
$values
,
'lang
cod
e'
)
!=
$language_interface
->
langcode
)
{
$translations
=
translation_node_get_translations
(
$tnid
);
if
(
isset
(
$translations
[
$language_interface
->
langcode
]))
{
$values
->
{
$this
->
aliases
[
'nid'
]}
=
$translations
[
$language_interface
->
langcode
]
->
nid
;
...
...
lib/Views/translation/Plugin/views/relationship/Translation.php
View file @
88b40cc6
...
...
@@ -41,7 +41,7 @@ function options_form(&$form, &$form_state) {
'current'
=>
t
(
'Current language'
),
'default'
=>
t
(
'Default language'
),
);
$options
=
array_merge
(
$options
,
locale
_language_list
());
$options
=
array_merge
(
$options
,
views
_language_list
());
$form
[
'language'
]
=
array
(
'#type'
=>
'select'
,
'#options'
=>
$options
,
...
...
@@ -75,20 +75,20 @@ function query() {
switch
(
$this
->
options
[
'language'
])
{
case
'current'
:
$def
[
'extra'
][]
=
array
(
'field'
=>
'lang
uag
e'
,
'field'
=>
'lang
cod
e'
,
'value'
=>
'***CURRENT_LANGUAGE***'
,
);
break
;
case
'default'
:
$def
[
'extra'
][]
=
array
(
'field'
=>
'lang
uag
e'
,
'field'
=>
'lang
cod
e'
,
'value'
=>
'***DEFAULT_LANGUAGE***'
,
);
break
;
// Other values will be the language codes.
default
:
$def
[
'extra'
][]
=
array
(
'field'
=>
'lang
uag
e'
,
'field'
=>
'lang
cod
e'
,
'value'
=>
$this
->
options
[
'language'
],
);
break
;
...
...
modules/comment.views.inc
View file @
88b40cc6
...
...
@@ -165,9 +165,10 @@ function comment_views_data() {
);
// Language field
if
(
module_exists
(
'locale'
))
{
$data
[
'comment'
][
'language'
]
=
array
(
// Langcode field
if
(
module_exists
(
'language'
))
{
$data
[
'comment'
][
'language'
][
'moved to'
]
=
array
(
'comment'
,
'langcode'
);
$data
[
'comment'
][
'langcode'
]
=
array
(
'title'
=>
t
(
'Language'
),
'help'
=>
t
(
'The language the comment is in.'
),
'field'
=>
array
(
...
...
modules/field.views.inc
View file @
88b40cc6
...
...
@@ -165,7 +165,7 @@ function field_views_field_default_views_data($field) {
$tables
[
FIELD_LOAD_REVISION
]
=
$revision_table
;
}
$add_fields
=
array
(
'delta'
,
'lang
uag
e'
,
'bundle'
);
$add_fields
=
array
(
'delta'
,
'lang
cod
e'
,
'bundle'
);
foreach
(
$field
[
'columns'
]
as
$column_name
=>
$attributes
)
{
$add_fields
[]
=
_field_sql_storage_columnname
(
$field
[
'field_name'
],
$column_name
);
}
...
...
modules/language.views.inc
View file @
88b40cc6
...
...
@@ -19,10 +19,6 @@ function language_views_data() {
'help'
=>
t
(
'A language used in drupal.'
),
);
// name
// direction
// weight
$data
[
'language'
][
'langcode'
]
=
array
(
'title'
=>
t
(
'Language code'
),
'help'
=>
t
(
"Language code, e.g. 'de' or 'en-US'."
),
...
...
modules/locale.views.inc
View file @
88b40cc6
...
...
@@ -195,27 +195,3 @@ function locale_views_data() {
return
$data
;
}
/**
* Implements hook_views_data_alter().
*/
function
locale_views_data_alter
(
&
$data
)
{
// Language field
$data
[
'node'
][
'language'
]
=
array
(
'title'
=>
t
(
'Language'
),
'help'
=>
t
(
'The language the content is in.'
),
'field'
=>
array
(
'id'
=>
'node_language'
,
'click sortable'
=>
TRUE
,
),
'filter'
=>
array
(
'id'
=>
'node_language'
,
),
'argument'
=>
array
(
'id'
=>
'node_language'
,
),