Skip to content

Commit

Permalink
find and use concept label which has a subtag language. Fixes #578
Browse files Browse the repository at this point in the history
(cherry picked from commit 73df45e)
  • Loading branch information
osma committed Feb 3, 2017
1 parent a17fd8c commit 01bd5e0
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions model/Concept.php
Original file line number Diff line number Diff line change
Expand Up @@ -119,13 +119,17 @@ public function getLabel()
return $this->resource->label($this->vocab->getConfig()->getDefaultLanguage());
}

// 3. label in any language
$label = $this->resource->label();
// if the label lang code is a subset of the ui lang eg. en-GB
if ($label !== null && strpos($label->getLang(), $lang . '-') === 0) {
return EasyRdf_Literal::create($label, $lang);
// 3. label in a subtag of the current language
// We need to check all the labels in case one of them matches a subtag of the current language
foreach($this->resource->allLiterals('skos:prefLabel') as $label) {
// the label lang code is a subtag of the UI lang eg. en-GB - create a new literal with the main language
if ($label !== null && strpos($label->getLang(), $lang . '-') === 0) {
return EasyRdf_Literal::create($label, $lang);
}
}


// 4. label in any language, including literal with empty language tag
$label = $this->resource->label();
if ($label !== null) {
return $label->getValue() . " (" . $label->getLang() . ")";
}
Expand Down

0 comments on commit 01bd5e0

Please sign in to comment.