MultiLang Fields Bazaar Package

From EPrints Documentation
Revision as of 10:28, 7 July 2016 by (talk | contribs) (Warning for already populated repositories)
Jump to: navigation, search

The MultiLang plugins introduces multiple language support in EPrints fields. The specific plugin replaces the title and abstract fields' types with their multilingual versions that calculate their values based on two newly added multilingual fields (ml_title and ml_abstract respectively). The wiki-page that explains how one can replace basic EPrints fields with multilang-fields -which basically explains how this plugin was created- is Adding multilang fields.

Installation Prerequisites



Install through the EPrints Bazaar.

Warning for already populated repositories

Once this plugin is installed, existing titles and abstracts will not be copied into their multilingual counterparts and access to them via the API will be lost! The users of this plugin are requested to use EPrints API to copy the values from the old fields to the new ones.

How to use the plugin

Once the plugin has been installed, the user needs to edit the workflow to contain the multilingual fields' versions instead of the default ones. This procedure is explained in the next section. A script that copies the title value of each eprint to ml_title field's en and el languages can be found here:[1]. Please, use this script at your own risk and don't forget to change its content to reflect the languages of your repository. The same script can be used for copying the abstract field's values to ml_abstract en and el by replacing title with abstract in this script.

Editing the workflow

In order for the plugin to be usable, the default field versions need to be commented out and the new multilingual ones need to be added. So, ~eprints/archives/reponame/cfg/workflows/eprint/default.xml has to be edited as follows:

    <component><field ref="title" required="yes" input_lookup_url="{$config{rel_cgipath}}/users/lookup/title_duplicates" input_lookup_params="id={eprintid}&amp;dataset=eprint&amp;field=title" /></component>
    <component><field ref="abstract"/></component>

    <component><field ref="ml_title" required="yes" input_lookup_url="{$config{rel_cgipath}}/users/lookup/ml_title_duplicates" input_lookup_params="id={eprintid}&amp;dataset=eprint&amp;field=ml_title"/></component>
    <component><field ref="ml_abstract"/></component>

As can be seen, the default lookup script is replaced by the plugin's lookup script (ml_title_duplicates) which supports the new ml_fields. Once the workflow has changed, the repository needs to be reloaded for the changes to take effect:

./epadmin reload reponame

Editing the phrase files

The plugin updates the EPrints system by providing an English and a Greek phrase file for the new fields it creates. The new fields are named ml_title and ml_abstract. So, if this plugin is used for repositories in other languages than these, the site administrator needs to provide the appropriate phrase files for their languages manually. What they can do is copy the phrases from the English language phrase file located in ~eprints/archives/<reponame>/cfg/lang/en/phrases/local.xml and copy them to a new file located in ~eprints/archives/<reponame>/cfg/lang/<your_lang>/phrases/. The file-name should have an xml extension (like local.xml in our example).

The phrases that need to be added are the following (excerpt from the Greek phrases file):

<!-- multilang title related phrases -->
    <epp:phrase id="eprint_fieldname_ml_title">Τίτλος</epp:phrase>
    <epp:phrase id="eprint_fieldname_ml_title_text">Κείμενο</epp:phrase>
    <epp:phrase id="eprint_fieldname_ml_title_help">Το help τεξτ</epp:phrase>
    <epp:phrase id="eprint_fieldname_ml_title_lang">Γλώσσα</epp:phrase>
    <epp:phrase id="eprint_fieldhelp_ml_title">Ο τίτλος του τεκμηρίου. Ο τίτλος δεν πρέπει να τελειώνει με τελεία, αλλά μπορεί να τελειώνει με ερωτηματικό. Δεν υπάρχει τρόπος να γράψετε με πλάγια γράμματα, παρακαλώ χρησιμοποιήστε απλό κείμενο. Εάν έχετε έναν υπότιτλο, θα πρέπει να προηγείται η άνω και κάτω τελεία του υπότιτλου [:]. Χρησιμοποιήστε κεφαλαία γράμματα μόνο στην πρώτη λέξη και στα κύρια ονόματα.
        <br/>Παράδειγμα: <span class="ep_form_example">Μια σύντομη ιστορία</span>
        <br/>Παράδειγμα: <span class="ep_form_example">Καβάφης: η βιογραφία</span>
        <br/>Παράδειγμα: <span class="ep_form_example">Μαθηματικά για μηχανικούς και επιστήμονες. 5η έκδοση</span>
        <br/>Παράδειγμα: <span class="ep_form_example">Οικοσυστήματα του πλανήτη. Τόμ. 26. Εκβολές του πλανήτη.</span>

<!-- multilang abstract related phrases -->

    <epp:phrase id="eprint_fieldname_ml_abstract">Περίληψη</epp:phrase>
    <epp:phrase id="eprint_fieldname_ml_abstract_text">Κείμενο</epp:phrase>
    <epp:phrase id="eprint_fieldname_ml_abstract_help">Το help τεξτ</epp:phrase>
    <epp:phrase id="eprint_fieldname_ml_abstract_lang">Γλώσσα</epp:phrase>
    <epp:phrase id="eprint_fieldhelp_ml_abstract">Μία περίληψη των περιεχομένων. Εάν το τεκμήριο διαθέτει περίληψη, αυτή πρέπει να τοποθετηθεί εδώ. Υποστηρίζεται μόνον απλό κείμενο.</epp:phrase>

Regenerating static files and abstracts

If our repository already contained records, we need to recreate static content such as static pages and abstracts. Hence, as eprints user we should run:

$ ./bin/generate_abstracts reponame
$ ./bin/generate_static reponame

within eprints user's home directory.

How the plugin works

Basically, what the plugin does is that it replaces EPrints default title and abstract field types with a type that supports storing and retrieving information on multilingual fields. The procedure that we followed in order to achieve this functionality was the following:

  • We introduced a new field's type, virtualwithvalue, that would allow our fields to override EPrints fields' default behaviour.
  • We added multilingual versions of the fields that are replaced (namely ml_title and ml_abstract) to store multilingual content.
  • We introduced our new fields' names, types and functionality to EPrints via a configuration file located in ~eprints/archives/<reponame>/cfg/cfg.d/
  • We added the appropriate phrases in each language's phrase file.
  • We added a custom lookup cgi script that uses the new ml_title field for the autocompletion feature.
  • We changed EPrints basic and advanced search scripts to search our new multilingual fields instead of the original ones.

A screenshot showing how the two fields look when inserting a new document follows: Ruomo multilang.jpg