Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: correcting the path to where the JSPUI libs are stored

Table of Contents
minLevel2
outlinetrue
stylenone

Introduction

DSpace ships with a number of interface translations. This page provides information on areas where internationalization that can be enabled localized by means of configuration or customization. By default, DSpace will look at the user's browser language. If it has a language file in the user's language, it will render the interface in that language. If not, it will default to English or another default that you have configured.

Common areas of localization

Enabling additional locales

Out of the box, DSpace only has English enabled as a supported locale. Additional locales and the default locale are managed through the following parameters in dspace.cfg:

Code Block
titledspace.cfg configuration parameters
webui.supported.locales
default.locale

You can change default.locale to a different one than English after adding it to webui.supported.locales.

Localization of email messages

XMLUI Internationalization

All email templates used by DSpace can be found in

Code Block
titlePath to the DSpace email templates
 [dspace]/config/emails

The contents of the emails can be edited and translated. 

Metadata localization

DSpace associates each metadata field value with a language code (though it may be left empty, e.g. for numeric values).

XMLUI specific localization

Message catalog

XMLUI The XML user interface supports multiple languages through the use of internationalization catalogues as defined by the Cocoon Internationalization Transformer. Each catalog contains the translation of all user-displayed strings into a particular language or variant. Each catalog is a single xml file whose name is based upon the language it is designated for, thus:

...

