Skip to content

Commit 241ef57

Browse files
committed
Normalize language tags to lower case when creating an i18n datatype or compound literal.
1 parent 51b90ae commit 241ef57

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

lib/json/ld/to_rdf.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,11 +50,11 @@ def item_to_rdf(item, graph_name: nil, &block)
5050
# Either serialize using a datatype, or a compound-literal
5151
case @options[:rdfDirection]
5252
when 'i18n-datatype'
53-
datatype = RDF::URI("https://www.w3.org/ns/i18n##{item.fetch('@language', '')}_#{item['@direction']}")
53+
datatype = RDF::URI("https://www.w3.org/ns/i18n##{item.fetch('@language', '').downcase}_#{item['@direction']}")
5454
when 'compound-literal'
5555
cl = RDF::Node.new
5656
yield RDF::Statement(cl, RDF.value, item['@value'].to_s)
57-
yield RDF::Statement(cl, RDF.to_uri + 'language', item['@language']) if item['@language']
57+
yield RDF::Statement(cl, RDF.to_uri + 'language', item['@language'].downcase) if item['@language']
5858
yield RDF::Statement(cl, RDF.to_uri + 'direction', item['@direction'])
5959
return cl
6060
end

spec/to_rdf_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1133,7 +1133,7 @@
11331133
],
11341134
"en-US rtl": [
11351135
%q({"http://example.org/label": {"@value": "en-US", "@language": "en-US", "@direction": "rtl"}}),
1136-
%q(_:a <http://example.org/label> "en-US"^^<https://www.w3.org/ns/i18n#en-US_rtl> .)
1136+
%q(_:a <http://example.org/label> "en-US"^^<https://www.w3.org/ns/i18n#en-us_rtl> .)
11371137
]
11381138
}.each do |title, (js, ttl)|
11391139
it title do
@@ -1161,7 +1161,7 @@
11611161
@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .
11621162
_:a <http://example.org/label> [
11631163
rdf:value "en-US";
1164-
rdf:language "en-US";
1164+
rdf:language "en-us";
11651165
rdf:direction "rtl"
11661166
] .
11671167
)

0 commit comments

Comments
 (0)