Uploaded image for project: 'DSpace'
  1. DSpace
  2. DS-1232

Metadata internationalization



    • Attachments:
    • Comments:
    • Documentation Status:
      In Comments


      The database schema for the table "metadatavalue" defines a field called "text_lang" which indicates the language in which the text of certain tuple (single metadata) is written in. This database field is filled on every insert with some default value ("en_US") due to DSpace does not provide any way to select a different one.
      Here there is a patch to add this functionality, based on the modifications we have made to our DSpace installation.

      In a few words, this patch adds a SELECT control to the sumission form, next to the respective INPUT or TEXTAREA, in order to allow the user to select the correct language for the text. In case of repetible fields, it adds a hidden input with the language.

      What was modified?

      • Class "org.dspace.app.util.DCInput" in order to consider a new <i18n> element in the input-forms.xml config file. When the element <i18n>true</i18n> is present in a field definition, this class now sets a flag indicating this field will be internationalizable.
      • Classes "Instance", "Text", "TextArea", "Params" and "Value", all from package "org.dspace.app.xmlui.wing.element", in order to accomplish two things:

      a) be able to set a flag when the form field is internationalizable: implies tagging the Param object associated to the Text or TextArea object that it is been constructed. This Param object will be rendered inside the DRI page (within the form field definition) with a new attribute "i18nable=yes".

      b) be able to save a language selected by the user: the selected language is set in the Text, TextArea or Instance object by adding a new Value object of type Value.TYPE_LANG.

      • Classes DescribeStep (from dspace-api and dspace-xmlui-api) in order to configure the Text and TextArea objects, and to read the submitted values (method readText()).
      • There is a new transformer attached to the Submission aspect, which loads the "webui.supported.locales" config property (or "default.locale" that property is not defined) and exposes it in the final DRI source, splitted in multiple "supporte_language" metadata elements inside <pageMeta>. This only when the user enters to the submit form.
      • File forms.xsl (the one from dspace-xmlui-webapp/../themes/dri2xhtml-alt) in order to render the SELECT (or hidden input for instances) control when the "dri:field" matches the expression "dri:params[@i18nable='yes']". Then it takes all the metadata named "supported_locale" from "pageMeta" and creates the OPTION elements with those values.

      It is IMPORTANT to note that:

      • The language selection works only for Text or TextArea fields (it has no sense in other elements).
      • Not internationalizable fields behave just like they did before this patch (the use the default language).
      • This patch won't work with the Reference theme because this theme redefines the XSL template "match="dri:field" mode="normalField", which is responsible to render the select control. If it is modified, it shoul work well.
      • Values displayed in the select control are internationalizable. This patch uses the following syntax to create the i18n codes: xmlui.dri2xhtml.METS-1.0.locale. {locale_code}, where "{locale_code}

        " is the language code to translate.

      Attached files:
      You can find the complete patch attached. Also you will find a zip file with the modified classes, organized in directories based on the dspace modules they belong to.
      There is also a screenshot that shows the expected result on the submission form.

      Example of field configuration in input-form.xml file:

      <hint>Enter the main title of the item.</hint>
      <required>You must enter a main title for this item.</required>

      Excerpt of the resulting DRI page with two internationalizable field: dc.title and dc.title.alternative

      <field id="aspect.submission.StepTransformer.field.dc_title" rend="submit-text" n="dc_title" required="yes" type="text">
      <params i18nable="yes"/>
      <help>Enter the main title of the item.</help>
      <value type="raw">Main title, in english</value>
      <value type="lang">en</value>
      <field id="aspect.submission.StepTransformer.field.dc_title_alternative" rend="submit-text" n="dc_title_alternative" type="text">
      <params i18nable="yes" operations="add delete"/>
      <label>Other Titles</label>
      <help>If the item has any alternative titles, please enter them below.</help>
      <value type="raw">Título alternativo, en español</value>
      <value type="lang">es</value>


          Issue Links



              Unassigned Unassigned
              nesovi Nestor Oviedo
              3 Vote for this issue
              6 Start watching this issue