Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Table of Contents

Panel

Excerpt
To a large extent, VIVO supports Spanish-language installations. Support for other languages is not difficult to implement.

Overview

Frequently, we are asked about a Spanish-language VIVO, or Portuguese, or a VIVO that supports multiple languages. The VIVO development team is working in this direction. 

What do we mean by "Language Support"?

Multiple language support can mean many things. When a VIVO site supports a language other than English, that support includes:

...

If you have a particular use case, or if you would be willing to assist in translating, please contact the VIVO development team.

Contacting the VIVO development team

You can discuss this with the VIVO developers on one of the regular team calls, or by submitting a note to the contact page at vivoweb.org.

Adding a language to your VIVO site

Adding language files to VIVO

VIVO is distributed with English as the only supported language. Releases 1.6 and 1.7 also included a set of "pseudo-language" files, as a demonstration of how language support is implemented.

...

If the repository contains files for the language you want, in the VIVO release that you are using, you can just download those files and install them, as described in the Installing VIVO release 1.8.1.

Updating languages files for a newer release

If the language you want has been implemented for VIVO, but is not available for the release that you want, you can adapt the existing language files for the newer release.

...

You can find some notes on this process at Updating language files for the next release. You can also contact the VIVO development team, to discuss this with the developers.

Translating VIVO into your language

First, contact the VIVO development team: we would love to talk to you. We will tell you if anyone else is working on your language, and we will be happy to help with any questions you may have.

When you are ready to go ahead, you must determine the "locale" of your translation. Then you prepare translations of twenty-one files, as shown below.

The locale

Your locale is an internationally recognized code that specifies the language you choose, and the region where it is spoken. For example, the locale string fr_CA is used for French as spoken in Canada, and es_MX is used for Spanish as spoken in Mexico. Recognized codes for languages and regions can be found by a simple Google search. Here is a list of locales that are recognized by the Java programming language. You may also use this definitive list of languages and regions, maintained by the Internet Assigned Numbers Authority.

...

Note

When the locale code appears in file names, it contains an underscore (en_US). When it appears inside RDF data files, it contains a hyphen (en-US).

The language files

You can get the Spanish or the English files from the VIVO and Vitro language repositories, to use as a template for your own files.

The example that follow assume that you are creating files for the Estonian language, as spoken in Estonia, with the locale et_EE.

Text strings (.properties)

These files contain about 1500 words and phrases that appear in the VIVO web pages. The page templates contain more than just text – they contain programming logic and display specifiers.

...

Code Block
titleExample content
minimum_image_dimensions = Minimaalne pildi mõõdud: {0} x {1} pikslit 
cropping_caption = Profiilifoto näeb alloleval pildil.

Freemarker Templates (.ftl)

Almost all of the text in the Freemarker templates is supplied by the text strings in the properties files. However, some Freemarker templates are essentially all text, and it seemed simpler to create a translation of the entire template. These include the help and about pages, the Terms of Use page, and the emails that are sent to new VIVO users.

...

Code Block
titleExample content
<section id="terms" role="region">
    <h2>kasutustingimused</h2> 
    
    <h3>Hoiatused</h3> 

    <p>
        See ${termsOfUse.siteName} veebisait sisaldab materjali; teksti informatsiooni 
        avaldamine tsitaadid, viited ja pildid ikka teie poolt ${termsOfUse.siteHost} 
        ja erinevate kolmandatele isikutele, nii üksikisikute ja organisatsioonide, 
        äri-ja muidu. Sel määral copyrightable Siin esitatud infot VIVO veebilehel ja 
        kättesaadavaks Resource Description Framework (RDF) andmed alates VIVO at 
        ${termsOfUse.siteHost} on mõeldud avalikuks kasutamiseks ja vaba levitamise 
        tingimuste kohaselt 
        <a href="http://creativecommons.org/licenses/by/3.0/" 
                target="_blank" title="creative commons">
            Creative Commons CC-BY 3.0
        </a> 
        litsentsi, mis võimaldab teil kopeerida, levitada, kuvada ja muuta derivaadid 
        seda teavet teile anda laenu ${termsOfUse.siteHost}.  
    </p>
</section>

RDF data (.n3)

Data in the RDF models includes labels for the properties and classes, labels for property groups and class groups, labels for menu pages and more.

...

Code Block
titleExample content
<http://vivoweb.org/ontology#vitroClassGrouppeople> 
    <http://www.w3.org/2000/01/rdf-schema#label> "inimesed"@et-EE .
<http://vivoweb.org/ontology#vitroClassGrouppublications> 
    <http://www.w3.org/2000/01/rdf-schema#label> "teadus"@et-EE .
