Versions Compared

Key

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

...

VIVO language files are available for English, Spanish, Brazilian Portuguese, and German. If you need support for another language, please inquire of the VIVO mailing lists, to see if another group has the files you need.

Adding

...

an existing language to your VIVO site

...

In this step by step guide we will use the German language files as an example. After you installed VIVO (as described here), clone your desired VIVO-language and Vitro-language folders/repositories (in this example we will use the files from https://github.com/vivo-DE). Be sure to use the theme 'wilma' or 'tenderfoot' for this to work without issues. 

...

  • Go into the VIVO project folder and uncomment the section for multiple language support (search for '<!-- Dependencies for multilingual support -->' and '<!-- Overlays for multilingual support -->' inside of the files)  in each of the two pom.xml files listed below:

    • Vitro/installer/webapp/pom.xml (Uncomment dependencies and overlays)
    • VIVO/installer/home/pom.xml (Uncomment dependencies)
    • VIVO/installer/webapp/pom.xml(Uncomment dependencies and overlays)
    Change the <version> in the two pom.xml files to the same version as in the 'VIVO-language/pom.xml' and 'Vitro-language/pom.xml' file respectively.  You may need to change the version in multiple places in the files.
  • Build VIVO from the VIVO project folder using mvn install -s installer/my-settings.xml
  • Edit the vivo_home_dir/config/runtime.properties file in your VIVO home directory:
    • uncomment/add RDFService.languageFilter = true
    • uncomment/add languages.selectableLocales = en_US, de_DE
  • Restart the tomcat
  • You should now be able to select your installed language (in this case German) in the header of your VIVO site

...

Creating new language files for your language

First, contact the VIVO development team. We would love to talk to you. We will be happy to help with any questions you may have and introduce you to others who may be working on the same language as you are.

...

The language files

You can get the Spanish or the English US English (en_US) files from the VIVO-language and Vitro-language repositories, to use as a among the vivo-project repositories(https://github.com/vivo-project), 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.

These words and phrases have been removed from the page templates, so no programming knowledge is required to translate them.

process simply consist of duplicating each file having the extension en_US inside  VIVO/Vitro -language  repositories and renaming the copy using the locale of the new language. The new file will reside along side (in the same directory) the original one.  

For example, when initializing the languages files for Estonian( et_EE),  copying the file vivo_all_en_US.properties will help creating vivo_allThere is one file for phrases used in Vitro, the core around which VIVO is built, and one file for phrases that are specific to VIVO. In the example, these two files are both called all_et_EE.properties and reside in Vitro and VIVO directories respectively.

Code Block
titleExample file names
[Vitro]/webapp/languages/et_EE/i18n/all_et_EE.properties
[VIVO]/languages/et_EE/themes/wilma/i18n/all_et_EE.properties

The two sample lines below show Estonian language that will be used when a template needs to show text for "minimum_image_dimensions" and for the "cropping caption".  Note that the first example contains place holders {0} and {1} that will be used by Freemarker during run-time to provide height and width values.

...

titleExample content

...

. Both of them will reside in vivo-languages/webapp/src/main/webapp/i18n

In the process of initializing the files for a new language. You will encounter the following types of file:


Text strings (.properties)

These files contain about 1500 words and phrases that appear in the VIVO/Vitro web pages.

These words and phrases have been removed from the page templates, so no programming knowledge is required to translate them.

They appear at different level in the application :

  • in Vitro-languages/webapp/src/main/webapp/i18n
  • in VIVO-languages/webapp/src/main/webapp/i18n
  • in each theme's i18n directory. For instance : 
    • VIVO-languages/webapp/src/main/webapp/themes/tenderfoot/i18n and
    • VIVO-languages/webapp/src/main/webapp/themes/wilma/i18n

The application will look for an entry starting with the activated theme(like tenderfoot or wilma), then VIVO and lastly Vitro.

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.

...

titleExample file names

...

They are located in:

  • Vitro-languages/webapp/

...

  • src/main/webapp/templates/freemarker

...

  • VIVO-languages/webapp/src/main/webapp/templates/freemarker/

...

  • body
  • VIVO-languages/webapp/src/main/webapp/templates/freemarker/

...

  • visualization/capabilitymap
  • VIVO-languages/webapp/

...

  • src/main/webapp/templates/freemarker/visualization/mapOfScience

Here are some examples of templates files to create for Estonian support

Code Block
titleExample file names
Vitro-languages/webapp/src/main/webapp/userAccounts-acctCreatedExternalOnlyEmail_et_EE.ftl
[Vitro]/webapp/languages/et_EE/templates/freemarker/userAccountssearch-confirmEmailChangedEmailhelp_et_EE.ftl
[Vitro]-languages/webapp/languages/et_EEsrc/main/webapp/templates/freemarker/userAccounts-firstTimeExternalEmailtermsOfUse_et_EE.ftl
[Vitro]-languages/webapp/languages/et_EEsrc/main/webapp/templates/freemarker/userAccounts-passwordCreatedEmailacctCreatedEmail_et_EE.ftl
[Vitro]-languages/webapp/languages/et_EEsrc/main/webapp/templates/freemarker/userAccounts-passwordResetCompleteEmailacctCreatedExternalOnlyEmail_et_EE.ftl
[Vitro]-languages/webapp/src/languagesmain/et_EEwebapp/templates/freemarker/userAccounts-passwordResetPendingEmailconfirmEmailChangedEmail_et_EE.ftl
[VIVO]/languages/et_EEVitro-languages/webapp/src/main/webapp/templates/freemarker/aboutMapOfScienceuserAccounts-firstTimeExternalEmail_et_EE.ftl
[VIVO]/languages/et_EE/Vitro-languages/webapp/src/main/webapp/templates/freemarker/userAccounts-passwordCreatedEmail_et_EE.ftl
Vitro-languages/webapp/src/main/webapp/templates/freemarker/aboutQrCodesuserAccounts-passwordResetCompleteEmail_et_EE.ftl
[VIVO]/languages/Vitro-languages/webapp/src/main/webapp/templates/freemarker/userAccounts-passwordResetPendingEmail_et_EE.ftl
VIVO-languages/webapp/src/main/webapp/templates/freemarker/mapOfScienceTooltipsbody/aboutMapOfScience_et_EE.ftl
VIVO-languages/webapp/src/main/webapp/templates/freemarker/body/aboutQrCodes_et_EE.ftl
VIVO-languages/webapp/src/main/webapp/templates/freemarker/visualization/mapOfScience/mapOfScienceTooltips_et_EE.ftl


Code Block
titleTerms of Use (Estonian)
<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)

    </p>
</section>

RDF data (.n3, .nt)

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. Here is the list of directories where one will have to create required rdf files:

  • VIVO-languages/home/src/main/resources/rdf/applicationMetadata/everytime
  • VIVO-languages/home/src/main/resources/rdf/display/everytime
  • VIVO-languages/home/src/main/resources/rdf/display/firsttime
  • VIVO-languages/home/src/main/resources/rdf/tbox/everytime

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.  In each case, the delivered file in english English has a corresponding file with the same name followed by and underscore and the name of the locale.  See illustrations below:

Code Block
titleFile names (Estonian)
[VIVO]/languages/et_EE/rdf/applicationMetadata/firsttime/classgroups_labels_et_EE.n3
[VIVO]/languages/et_EE/rdf/applicationMetadata/firsttime/propertygroups_labels_et_EE.n3
[VIVO]/languages/et_EE/rdf/display/everytime/PropertyConfig_et_EE.n3
[VIVO]/languages/et_EE/rdf/display/firsttime/aboutPage_et_EE.n3
[VIVO]/languages/et_EE/rdf/display/firsttime/menu_et_EE.n3
[VIVO]/languages/et_EE/rdf/tbox/firsttime/vitroAnnotations_et_EE.n3

...

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(or the language) where the language is spoken.

Here are the locations you need to add the flag of the country where the language is spoken.  Add language:

  • Vitro-languages/webapp/src/main/webapp/themes/vitro/i18n/images
  • VIVO-languages/webapp/src/main/webapp/themes/tenderfoot/i18n/images
  • VIVO-languages/webapp/src/main/webapp/themes/wilma/i18n/images

You need to add the image to the theme themes you will be using. Here the path to the image that will load with wilma:

Code Block
titleSelect Local Image File name (Estonian)
[VIVO]/languages/et_EEVIVO-languages/webapp/src/main/webapp/themes/wilma/i18n/images/select_locale_et_EE.gif

...

Panel
titleImage for locale selection (Estonian)

Image Removed

Adding language support to your local modifications

...

Image Added

How VIVO supports languages

Language in the data model

...

Note

VIVO has 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.

. Language-specific values for other properties must be ingested into VIVO.

Language support in VIVO pages

VIVO uses The mechanism we use is based on the Java language's built-in framework for Internationalization. You can find more information in the Java tutorials for resource bundles and properties files.

...

 In the I18n framework, displayed text strings are not embedded in the Java classes or in the Freemarker template. Instead, each piece of text is assigned a "key" and the code will ask the framework to provide the text string that is associated with that codekey. The framework has access to sets of properties files, one set for each supported language, and it will use the appropriate set to get the correct strings.

...

Code Block
titleUsing I18n strings from Java code
protected String getTitle(String siteName, VitroRequest vreq) {
    return I18n.text(vreq, "upload_image_page_title");
}

private String getPrompt(HttpServletRequest req, int width, int height) {
    return I18n.text(req, "minimum_image_dimensions", width, height);
}

...

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.

...

  • webapp/themes/frodo/i18n/all.properties
  • webapp/i18n/all.properties

If you specify a complex more than one locale for VIVO, this search pattern becomes longer. For example, if your user has chosen Canadian French as his language/country combination, then these files (if they exist) will be searched for text strings:

...

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.

...

Up through VIVO release 1.710, 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 To access string properties in JavaScript called from a template, assign the properties to variables in the Freemarker template, and then access those values from the JavaScript.

...