EPrints Technical Mailing List Archive

Message: #04381


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

[EP-tech] Re: [spam?] Re: How to set a field to be multilang


I was planning an automatic fields training video for this afternoon, but can do virtual fields if you'd like.

--
Adam Field
Business Relationship Manager and Community Lead
EPrints Services

On 25 Jun 2015, at 10:51, George Mamalakis <mamalos@eng.auth.gr> wrote:

OK...That was much, much more than I hoped for!!! :)

I like most of your last ideas, especially the last one. The others, though, were very helpful in giving insight as to how EPrints works with respect to plugins and the get_value() function. 

So for your last suggestion: What do you think this virtual field should be, and how does somebody define a callback on a field's return value? OK, If this, on the other hand, is not something easy to implement, I can definitely go with your fore-last suggestion, using this "eprint_fields_automatic.pl" (which I had no idea of...it sounds very promising as well (as the syntax is somehow self-explanatory or documented)).

Thanks a lot Tim!!!

On 25/06/2015 11:42 πμ, Timothy Miles-Board wrote:
The "problem" is that when you ask $eprint->get_value() for the value of a multilang field it gives you a perl data structure - in this case arrayref (array of {langcode=>text} hashrefs) - ie. the same behaviour as you would expect for a compound field or any field with a multiple value.

$eprint->get_value() is used everywhere - including in export plugins. So any field where the plugin implicitly expects a string - like title, abstract etc - it will output something like ARRAYx01123123

So your options are:

