Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
195 changes: 195 additions & 0 deletions conf/langCodes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,195 @@
---

# Map from three-character ISO 639-2/B code (same as used in MARC 008) to
# two-character ISO 639 codes (same as IETF codes for html lang attribute) If
# there is a language code in a record not in this list, then the
# three-character code will be used, which is likely also an IETF language
# code. See
# https://www.iana.org/assignments/language-subtag-registry/language-subtag-registry

lang_codes:
aar: aa
abk: ab
afr: af
aka: ak
alb: sq
amh: am
ara: ar
arg: an
arm: hy
asm: as
ava: av
ave: ae
aym: ay
aze: az
bak: ba
bam: bm
baq: eu
bel: be
ben: bn
bih: bh
bis: bi
bos: bs
bre: br
bul: bg
bur: my
cat: ca
cha: ch
che: ce
chi: zh
chu: cu
chv: cv
cor: kw
cos: co
cre: cr
cze: cs
dan: da
div: dv
dut: nl
dzo: dz
eng: en
epo: eo
est: et
ewe: ee
fao: fo
fij: fj
fin: fi
fre: fr
fry: fy
ful: ff
geo: ka
ger: de
gla: gd
gle: ga
glg: gl
glv: gv
gre: el
grn: gn
guj: gu
hat: ht
hau: ha
heb: he
her: hz
hin: hi
hmo: ho
hrv: hr
hun: hu
ibo: ig
ice: is
ido: io
iii: ii
iku: iu
ile: ie
ina: ia
ind: id
ipk: ik
ita: it
jav: jv
jpn: ja
kal: kl
kan: kn
kas: ks
kau: kr
kaz: kk
khm: km
kik: ki
kin: rw
kir: ky
kom: kv
kon: kg
kor: ko
kua: kj
kur: ku
lao: lo
lat: la
lav: lv
lim: li
lin: ln
lit: lt
ltz: lb
lub: lu
lug: lg
mac: mk
mah: mh
mal: ml
mao: mi
mar: mr
may: ms
mlg: mg
mlt: mt
mon: mn
nau: na
nav: nv
nbl: nr
nde: nd
ndo: ng
nep: ne
nno: nn
nob: nb
nor: no
nya: ny
oci: oc
oji: oj
ori: or
orm: om
oss: os
pan: pa
per: fa
pli: pi
pol: pl
por: pt
pus: ps
que: qu
roh: rm
rum: ro
run: rn
rus: ru
sag: sg
san: sa
# scr: sh
sin: si
slo: sk
slv: sl
sme: se
smo: sm
sna: sn
snd: sd
som: so
sot: st
spa: es
srd: sc
srp: sr
ssw: ss
sun: su
swa: sw
swe: sv
tah: ty
tam: ta
tat: tt
tel: te
tgk: tg
tgl: tl
tha: th
tib: bo
tir: ti
ton: to
tsn: tn
tso: ts
tuk: tk
tur: tr
twi: tw
uig: ug
ukr: uk
urd: ur
uzb: uz
ven: ve
vie: vi
vol: vo
wel: cy
wln: wa
wol: wo
xho: xh
yid: yi
yor: yo
zha: za
zul: zu
14 changes: 7 additions & 7 deletions interface/themes/firebird/Record/view.summary.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{if $marcField}
<div class="grid">
<dt class="g-col-lg-4 g-col-12">{translate text='New Title'}</dt>
<dd class="g-col-lg-8 g-col-12">
<dd class="g-col-lg-8 g-col-12" lang="{$html_lang}">
{foreach from=$marcField item=field name=loop}
<a href="{$url}/Search/Home?lookfor=%22{$field|getvalue:'s'}{$field|getvalue:'t'}%22&type=title&amp;inst={$inst}">{$field|getvalue:'s'}{$field|getvalue:'t'}</a><br>
{/foreach}
Expand All @@ -17,7 +17,7 @@
{if $marcField}
<div class="grid">
<dt class="g-col-lg-4 g-col-12">{translate text='Previous Title'}</dt>
<dd class="g-col-lg-8 g-col-12">
<dd class="g-col-lg-8 g-col-12" lang="{$html_lang}">
{foreach from=$marcField item=field name=loop}
<a href="{$url}/Search/Home?lookfor=%22{$field|getvalue:'s'}{$field|getvalue:'t'}%22&type=title&amp;inst={$inst}">{$field|getvalue:'s'}{$field|getvalue:'t'}</a><br>
{/foreach}
Expand All @@ -29,7 +29,7 @@
{if $marcField}
<div class="grid">
<dt class="g-col-lg-4 g-col-12">{translate text='Main Author'}</dt>
<dd class="g-col-lg-8 g-col-12">
<dd class="g-col-lg-8 g-col-12" lang="{$html_lang}">
{record_author_display marc_field=$marcField inst=$inst url=$url}
</dd>
</div>
Expand All @@ -39,7 +39,7 @@
{if $marcField}
<div class="grid">
<dt class="g-col-lg-4 g-col-12">{translate text='Corporate Author'}</dt>
<dd class="g-col-lg-8 g-col-12">
<dd class="g-col-lg-8 g-col-12" lang="{$html_lang}">
{record_author_display marc_field=$marcField inst=$inst url=$url}
</dd>
</div>
Expand All @@ -49,7 +49,7 @@
{if $marcField}
<div class="grid">
<dt class="g-col-lg-4 g-col-12">{translate text='Meeting Name'}</dt>
<dd class="g-col-lg-8 g-col-12">
<dd class="g-col-lg-8 g-col-12" lang="{$html_lang}">
{record_author_display marc_field=$marcField inst=$inst url=$url}
</dd>
</div>
Expand All @@ -59,7 +59,7 @@
{if $marcField}
<div class="grid">
<dt class="g-col-lg-4 g-col-12">{translate text='Related Names'}</dt>
<dd class="g-col-lg-8 g-col-12">
<dd class="g-col-lg-8 g-col-12" lang="{$html_lang}">
{foreach from=$marcField item=field name=loop}
{record_author_display marc_field=$field inst=$inst url=$url}<br/>
{/foreach}
Expand Down Expand Up @@ -89,7 +89,7 @@
<dt class="g-col-lg-4 g-col-12">{translate text='Published'}</dt>
<dd class="g-col-lg-8 g-col-12">
{foreach from=$marcField item=field name=loop}
{$field|getvalue:'a'} {$field|getvalue:'b'} {$field|getvalue:'c'}<br>
<span lang="{$html_lang}">{$field|getvalue:'a'} {$field|getvalue:'b'}</span> {$field|getvalue:'c'}<br>
{/foreach}
</dd>
</div>
Expand Down
8 changes: 5 additions & 3 deletions interface/themes/firebird/Record/view.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@
</div>
</xsl:if>
{assign var=marcField value=$marc->getFields('245')}
<h1>
{assign var=html_lang value=$ru->getHtmlLang($record)}
<h1 lang="{$html_lang}">
{foreach from=$marcField item=field name=loop}
{foreach from=$field->getSubfields() item=subfield key=subcode name=subloop}
{if $subcode >= 'a' and $subcode <= 'z'}
Expand Down Expand Up @@ -152,15 +153,16 @@
{foreach from=$similarRecords item=similar}
{if is_array($similar.title)}{assign var=similarTitle value=$similar.title.0}
{else}{assign var=similarTitle value=$similar.title}{/if}
{assign var=html_lang value=$ru->getHtmlLang($similar)}
<div class="d-flex gap-3 p-3 mb-3 mt-3 shadow-sm rounded">
<div class="container-fluid p-1">
<h3 class="record-title h4 mb-3 fw-normal"><a href="{$url}/Record/{$similar.id}">{$similarTitle}</a></h3>
<h3 class="record-title h4 mb-3 fw-normal" lang="{$html_lang}"><a href="{$url}/Record/{$similar.id}">{$similarTitle}</a></h3>
{if $similar.author or $similar.publishDate}
<dl class="metadata mb-0">
<div class="grid gap-2">
{if $similar.author}
<dt class="g-col-lg-3 g-col-12">Author</dt>
<dd class="g-col-lg-9 g-col-12">{$similar.author.0}</dd>
<dd class="g-col-lg-9 g-col-12" lang="{$html_lang}">{$similar.author.0}</dd>
{/if}
{if $similar.publishDate}
<dt class="g-col-lg-3 g-col-12">Published</dt>
Expand Down
10 changes: 5 additions & 5 deletions interface/themes/firebird/Search/list-list.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ FIREBIRD TODOS:

