EPrints Technical Mailing List Archive

See the EPrints wiki for instructions on how to join this mailing list and related information.

Message: #04391


< 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


OK, that was an illuminating video, and thanks once more!

Here's the indexing, my indexes are large and many because I thought it would be good if they helped as a howto themselves (the appropriate steps needed for it to work), but of course feel free to change them to suit your liking! :) (e.g. saying that "running tests" or "running script" might not be needed...:))

0:00 Introduction
0:57 creating a virtual field  (new configuration file (z_caps_title.pl) in ~/archive/arch_name/cfg/cfg.d)
2:40 adding render_value callback in configuration file
3:08 Explaining render_function of ~/perl_lib/EPrints/MetaField.pm
8:04 adding field in ~/archive/archname/cfg/dfg.d/render.pl in (note: why exactly did we need that step?)
8:30 testing EPrints service
8:40 restarting web server
8:52 refreshing abstracts for our repository
9:10 first trial if it works fails
10:15 adding our new field manually in ~/archive/archname/cfg/citations/eprint/summary_page.xml since it doesn't have a value, yet
11:38 regenerating abstracts
11:49 Second trial works
12:40 creating an API script that shows virtual fields indeed have no value (test_value.pl)
13:28 copying API Core code when writing EPrints scripts
14:12 rendering code for virtual fields
15:33 testing if rendering works
15:47 code that shows that a virtual field's value is not set
16:30 running script that shows no value is set
16:37 code printing a virtual field's value
17:09 running script to show the value is void
17:37 how to make a virtual field generate a value
18:37 how are value() and get_value() defined in ~/perl_lib/EPrints/DataObj.pm
20:35 creating a new virtual field type using SubObject.pm as a base (Virtualwithvalue.pm)
26:36 editing z_caps_title.pl configuration file to contain a get_value property that returns its value
27:46 testing the service
33:08 correcting Virtualwithvalue.pm to return defaults in order to pass tests without warnings
34:23 tests pass without warnings
34:34 test_value.pl script now shows the value as it should and prints its output
35:18 changing z_caps_title.pl render value to use the newly created value
37:48 testing it works
38:44 fixing wide character utf8 warning in console by correcting test_value.pl
40:00 regenerating abstracts for archive
40:05 the new field is shown automatically in the web page now (having an undefined phrase)

Hope you like it!







On 25/06/2015 11:01 μμ, Adam Field wrote:
OK, it's finally up now.  It's 40 minutes long!!!!  I look forward to receiving the index from one of you (perhaps whoever gets to it first should email the other to say they'll do it).

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

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

I'm also available, if you want to. But I'll have do it tomorrow, if it's not a problem (here it's UTC+3 and I have arrangements for this evening :)).


On 25/06/2015 05:58 μμ, Alan.Stiles wrote:
Will do. Might even give it a like if it’s good! ;-)
 
From: Adam Field [mailto:af05v@ecs.soton.ac.uk] 
Sent: 25 June 2015 15:47
To: eprints-tech@ecs.soton.ac.uk
Subject: [EP-tech] Re: [spam?] Re: How to set a field to be multilang
 
I'm processing it now.  It's a monster of a video -- I usually aim for 20 minutes max, but it's definitely more that that.  Can someone volunteer to create an index for me.  What that entails is watching it, and writing down the times of things as they start.  E.g.:
 
0:12 Explanation of Foo
1:15 Configuration of bar
2:30 Debugging error in baz
 
--
Adam Field
Business Relationship Manager and Community Lead
EPrints Services
 
On 25 Jun 2015, at 12:52, Alen Vodopijevec <alen@irb.hr> wrote:
 
+1 for virtual fields

On 25 June 2015 13:06:14 CEST, George Mamalakis <mamalos@eng.auth.gr> wrote:
...OK, I feel a bit stupid now...:) 

So, perfect! Thanks again Adam!

George

On 25/06/2015 01:52 μμ, Timothy Miles-Board wrote:
+1 for virtual fields
 
George: Adam usually makes the videos available via YouTube.
 
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 11:42 AM
To: eprints-tech@ecs.soton.ac.uk
Subject: [EP-tech] Re: [spam?] Re: How to set a field to be multilang
 
I'd be interested in that, but at what time are we talking about (GMT)? And how does somebody apply?

Thanks.

On 25/06/2015 01:20 μμ, Adam Field wrote:
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/



-- 
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/

-- 
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/
 
-- The Open University is incorporated by Royal Charter (RC 000391), an exempt charity in England & Wales and a charity registered in Scotland (SC 038302). The Open University is authorised and regulated by the Financial Conduct Authority. 

*** 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/



*** 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