The interface will automatically determine which file to select based upon the user's browser and system configuration. For example, if the user's browser is set to Australian English then first the system will check if messages_en_au.xml is available. If this translation is not available it will fall back to messages_en.xml, and finally if that is not available, messages.xml.DSpace XMLUI supplies an English only translation of the interface, which can be found in the XMLUI web application ([dspace]/webapps/xmlui

Where to find the message catalog

The latest English message catalog is part of the main DSpace distribution and can be found at:

Code Block
titleLocation of the XMLUI message catalog in the DSpace source tree
[dspace-source]/dspace-xmlui/src/main/webapp/i18n/messages.xml

...

The different translations for this message catalog are being managed separately from the DSpace core project, in order to release updates for these files more frequently than the DSpace software itself. Visit the dspace-xmlui-lang project on Github.

Where to edit

In some cases you may want to add additional keys to the message catalog or changing the particular wording of DSpace concepts. For example, you may want to change "Communities" into "Departments". These kind of changes may get automatically overwritten again when you upgrade to the newest version of DSpace. It is therefore advised to keep such changes isolated in the following location:

Code Block
titleRecommended location for i18n customizations

If you wish to add other translations to the system, or make customizations to the existing messages.xml file, you can place them in the following directory:

code
[dspace-source]/dspace/modules/xmlui/src/main/webapp/i18n/

After rebuilding DSpace, any messages files placed in this directory will be automatically included in the XMLUI web application (and files . Files of the same name will override any default files). By default, this full directory path may not exist (if not, just create it) or may be emptyor may be empty. If it does not exist, you can simply create it. You can place any number of translation catalogues in this directory. To add additional translations, just add alternative versions another copy of the messages.xml file in translated into the specific language and country variants as needed for your installation.To set a language other than English as the default language for the repository's interface, you can simply rename the translation catalogue for the new default language to "messages.xml".variant you need. 

After building and deploying, DSpace will finally read the files from the following location:

Code Block
titleLocation where your i18n files are being deployed
[dspace]/webapps/xmlui/i18n/messages.xml

Again, note that you will need to rebuild DSpace for these changes to take effect in your installed XMLUI web application!

Warning
titleDo not customize your messages in the webapps directory

While it seems like a fast option to change your messages straight in the deployed dspace directory, these changes are very volatile. If you rebuild and redeploy DSpace, these changes will get lost.

For more information about the [dspace-source]/dspace/modules/ directory, and how it may be used to "overlay" (or customize) the default XMLUI interface, classes and files, please see: Advanced Customisation

Latest language files

The XMLUI language files are updated and released separately from the DSpace core project. Visit the dspace-xmlui-lang project on Github.

Difference with JSPUI

In JSPUI, a wider range of files, including input-forms.xml and default.license can be localized by adding _COUNTRY at the end of the filename. This is currently not supported in XMLUI.

JSPUI specific localization

Message catalog

...

The Java Standard Tag Library v1.0 is used to specify messages in the JSPs like this:OLD:

Code Block
<H1>Search Results</H1>

NEW:

Code Block
<H1><fmt:message key="jsp.search.results.title"/></H1>

This message can now be changed using the config/language-packs/Messages.properties file. ( This must be done at build-time: Messages.properties is placed in the dspace.war Web application file.)

Code Block
jsp.search.results.title = Search Results

Phrases may have parameters to be passed in, to make the job of translating easier, reduce the number of 'keys' and to allow translators to make the translated text flow more appropriately for the target language.

OLD:

Code Block
<P>Results <%= r.getFirst() %> to <%= r.getLast() %> of <%=r.getTotal() %></P>

NEW:

Code Block
<fmt:message key="jsp.search.results.text">
  <fmt:param><%= r.getFirst() %></fmt:param>
  <fmt:param><%= r.getLast() %></fmt:param>
  <fmt:param><%= r.getTotal() %></fmt:param>
</fmt:message>

(Note: JSTL 1.0 does not seem to allow JSP <%= %> expressions to be passed in as values of attribute in <fmt:param value=""/>)

The above would appear in the Messages_xx.properties file asHere is an example of a phrase in which two parameters are passed in:

Code Block
jsp.search.results.text = Results {0}-{1} of {2} 

Introducing number parameters that should be formatted according to the locale used makes no difference in the message key compared to string parameters:

Code Block
jsp.submit.show-uploaded-file.size-in-bytes = {0} bytes

In the JSP using this key can be used in the way belov:

Code Block
<fmt:message key="jsp.submit.show-uploaded-file.size-in-bytes">
  <fmt:param><fmt:formatNumber><%= bitstream.getSize()%></fmt:formatNumber></fmt:param>
</fmt:message>

(Note: JSTL offers a way to include numbers in the message keys as jsp.foo.key = {0,number} bytes. Setting the parameter as <fmt:param value="${variable}" /> workes when variable is a single variable name and doesn't work when trying to use a method's return value instead: bitstream.getSize(). Passing the number as string (or using the <%= %> expression) also does not work.)

Multiple Messages.properties can be created for different languages. See ResourceBundle.getBundle. e.g. you can add German and Canadian French translations:

Code Block
Messages_de.properties
Messages_fr_CA.properties

The end user's browser settings determine which language is used by default. The user can change the language by clicking a link in the UI. These links are visible if more than one language is configured in DSpace. The English language file Messages.properties (or the default server locale) will be used as a default fallback if there's no language bundle for the end user's preferred language. ( Note that the English file is not called Messages_en.properties – this . This is so because it is always available as a defaultfallback, regardless of server configuration.)

Message Key Convention

When translating further pages, please follow the convention for naming message keys to avoid clashes.

For text in JSPs use the complete path + filename of the JSP, then a one-word name for the message. e.g. for the title of jsp/mydspace/main.jsp use:

Code Block
jsp.mydspace.main.title

Some common words (e.g. "Help") can be brought out into keys starting jsp. for ease of translation, e.g.:

Code Block
jsp.admin = Administer

Other common words/phrases are brought out into 'general' parameters if they relate to a set (directory) of JSPs, e.g.

Code Block
jsp.tools.general.delete = Delete

Phrases that relate strongly to a topic (eg. MyDSpace) but used in many JSPs outside the particular directory are more convenient to be cross-referenced. For example one could use the key below in jsp/submit/saved.jsp to provide a link back to the user's MyDSpace:

(Cross-referencing of keys in general is not a good idea as it may make maintenance more difficult. But in some cases it has more advantages as the meaning is obvious.)

Code Block
jsp.mydspace.general.goto-mydspace = Go to My DSpace

For text in servlet code, in custom JSP tags or wherever applicable use the fully qualified classname + a one-word name for the message. e.g.

Code Block
org.dspace.app.webui.jsptag.ItemListTag.title = Title

Latest language files

The JSPUI language files are updated and released separately from the DSpace core project. Visit the dspace-api-lang project on Github.

Internationalization of Metadata

Where to find the message catalog

The latest English message catalog is part of the main DSpace distribution and can be found at:

Code Block
titleLocation of the JSPUI message catalog in the DSpace source tree
[dspace-source]/dspace-api/src/main/resources/Messages.properties

The different translations for this message catalog are being managed separately from the DSpace core project, in order to release updates for these files more frequently than the DSpace software itself. Visit the dspace-api-lang project on Github.

Where to edit

In some cases you may want to add additional keys to the message catalog or changing the particular wording of DSpace concepts. For example, you may want to change "Communities" into "Departments". These kind of changes may get automatically overwritten again when you upgrade to the newest version of DSpace. It is therefore advised to keep such changes isolated in the following location:

Code Block
titleRecommended location for i18n customizations
[dspace-source]/dspace/modules/jspui/src/main/resources/

After rebuilding DSpace, any messages files placed in this directory will be automatically included in the JSPUI web application. Files of the same name will override any default files. By default, this full directory path may not exist or may be empty. If it does not exist, you can simply create it. You can place any number of translation catalogues in this directory. To add additional translations, just add another copy of the Messages.properties file translated into the specific language and country variant you need. 

After building and deploying, DSpace will finally read the files from the dspace-api-4.0.jar file in your [tomcat]\webapps\jspui\WEB-INF\lib directory.

Again, note that you will need to rebuild DSpace for these changes to take effect in your installed JSPUI web application!

For more information about the [dspace-source]/dspace/modules/ directory, and how it may be used to "overlay" (or customize) the default XMLUI interface, classes and files, please see: Advanced Customisation

Localization of input-forms.xml and license.default

The display labels for input-forms.xml and the text in the default submission license (license.default) are currently not managed in the messages catalogs. To localize these files, you can create versions of these files in the same folders, appending _COUNTRY at the end of the filename, before the extension. For example, input-forms_de.xml can be used to translate the submission form labels in German.DSpace stores a language value together with the actual metadata fields.