From bb54167141b16e091832119487fd8a86f719aacd Mon Sep 17 00:00:00 2001 From: Nigel Banks Date: Wed, 23 Oct 2013 19:15:34 +0200 Subject: [PATCH] Added i18n support for DC metadata labels. --- README.md | 10 +++++++++- includes/dublin_core.inc | 5 ++++- islandora.module | 42 ++++++++++++++++++++++++++++++++++++++++ 3 files changed, 55 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index c1974352..90d935cf 100644 --- a/README.md +++ b/README.md @@ -26,9 +26,17 @@ REQUIREMENTS The Tuque library must be installed to use Islandora. It can be found here: http://github.com/Islandora/tuque It is expected to be in one of two paths: - - sites/all/libraries/tuque (libraries directory may need to be created) + - sites/all/libraries/tuque (libraries directory may need to be created) - islandora_folder/libraries/tuque +OPTIONAL REQUIREMENTS +--------------------- + +If you want to support languages other than English download and enable +[String Translation](https://drupal.org/project/i18n), And follow our +[guide](wiki/Multilingual-Support) for setting up additional languges. + + INSTALLATION ------------ diff --git a/includes/dublin_core.inc b/includes/dublin_core.inc index ecfcc7b1..ae59ef5c 100644 --- a/includes/dublin_core.inc +++ b/includes/dublin_core.inc @@ -130,7 +130,10 @@ class DublinCore { } $dc_label = explode(':', $field); $element_label = drupal_ucfirst($dc_label[1]); - $dc_array[$field]['label'] = $element_label; + $i18n_object_id = drupal_strtolower($element_label); + $dc_array[$field]['label'] = function_exists('i18n_string') ? + i18n_string("islandora:dc:{$i18n_object_id}:label", $element_label) : + $element_label; $dc_array[$field]['value'] = filter_xss($value); $dc_array[$field]['class'] = drupal_strtolower(preg_replace('/[^A-Za-z0-9]/', '-', $field)); $dc_array[$field]['dcterms'] = preg_replace('/^dc/', 'dcterms', $field); diff --git a/islandora.module b/islandora.module index 9c14c90f..3ee959c2 100644 --- a/islandora.module +++ b/islandora.module @@ -532,6 +532,48 @@ function islandora_permission() { ); } +/** + * Implements hook_i18n_string_info(). + */ +function islandora_i18n_string_info() { + return array( + 'islandora' => array( + 'title' => t('Islandora'), + 'description' => t('Translatable Metadata labels, etc.'), + 'format' => FALSE, + 'list' => TRUE, + ), + ); +} + +/** + * Implements islandora_i18n_string_list(). + */ +function islandora_i18n_string_list($group) { + if ($group == 'islandora') { + return array( + 'islandora' => array( + 'dc' => array( + 'title' => array('label' => 'Title'), + 'creator' => array('label' => 'Creator'), + 'subject' => array('label' => 'Subject'), + 'description' => array('label' => 'Description'), + 'publisher' => array('label' => 'Publisher'), + 'contributor' => array('label' => 'Contributor'), + 'date' => array('label' => 'Date'), + 'type' => array('label' => 'Type'), + 'format' => array('label' => 'Format'), + 'identifier' => array('label' => 'Identifier'), + 'source' => array('label' => 'Source'), + 'language' => array('label' => 'Language'), + 'relation' => array('label' => 'Relation'), + 'coverage' => array('label' => 'Coverage'), + ), + ), + ); + } +} + /** * Renders the print page for the given object. *