* Fix up all the plugins to be cleverer about how they get the "best" value of multilang field (ie. use get_value() then look at the user's lang / default lang to pull out the best string from the multilang structure) - but this would mean repeating the same routine in every plugin..

* Change the way that get_value() works so that it somehow decides which behaviour to use (arrayref vs best lang string) based on calling context etc. - get_value is used everywhere in EPrints so this would probably break everything..

* Add a layer of abstraction between the low level get_value() and the plugins that defines an API for returning language dependent strings - then change all the plugins to use that (so instead of get_value(), plugins could call get_lang_string() or something - something like this would be the best approach...

In the meantime, what you could do is instead of changing the default title, abstract etc fields, just define new multilang versions.

So eg. ml_title, ml_abstract ...

Then use these in your workflow instead of the default title, abstract .. etc.

Finally in eprint_fields_automatic.pl, write some code to take the ml_* fields and populate the equivalent scalar fields. So eg. get the value of ml_title, pull out the text in the default language (or if the default language version is not defined, some other language in order of preference - the EPrints::Language module already does stuff like this with phrases) and write that value into the title field.

Then anything that expects $eprint->get_value( "title" ) to return a string will be happy (albeit they will always give the default/preferred language).

Or...

Change the default title, abstract etc. fields to a virtual field so that you can dynamically work out the (string) value by looking at ml_title, ml_abstract etc - as long as the value returned is always a string this shouldn't break anything.

Food for thought I hope,

Tim

Timothy Miles-Board
Web & Repositories Development Specialist, University of London Computer Centre
020 7863 1342  |  07742 970 351  | timothy.miles-board@london.ac.uk | @drtjmb
The University of London is an exempt charity in England and Wales



From: eprints-tech-bounces@ecs.soton.ac.uk <eprints-tech-bounces@ecs.soton.ac.uk> on behalf of George Mamalakis <mamalos@eng.auth.gr>
Sent: 25 June 2015 8:38 AM
To: eprints-tech@ecs.soton.ac.uk
Subject: [EP-tech] Re: [spam?] Re: How to set a field to be multilang
 
Thanks Alen, I'll look into it deeper.

It's sad, though, that default Import/Export plugins break. Could you give a few hints on how to customise these plugins? (general guidelines). Could the changes be applied on the parent Import and Export plugin, or most child plugins tend to override functions dealing with title, abstract, etc?

And that being the case, isn't it equivalent to adding extra fields for an additional language? Either way same things are broken, right? :)

Lastly, where are these metadata fields stored in the database? Reading the article in the link you provided diagonally, it seems that I need to update the database in order to create them, right?

Thanks again!

On 24/06/2015 11:18 μμ, Alen Vodopijevec wrote:
Hi!

You have Metadata Field Types documented here:
http://wiki.eprints.org/w/Category:EPrints_Metadata_Fields

But, be aware that changing title, keywords and abstract fields to 
'compound' breaks default EPrints plugins - export/import .. these 
plugins expect title/keywords/abstract to be simple and not compound 
(hash) value.

I'm using it that way but there is some extra effort to customize and 
maintain import/export plugins.

If anybody have a suggestion or a better solution please let me know.

Maybe this is a good opportunity to discuss that i18n issues in EPrints.

Kind regards,
--
Alen

On 06/24/2015 10:15 AM, George Mamalakis wrote:
> Ah,
>
> And by the way, is there any documentation on this "fields" attribute 
> somewhere? Cos I think it wasn't mentioned anywhere.
>
> Thanks again!
>
> On 24/06/2015 10:29 πμ, Timothy Miles-Board wrote:
>>
>> ---------- Forwarded message ----------
>> From: Timothy Miles-Board <timothy.miles-board@ulcc.ac.uk>
>> Date: 18 Jun 2015 11:30 pm
>> Subject: Re: [EP-tech] How to set a field to be multilang
>> To: eprints-tech@ecs.soton.ac.uk
>> Cc:
>>
>> {
>> name => 'title',
>> type => 'multilang',
>> multiple => 1,
>> fields => [ { sub_name => "text", type => "longtext",
>> input_rows => 3, make_single_value_orderkey =>
>> 'EPrints::Extras::english_title_orderkey' } ],
>> input_add_boxes => 1,
>> },
>>
>>
>> Tim
>>
>> On 23 Jun 2015 9:09 am, George Mamalakis <mamalos@eng.auth.gr> wrote:
>>
>> Guys (and girls),
>>
>> Any news on multilingual fields? Anybody using them?
>>
>> Thanks!
>>
>> George
>>
>> On 18/06/2015 06:31 μμ, George Mamalakis wrote:
>> > Hello again,
>> >
>> > I am trying to make my EPrints installation support
>> multilanguage fields
>> > (eg. title, abstract, etc.). The thing I did that worked (which
>> doesn't
>> > feel right to me, though) was adding a new Metadata field (eg.
>> title_en)
>> > and add it to the database and workflow. On the documentation,
>> on the
>> > other hand, I saw that there is a Multilang field type
>> > (./perl_lib/EPrints/MetaField/Multilang.pm) which should be
>> used for
>> > this purpose. The strange thing is that its perldoc DESCRIPTION
>> section
>> > starts with "not done", probably meaning that it's not implemented?
>> > Disregarding the last comment, when I changed
>> > ./archives/myarchive/cfg/cfg.d/eprint_fields.pl title field to
>> read:
>> >
>> > {
>> > name => 'title',
>> > type => 'multilang',
>> > input_rows => 3,
>> > make_single_value_orderkey =>
>> > 'EPrints::Extras::english_title_orderkey',
>> > },
>> >
>> > and I reloaded epadmin, I got the following error:
>> >
>> > "Error in field property for eprint.title: fields on a multilang
>> > metafield can't be undefined"
>> >
>> > So, which is the proper way for adding multilanguage support in
>> fields
>> > and display them in workflows?
>> >
>> > Thanks for all help in advance!
>> >
>>
>>
>> -- 
>> George Mamalakis
>>
>> IT and Security Officer,
>> Electrical and Computer Engineer (Aristotle Univ. of Thessaloniki),
>> PhD (Aristotle Univ. of Thessaloniki),
>> MSc (Imperial College of London)
>>
>> School of Electrical and Computer Engineering
>> Aristotle University of Thessaloniki
>>
>> phone number : +30 (2310) 994379
>>
>>
>>
>> *** Options:
>> http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
>> *** Archive: http://www.eprints.org/tech.php/
>> *** EPrints community wiki: http://wiki.eprints.org/
>> *** EPrints developers Forum: http://forum.eprints.org/
>>
>>
>>
>> *** Options:http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
>> *** Archive:http://www.eprints.org/tech.php/
>> *** EPrints community wiki:http://wiki.eprints.org/
>> *** EPrints developers Forum:http://forum.eprints.org/
>
>
> -- 
> George Mamalakis
>
> IT and Security Officer,
> Electrical and Computer Engineer (Aristotle Univ. of Thessaloniki),
> PhD (Aristotle Univ. of Thessaloniki),
> MSc (Imperial College of London)
>
> School of Electrical and Computer Engineering
> Aristotle University of Thessaloniki
>
> phone number : +30 (2310) 994379
>
>
>
>
> ----------------------------- Upozorenje -----------------------------
>
> Automatskom detekcijom utvrdjeno je da tekst ove poruke
> podsjeca na tzv. phishing poruku.
>
> AKO SE U PORUCI TRAZI DA POSALJETE VASU IRB LOZINKU ILI
> DA UNESETE IRB PODATKE NA NAVEDENOM LINKU, RADI SE O
> NAPADU S CILJEM KRADJE I ZLOUPOTREBE PODATAKA.
>
> Centar za informatiku i racunarstvo,
> Institut Rudjer Boskovic
>
> ----------------------------- Upozorenje -----------------------------
>
>
> *** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
> *** Archive: http://www.eprints.org/tech.php/
> *** EPrints community wiki: http://wiki.eprints.org/
> *** EPrints developers Forum: http://forum.eprints.org/


-- 
Sent from my Android device with K-9 Mail. Please excuse my brevity. 

*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: http://www.eprints.org/tech.php/
*** EPrints community wiki: http://wiki.eprints.org/
*** EPrints developers Forum: http://forum.eprints.org/


-- 
George Mamalakis

IT and Security Officer, 
Electrical and Computer Engineer (Aristotle Univ. of Thessaloniki),
PhD (Aristotle Univ. of Thessaloniki),
MSc (Imperial College of London)

School of Electrical and Computer Engineering
Aristotle University of Thessaloniki

phone number : +30 (2310) 994379




*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: http://www.eprints.org/tech.php/
*** EPrints community wiki: http://wiki.eprints.org/
*** EPrints developers Forum: http://forum.eprints.org/


-- 
George Mamalakis

IT and Security Officer, 
Electrical and Computer Engineer (Aristotle Univ. of Thessaloniki),
PhD (Aristotle Univ. of Thessaloniki),
MSc (Imperial College of London)

School of Electrical and Computer Engineering
Aristotle University of Thessaloniki

phone number : +30 (2310) 994379


*** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
*** Archive: http://www.eprints.org/tech.php/
*** EPrints community wiki: http://wiki.eprints.org/
*** EPrints developers Forum: http://forum.eprints.org/