Support translator meta data type
Change-Id: I2f8c02122b7a15cddcaf63d411a04f0afb5f0fb7
diff --git a/lib/KorAP/XML/Meta/I5.pm b/lib/KorAP/XML/Meta/I5.pm
index 76eb763..0dd5330 100644
--- a/lib/KorAP/XML/Meta/I5.pm
+++ b/lib/KorAP/XML/Meta/I5.pm
@@ -59,10 +59,20 @@
my $author = $analytic->at('h\.author');
my $editor = $analytic->at('editor');
+ # Editor contains translator
+ my $translator;
+ if ($editor && $editor->attr('role') && $editor->attr('role') eq 'translator') {
+ # Translator is only supported on the text level currently
+ $self->{translator} = _squish $editor->all_text;
+ $editor = undef;
+ }
+ else {
+ $editor = $editor ? _squish $editor->all_text : undef;
+ };
+
$title = $title ? _squish $title->all_text : undef;
$sub_title = $sub_title ? _squish $sub_title->all_text : undef;
$author = $author ? _squish $author->all_text : undef;
- $editor = $editor ? _squish $editor->all_text : undef;
# Text meta data
if ($type eq 'text') {
diff --git a/t/corpus/BBU/BLOG/83709_a_82384/header.xml b/t/corpus/BBU/BLOG/83709_a_82384/header.xml
index b492d5d..f0cf746 100644
--- a/t/corpus/BBU/BLOG/83709_a_82384/header.xml
+++ b/t/corpus/BBU/BLOG/83709_a_82384/header.xml
@@ -17,7 +17,7 @@
<biblStruct>
<monogr>
<h.author>DragoČ™ Bucurenci</h.author>
- <editor role="translator">-</editor>
+ <!-- <editor role="translator">-</editor> -->
<imprint>
<pubDate type="year">2013</pubDate>
<pubDate type="month">10</pubDate>
@@ -28,4 +28,4 @@
</biblStruct>
</sourceDesc>
</fileDesc>
- </idsHeader>
\ No newline at end of file
+ </idsHeader>
diff --git a/t/real/drukola.t b/t/real/drukola.t
index 244101a..4656f18 100644
--- a/t/real/drukola.t
+++ b/t/real/drukola.t
@@ -38,6 +38,7 @@
ok(!$meta->{publisher}, 'Publisher');
ok(!$meta->{editor}, 'Editor');
+is($meta->{translator}, '[TRANSLATOR]', 'Translator');
#is($meta->{text_type}, 'Autobiographie', 'Correct Text Type');
ok(!$meta->{text_type_art}, 'Correct Text Type Art');
# is($meta->{text_type_ref}, '', 'Correct Text Type Ref');