summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEarl Miles2011-03-22 19:01:50 (GMT)
committer Earl Miles2011-03-22 19:01:50 (GMT)
commit5e66dd12948b5afd7820ee69495722dc48bc5501 (patch)
tree4314b803a3df442df50e576b9cab6f5d2f78d080
parentbba811d53535e2d7888b547f1e93c7f2216e2d1b (diff)
Issue #779436 by Narretz: Add aiblity to display "native language" translation.
-rw-r--r--modules/locale/views_handler_field_locale_language.inc21
-rw-r--r--modules/translation/views_handler_field_node_language.inc19
2 files changed, 37 insertions, 3 deletions
diff --git a/modules/locale/views_handler_field_locale_language.inc b/modules/locale/views_handler_field_locale_language.inc
index c44d48c..93ab613 100644
--- a/modules/locale/views_handler_field_locale_language.inc
+++ b/modules/locale/views_handler_field_locale_language.inc
@@ -4,8 +4,25 @@
* Field handler to translate a language into its readable form.
*/
class views_handler_field_locale_language extends views_handler_field {
+ function option_definition() {
+ $options = parent::option_definition();
+ $options['native_language'] = array('default' => FALSE);
+
+ return $options;
+ }
+
+ function options_form(&$form, &$form_state) {
+ parent::options_form($form, $form_state);
+ $form['native_language'] = array(
+ '#title' => t('Native language'),
+ '#type' => 'checkbox',
+ '#default_value' => $this->options['native_language'],
+ '#description' => t('If enabled, the native name of the language will be displayed'),
+ );
+ }
+
function render($values) {
- $languages = language_list();
- return isset($languages[$values->{$this->field_alias}]) ? $languages[$values->{$this->field_alias}]->name : '';
+ $languages = locale_language_list(empty($this->$options['native_language']) ? 'name' : 'native');
+ return isset($languages[$values->{$this->field_alias}]) ? $languages[$values->{$this->field_alias}] : '';
}
}
diff --git a/modules/translation/views_handler_field_node_language.inc b/modules/translation/views_handler_field_node_language.inc
index fffe033..cae2f79 100644
--- a/modules/translation/views_handler_field_node_language.inc
+++ b/modules/translation/views_handler_field_node_language.inc
@@ -4,8 +4,25 @@
* Field handler to translate a language into its readable form.
*/
class views_handler_field_node_language extends views_handler_field_node {
+ function option_definition() {
+ $options = parent::option_definition();
+ $options['native_language'] = array('default' => FALSE);
+
+ return $options;
+ }
+
+ function options_form(&$form, &$form_state) {
+ parent::options_form($form, $form_state);
+ $form['native_language'] = array(
+ '#title' => t('Native language'),
+ '#type' => 'checkbox',
+ '#default_value' => $this->options['native_language'],
+ '#description' => t('If enabled, the native name of the language will be displayed'),
+ );
+ }
+
function render($values) {
- $languages = locale_language_list();
+ $languages = locale_language_list(empty($this->options['native_language']) ? 'name' : 'native');
$value = isset($languages[$values->{$this->field_alias}]) ? $languages[$values->{$this->field_alias}] : '';
return $this->render_link($value, $values);
}