<http://vivoweb.org/ontology#vitroClassGrouporganizations> 
    <http://www.w3.org/2000/01/rdf-schema#label> "organisatsioonid"@et-EE .
<http://vivoweb.org/ontology#vitroClassGroupactivities> 
    <http://www.w3.org/2000/01/rdf-schema#label> "tegevused"@et-EE .

The selection image (.png, .jpeg, .gif)

If you allow the user to select a preferred language, you must supply an image for the user to click on. Typically, this image is of the flag of the country where the language is spoken.

...

Panel
titleExample content

How can I contribute my language files to the VIVO community?

If you are planning to create a translation of VIVO, you should coordinate with the VIVO developers. When your files are ready, you can make them available to the development team in any way you choose. Note that the VIVO project will release your files under the Apache 2 License. They will require a Contributor Agreement stating that you agree to those terms.

Adding language support to your local modifications

If you make changes to the VIVO code or templates, you may want to add language support to your changes. This is only necessary if your site supports multiple languages, or if you plan to contribute your code to the VIVO community.

Language in the data model

The usual form of language support in RDF is to include multiple labels for a single individual, each with a language specifier.

...

Note

In release 1.7, there is still only limited language support for editing values in the GUI. It is possible to edit language-specific labels for individuals. Language-specific values for other properties must be ingested into VIVO.

Language support in VIVO pages

This section deals with the framework of the VIVO pages: the page titles, the prompts, the tool tips, the error messages; everything that doesn't come from the data model. These pieces of text are not stored in RDF, so we need a different mechanism for managing them.

...

Here is the appearance of the page in question, in English and in Spanish:

Structure of the properties files

The properties files that hold text strings are based on the Java I18n framework for resource bundles. Here is a tutorial on resource bundles.

...

The text strings are processed by the Java I18n framework for message formats. Here is a tutorial on message formats. Full details can be found in the description of the MessageFormat class.

Local extension: application vs. theme

The Java I18n framework expects all properties files to be in one location. In VIVO, this has been extended to look in two locations for text strings. First, it looks for properties files in the current theme directory. Then, it looks in the main application area. This means that you don't need to include all of the basic text strings in your theme. But you can still add or override strings in your theme.

...

When VIVO finds a text string in one of these files, it uses that value, and will not search the remaining files.

Language in Freemarker page templates

Here is some example code from page-home.ftl

...

Code Block
titleEnglish properties used in the example
intro_searchvivo = Search VIVO
search_form = Search form
search_button = Search
intro_filtersearch = Filter search
all_capitalized = All

Language-specific templates

Most Freemaker templates are constructed like the one above; the text is merged with the markup at runtime. In most cases, this results in lower maintenance efforts, since the markup can be re-structured without affecting the text that is displayed.

...

Search order for termsOfUse.ftl

Current locale is es_MX

termsOfUse_es_MX.ftl
termsOfUse_es.ftl
termsOfUse.ftl

Language in Java code

Java code has access to the same language properties that Freemarker accesses. Here is an example of using a language-specific string in Java code:

...

Note how the name of the VIVO site is passed as a parameter to the text message.

Language in JSPs

Up through VIVO release 1.7, no attempt has been made to add language support to JSPs.

Language in JavaScript files

There is no convenient way to access the i18n framework from JavaScript files. One workaround is to assign values to JavaScript variables in the Freemarker template, and then access those values from the JavaScript.

...

Code Block
titleExcerpt from homePageMaps.js
        if ( area == "global" ) {
            text = " " + i18nStrings.countriesAndRegions;
        }
        else if ( area == "country" ) {
            text = " " + i18nStrings.statesString;
        }

Tools you can use

i18nChecker

This is a set of Ruby scripts that are distributed with VIVO, in the utilities/languageSupport/i18nChecker directory. Use them to scan your language properties files and your freemarker templates. The scripts look for common errors in the files.

Scanning language properties files:

  • Warn if a specialized file has no default version.
  • Warn about duplicate keys, keys with empty values.
  • Warn about keys that do not appear in the default version.
  • If the "complete" flag is set,
    • Warn if the default version is not found.
    • Warn about missing keys, compared to the default version.

Scanning Freemarker templates:

  • Warn about visible text that contains other than blank space or Freemarker expressions.
  • Visible text is:
    • Anything that is not inside a tag and not between <script> tags
    • title="" attributes on any tags
    • alert="" attributes on <img> tags
    • alt=""   attributes on <img> tags
    • value="" attributes on <input> tags with submit attributes

...