Nestor Oviedo created DS-1232:
---------------------------------
Summary: Metadata internationalization
Key: DS-1232
URL: https://jira.duraspace.org/browse/DS-1232
Project: DSpace
Issue Type: Improvement
Components: DSpace API, Language Packs, XMLUI
Affects Versions: 1.8.2, 3.0
Reporter: Nestor Oviedo
Attachments: i18nable-metadata-modified-classes.zip,
i18nable-metadata.patch, i18nable-metadata-screenshot.png
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:
<field>
<dc-schema>dc</dc-schema>
<dc-element>title</dc-element>
<dc-qualifier></dc-qualifier>
<repeatable>false</repeatable>
<label>Title</label>
<input-type>onebox</input-type>
<hint>Enter the main title of the item.</hint>
<required>You must enter a main title for this item.</required>
<i18n>true</i18n>
</field>
Excerpt of the resulting DRI page with two internationalizable field: dc.title
and dc.title.alternative
<item>
<field id="aspect.submission.StepTransformer.field.dc_title"
rend="submit-text" n="dc_title" required="yes" type="text">
<params i18nable="yes"/>
<label>Title</label>
<help>Enter the main title of the item.</help>
<value type="raw">Main title, in english</value>
<value type="lang">en</value>
</field>
</item>
<item>
<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>
<instance>
<value type="raw">Título alternativo, en español</value>
<value type="lang">es</value>
</instance>
</field>
</item>
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://jira.duraspace.org/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Dspace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dspace-devel