<div class="flex-grow-1 d-flex flex-column justify-content-between">
<div class="container-fluid p-1">
<div id="maintitle-{$i}">
<div id="maintitle-{$i}" lang="{$record.html_lang}">
{if is_array($record.title)}
{foreach from=$record.title item=title}
<h3 class="record-title">
Expand All @@ -50,13 +50,13 @@ FIREBIRD TODOS:
</div>
{if $record.title2}
<blockquote>
<p class="results_title2">{$record.title2|truncate:180:"..."|highlight:$lookfor}</p>
<p class="results_title2" lang="{$record.html_lang}">{$record.title2|truncate:180:"..."|highlight:$lookfor}</p>
</blockquote>
{/if}

{if $record.vtitle}
<blockquote>
<span class="results_title2">{$record.vtitle}</span>
<span class="results_title2" lang="{$record.html_lang}">{$record.vtitle}</span>
</blockquote>
{/if}

Expand All @@ -73,10 +73,10 @@ FIREBIRD TODOS:
<dt class="g-col-lg-4 g-col-12">Author</dt>
{if is_array($record.author)}
{foreach from=$record.author item=author}
<dd class="g-col-lg-4 g-col-12">{$author|highlight:$lookfor}</dd>
<dd class="g-col-lg-4 g-col-12" lang="{$record.html_lang}">{$author|highlight:$lookfor}</dd>
{/foreach}
{else}
<dd class="g-col-lg-4 g-col-12">{$record.author|highlight:$lookfor}</dd>
<dd class="g-col-lg-4 g-col-12" lang="{$record.html_lang}">{$record.author|highlight:$lookfor}</dd>
</div>
{/if}
{/if}
Expand Down
12 changes: 12 additions & 0 deletions services/Record/RecordUtils.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ class RecordUtils {
'wu' => 'WISC'
);

