Commit f29ef690 authored by Laurent Wouters's avatar Laurent Wouters
Browse files

[fix] Use non-tagged literals as default when requested languages are not found

parent 05ee13ea2674
......@@ -136,14 +136,27 @@ export class MetaPropertyData implements MetaProperty {
let matching = literals
.map((literal: $rdf.Literal) => {
// is it tagged by one of the requested language?
for (var l = 0; l != languages.length; l++) {
if (
literal.lang == languages[l].iso639_1 ||
literal.lang == languages[l].iso639_2
)
// ok => it has the priority of the language
return { literal: literal, rank: l } as RankedLiteral;
}
return { literal: literal, rank: languages.length } as RankedLiteral;
if (
literal.lang == null ||
literal.lang == undefined ||
literal.lang == ""
)
// lang-tag is not defined, has more priority than other tagged literals that do not match (considered as a default)
return { literal: literal, rank: languages.length } as RankedLiteral;
// this is tagged literal that is not matched by one of the requested language
return {
literal: literal,
rank: languages.length + 1
} as RankedLiteral;
})
.sort((a: RankedLiteral, b: RankedLiteral) => a.rank - b.rank);
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment