Skip to content

Commit

Permalink
Merge pull request #6 from zazuko/fix-languages
Browse files Browse the repository at this point in the history
Fix language resolution for labels
  • Loading branch information
ludovicm67 authored Sep 18, 2023
2 parents 14a58b6 + cc60064 commit cac1365
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/itchy-ears-warn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@zazuko/rdf-entity-webcomponent": patch
---

Fix language resolution for labels (closes #4)
7 changes: 6 additions & 1 deletion src/builder/labels.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
import { splitIfVocab } from './utils.js'

function getWithLang (cf, options) {
let highlightLanguage = options.highlightLanguage ? [options.highlightLanguage] : undefined
if (!highlightLanguage) {
highlightLanguage = options.preferredLanguages ?? []
}

for (const property of options.labelProperties) {
const terms = cf.out(property,
{ language: [...(options.preferredLanguages ?? []), '*'] }).terms
{ language: [...highlightLanguage, '*'] }).terms
if (terms.length) {
const language = terms[0].language
return {
Expand Down

0 comments on commit cac1365

Please sign in to comment.