<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<div class="moz-cite-prefix">Tim,<br>
<br>
Now that I got illuminated (:-P) by the video regarding EPrints'
virtual fields, I am trying to think how I could take advantage of
them in order to use to solve my multilanguage-fields problem, and
I think I'm a bit stuck.<br>
<br>
I'll speak my thoughts out loud and please correct me if I'm
wrong. Let the target field be the "title". <br>
<br>
So, we need the title to be stored in more than one languages in
the database, which should be "easily" accomplished using a
multi-row field. Hence, multilang fields are a perfect candidate
for this. We therefore create a new field, let's say ml_title (as
you proposed) and store our values in it. Now, in order for
EPrints not to break, we change the title field to be a virtual
field and compose its output based on ml_title field. In the end,
we'll have two fields for the title. The title field (of type
virtualfield) that will be calculating its value each time it's
called, and the ml_title field (of type multilang). Is that
correct?<br>
<br>
Now that I've written my thoughts, I think I'm no more stuck and I
see that your idea is brilliant and very easy!! :):). And if the
above paragraph is not your idea, and it's even easier than that,
then it'll be even more brilliant!! :):)<br>
<br>
Cheers again, I'll give it a try on Monday!<br>
<br>
Once again, nice work Adam and thanks Tim and all of you for your
help!<br>
<br>
PS. It would be extremely beneficial if there were a guide as to
how EPrints' internals work. Something that is a little be more
explanatory than the "anatomy of a request
(<a class="moz-txt-link-freetext" href="http://wiki.eprints.org/w/Anatomy_of_a_request">http://wiki.eprints.org/w/Anatomy_of_a_request</a>)" and explain how
the coders of EPrints really think of EPrints in their minds.<br>
<br>
On 25/06/2015 11:42 πμ, Timothy Miles-Board wrote:<br>
</div>
<blockquote
cite="mid:EMEW3|b64ed13f54bc5a8a7f94848fe4a4327dr5O9hK14eprints-tech-bounces|ecs.soton.ac.uk|DB4PR05MB073553825CBD4FD9ECA4944382AE0@DB4PR05MB0735.eurprd05.prod.outlook.com"
type="cite">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
<div id="divtagdefaultwrapper"
style="font-size:12pt;color:#000000;background-color:#FFFFFF;font-family:Calibri,Arial,Helvetica,sans-serif;">
<p>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.</p>
<p><br>
</p>
<p>$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</p>
<p><br>
</p>
<p>So your options are:</p>
<p><br>
</p>
<p>* 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..</p>
<p><br>
</p>
<p>* 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..</p>
<p><br>
</p>
<p>* 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...</p>
<p><br>
</p>
<p>In the meantime, what you could do is instead of changing the
default title, abstract etc fields, just define new multilang
versions.</p>
<p><br>
</p>
<p>So eg. ml_title, ml_abstract ...</p>
<p><br>
</p>
<p>Then use these in your workflow instead of the default title,
abstract .. etc.</p>
<p><br>
</p>
<p>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.</p>
<p><br>
</p>
<p>Then anything that expects $eprint->get_value( "title" )
to return a string will be happy (albeit they will always give
the default/preferred language).</p>
<p><br>
</p>
<p>Or...</p>
<p><br>
</p>
<p>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.</p>
<p><br>
</p>
<p>Food for thought I hope,</p>
<p><br>
</p>
<p>Tim</p>
<p><br>
</p>
<div id="Signature">
<div id="divtagdefaultwrapper" style="font-size:12pt;
color:#000000; background-color:#FFFFFF;
font-family:Calibri,Arial,Helvetica,sans-serif">
<div><strong style="color:rgb(33,33,33); font-family:'Times
New Roman',serif"><span style="font-size:11pt;
font-family:Calibri,sans-serif; color:rgb(31,73,125)">Timothy
Miles-Board</span></strong><br>
</div>
<div>
<p class="x_MsoNormal" style="margin:0cm 0cm 0.0001pt;
font-size:16px; font-family:'Times New Roman',serif;
color:rgb(33,33,33); background-color:rgb(255,255,255)">
<span style="font-size:10pt;
font-family:Calibri,sans-serif;
font-variant:small-caps; color:rgb(31,73,125);
letter-spacing:1pt">Web & Repositories Development
Specialist, University of London Computer Centre</span><strong><span
style="font-size:10pt;
font-family:Calibri,sans-serif;
color:rgb(31,73,125)"></span></strong></p>
<p class="x_MsoNormal" style="margin:0cm 0cm 0.0001pt;
font-size:16px; font-family:'Times New Roman',serif;
color:rgb(33,33,33); background-color:rgb(255,255,255)">
<span style="font-size:11pt;
font-family:Calibri,sans-serif; color:rgb(31,73,125)">020
7863 1342 | 07742 970 351 | </span><span
style="font-size:11pt; font-family:Calibri,sans-serif;
color:rgb(22,139,186)"><a moz-do-not-send="true"
href="mailto:timothy.miles-board@london.ac.uk"
target="_blank"
title="mailto:timothy.miles-board@london.ac.uk
Ctrl+Click or tap to follow the link">timothy.miles-board@london.ac.uk</a> |
@drtjmb</span><span style="font-size:11pt;
font-family:Calibri,sans-serif; color:rgb(31,73,125)"></span></p>
<p class="x_MsoNormal" style="margin:0cm 0cm 0.0001pt;
font-size:16px; font-family:'Times New Roman',serif;
color:rgb(33,33,33); background-color:rgb(255,255,255)">
<span style="font-size:10pt;
font-family:Calibri,sans-serif; color:rgb(31,73,125)">The
University of London is an exempt charity in England
and Wales</span></p>
</div>
</div>
</div>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font style="font-size:11pt"
color="#000000" face="Calibri, sans-serif"><b>From:</b>
<a class="moz-txt-link-abbreviated" href="mailto:eprints-tech-bounces@ecs.soton.ac.uk">eprints-tech-bounces@ecs.soton.ac.uk</a>
<a class="moz-txt-link-rfc2396E" href="mailto:eprints-tech-bounces@ecs.soton.ac.uk"><eprints-tech-bounces@ecs.soton.ac.uk></a> on behalf of
George Mamalakis <a class="moz-txt-link-rfc2396E" href="mailto:mamalos@eng.auth.gr"><mamalos@eng.auth.gr></a><br>
<b>Sent:</b> 25 June 2015 8:38 AM<br>
<b>To:</b> <a class="moz-txt-link-abbreviated" href="mailto:eprints-tech@ecs.soton.ac.uk">eprints-tech@ecs.soton.ac.uk</a><br>
<b>Subject:</b> [EP-tech] Re: [spam?] Re: How to set a
field to be multilang</font>
<div> </div>
</div>
<div>
<div class="moz-cite-prefix">Thanks Alen, I'll look into it
deeper.<br>
<br>
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?<br>
<br>
And that being the case, isn't it equivalent to adding
extra fields for an additional language? Either way same
things are broken, right? :)<br>
<br>
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?<br>
<br>
Thanks again!<br>
<br>
On 24/06/2015 11:18 μμ, Alen Vodopijevec wrote:<br>
</div>
<blockquote type="cite">Hi!<br>
<br>
You have Metadata Field Types documented here:<br>
<a moz-do-not-send="true"
href="http://wiki.eprints.org/w/Category:EPrints_Metadata_Fields">http://wiki.eprints.org/w/Category:EPrints_Metadata_Fields</a><br>
<br>
But, be aware that changing title, keywords and abstract
fields to <br>
'compound' breaks default EPrints plugins - export/import
.. these <br>
plugins expect title/keywords/abstract to be simple and
not compound <br>
(hash) value.<br>
<br>
I'm using it that way but there is some extra effort to
customize and <br>
maintain import/export plugins.<br>
<br>
If anybody have a suggestion or a better solution please
let me know.<br>
<br>
Maybe this is a good opportunity to discuss that i18n
issues in EPrints.<br>
<br>
Kind regards,<br>
--<br>
Alen<br>
<br>
On 06/24/2015 10:15 AM, George Mamalakis wrote:<br>
> Ah,<br>
><br>
> And by the way, is there any documentation on this
"fields" attribute <br>
> somewhere? Cos I think it wasn't mentioned anywhere.<br>
><br>
> Thanks again!<br>
><br>
> On 24/06/2015 10:29 πμ, Timothy Miles-Board wrote:<br>
>><br>
>> ---------- Forwarded message ----------<br>
>> From: Timothy Miles-Board <a
moz-do-not-send="true" class="moz-txt-link-rfc2396E"
href="mailto:timothy.miles-board@ulcc.ac.uk">
<timothy.miles-board@ulcc.ac.uk></a><br>
>> Date: 18 Jun 2015 11:30 pm<br>
>> Subject: Re: [EP-tech] How to set a field to be
multilang<br>
>> To: <a moz-do-not-send="true"
class="moz-txt-link-abbreviated"
href="mailto:eprints-tech@ecs.soton.ac.uk">
eprints-tech@ecs.soton.ac.uk</a><br>
>> Cc:<br>
>><br>
>> {<br>
>> name => 'title',<br>
>> type => 'multilang',<br>
>> multiple => 1,<br>
>> fields => [ { sub_name => "text", type
=> "longtext",<br>
>> input_rows => 3, make_single_value_orderkey
=><br>
>> 'EPrints::Extras::english_title_orderkey' } ],<br>
>> input_add_boxes => 1,<br>
>> },<br>
>><br>
>><br>
>> Tim<br>
>><br>
>> On 23 Jun 2015 9:09 am, George Mamalakis <a
moz-do-not-send="true" class="moz-txt-link-rfc2396E"
href="mailto:mamalos@eng.auth.gr">
<mamalos@eng.auth.gr></a> wrote:<br>
>><br>
>> Guys (and girls),<br>
>><br>
>> Any news on multilingual fields? Anybody using
them?<br>
>><br>
>> Thanks!<br>
>><br>
>> George<br>
>><br>
>> On 18/06/2015 06:31 μμ, George Mamalakis wrote:<br>
>> > Hello again,<br>
>> ><br>
>> > I am trying to make my EPrints installation
support<br>
>> multilanguage fields<br>
>> > (eg. title, abstract, etc.). The thing I did
that worked (which<br>
>> doesn't<br>
>> > feel right to me, though) was adding a new
Metadata field (eg.<br>
>> title_en)<br>
>> > and add it to the database and workflow. On
the documentation,<br>
>> on the<br>
>> > other hand, I saw that there is a Multilang
field type<br>
>> > (./perl_lib/EPrints/MetaField/<a
moz-do-not-send="true" href="http://Multilang.pm">Multilang.pm</a>)
which should be<br>
>> used for<br>
>> > this purpose. The strange thing is that its
perldoc DESCRIPTION<br>
>> section<br>
>> > starts with "not done", probably meaning
that it's not implemented?<br>
>> > Disregarding the last comment, when I
changed<br>
>> > ./archives/myarchive/cfg/cfg.d/eprint_<a
moz-do-not-send="true" href="http://fields.pl">fields.pl</a>
title field to<br>
>> read:<br>
>> ><br>
>> > {<br>
>> > name => 'title',<br>
>> > type => 'multilang',<br>
>> > input_rows => 3,<br>
>> > make_single_value_orderkey =><br>
>> > 'EPrints::Extras::english_title_orderkey',<br>
>> > },<br>
>> ><br>
>> > and I reloaded epadmin, I got the following
error:<br>
>> ><br>
>> > "Error in field property for eprint.title:
fields on a multilang<br>
>> > metafield can't be undefined"<br>
>> ><br>
>> > So, which is the proper way for adding
multilanguage support in<br>
>> fields<br>
>> > and display them in workflows?<br>
>> ><br>
>> > Thanks for all help in advance!<br>
>> ><br>
>><br>
>><br>
>> -- <br>
>> George Mamalakis<br>
>><br>
>> IT and Security Officer,<br>
>> Electrical and Computer Engineer (Aristotle Univ.
of Thessaloniki),<br>
>> PhD (Aristotle Univ. of Thessaloniki),<br>
>> MSc (Imperial College of London)<br>
>><br>
>> School of Electrical and Computer Engineering<br>
>> Aristotle University of Thessaloniki<br>
>><br>
>> phone number : +30 (2310) 994379<br>
>><br>
>><br>
>><br>
>> *** Options:<br>
>> <a moz-do-not-send="true"
href="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech">http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</a><br>
>> *** Archive: <a moz-do-not-send="true"
href="http://www.eprints.org/tech.php">http://www.eprints.org/tech.php</a>/<br>
>> *** EPrints community wiki: <a
moz-do-not-send="true" href="http://wiki.eprints.org">http://wiki.eprints.org</a>/<br>
>> *** EPrints developers Forum: <a
moz-do-not-send="true" href="http://forum.eprints.org">http://forum.eprints.org</a>/<br>
>><br>
>><br>
>><br>
>> *** Options:<a moz-do-not-send="true"
href="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech">http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</a><br>
>> *** Archive:<a moz-do-not-send="true"
href="http://www.eprints.org/tech.php">http://www.eprints.org/tech.php</a>/<br>
>> *** EPrints community wiki:<a
moz-do-not-send="true" href="http://wiki.eprints.org">http://wiki.eprints.org</a>/<br>
>> *** EPrints developers Forum:<a
moz-do-not-send="true" href="http://forum.eprints.org">http://forum.eprints.org</a>/<br>
><br>
><br>
> -- <br>
> George Mamalakis<br>
><br>
> IT and Security Officer,<br>
> Electrical and Computer Engineer (Aristotle Univ. of
Thessaloniki),<br>
> PhD (Aristotle Univ. of Thessaloniki),<br>
> MSc (Imperial College of London)<br>
><br>
> School of Electrical and Computer Engineering<br>
> Aristotle University of Thessaloniki<br>
><br>
> phone number : +30 (2310) 994379<br>
><br>
><br>
><br>
><br>
> ----------------------------- Upozorenje
-----------------------------<br>
><br>
> Automatskom detekcijom utvrdjeno je da tekst ove
poruke<br>
> podsjeca na tzv. phishing poruku.<br>
><br>
> AKO SE U PORUCI TRAZI DA POSALJETE VASU IRB LOZINKU
ILI<br>
> DA UNESETE IRB PODATKE NA NAVEDENOM LINKU, RADI SE O<br>
> NAPADU S CILJEM KRADJE I ZLOUPOTREBE PODATAKA.<br>
><br>
> Centar za informatiku i racunarstvo,<br>
> Institut Rudjer Boskovic<br>
><br>
> ----------------------------- Upozorenje
-----------------------------<br>
><br>
><br>
> *** Options: <a moz-do-not-send="true"
href="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech">
http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</a><br>
> *** Archive: <a moz-do-not-send="true"
href="http://www.eprints.org/tech.php">http://www.eprints.org/tech.php</a>/<br>
> *** EPrints community wiki: <a
moz-do-not-send="true" href="http://wiki.eprints.org">http://wiki.eprints.org</a>/<br>
> *** EPrints developers Forum: <a
moz-do-not-send="true" href="http://forum.eprints.org">http://forum.eprints.org</a>/<br>
<br>
<br>
-- <br>
Sent from my Android device with K-9 Mail. Please excuse
my brevity. <br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre>*** Options: <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech">http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</a>
*** Archive: <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://www.eprints.org/tech.php/">http://www.eprints.org/tech.php/</a>
*** EPrints community wiki: <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://wiki.eprints.org/">http://wiki.eprints.org/</a>
*** EPrints developers Forum: <a moz-do-not-send="true" class="moz-txt-link-freetext" href="http://forum.eprints.org/">http://forum.eprints.org/</a>
</pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
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
</pre>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<br>
<pre wrap="">*** Options: <a class="moz-txt-link-freetext" href="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech">http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</a>
*** Archive: <a class="moz-txt-link-freetext" href="http://www.eprints.org/tech.php/">http://www.eprints.org/tech.php/</a>
*** EPrints community wiki: <a class="moz-txt-link-freetext" href="http://wiki.eprints.org/">http://wiki.eprints.org/</a>
*** EPrints developers Forum: <a class="moz-txt-link-freetext" href="http://forum.eprints.org/">http://forum.eprints.org/</a>
</pre>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">--
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
</pre>
</body>
</html>