private $lang_codes;

// Get all 974s
function ht_fields($marc) {
return $marc->getFields('974');
Expand Down Expand Up @@ -245,6 +247,7 @@ function is_open_to_no_one($rcodes) {

function __construct() {
global $configArray;
$this->lang_codes = yaml_parse_file('conf/langCodes.yaml')['lang_codes'];
}

function getMarcRecord($record) {
Expand Down Expand Up @@ -504,6 +507,15 @@ function getSummaryAndContentAdvice($marc) {
}
return $data;
}

function getHtmlLang($record) {
$lang = $record['language008'];
if(array_key_exists($lang,$this->lang_codes)) {
$lang = $this->lang_codes[$lang];
}
return $lang;
}

}

?>
3 changes: 1 addition & 2 deletions services/Search/Home.php
Original file line number Diff line number Diff line change
Expand Up @@ -408,11 +408,10 @@ function search()
$marcRecord = $ru->getMarcRecord($record);
$result['record'][$num]['marc'] = $marcRecord;
$result['record'][$num]['title'] = $ru->getFullTitle($marcRecord);
$result['record'][$num]['html_lang'] = $ru->getHtmlLang($record);
$result['record'][$num]['googleLinks'] = implode(",", $ru->getLinkNums($marcRecord));
$url_list[$record['id']] = $ru->getURLs($marcRecord);
$id = $record['id'];


}


Expand Down