@@ -128,7 +128,8 @@ function _graphToRDF(dataset, graph, graphTerm, issuer, options) {
128
128
}
129
129
130
130
// convert list, value or node object to triple
131
- const object = _objectToRDF ( item , issuer , dataset , graphTerm ) ;
131
+ const object =
132
+ _objectToRDF ( item , issuer , dataset , graphTerm , options . rdfDirection ) ;
132
133
// skip null objects (they are relative IRIs)
133
134
if ( object ) {
134
135
dataset . push ( {
@@ -154,7 +155,7 @@ function _graphToRDF(dataset, graph, graphTerm, issuer, options) {
154
155
*
155
156
* @return the head of the list.
156
157
*/
157
- function _listToRDF ( list , issuer , dataset , graphTerm ) {
158
+ function _listToRDF ( list , issuer , dataset , graphTerm , rdfDirection ) {
158
159
const first = { termType : 'NamedNode' , value : RDF_FIRST } ;
159
160
const rest = { termType : 'NamedNode' , value : RDF_REST } ;
160
161
const nil = { termType : 'NamedNode' , value : RDF_NIL } ;
@@ -165,7 +166,7 @@ function _listToRDF(list, issuer, dataset, graphTerm) {
165
166
let subject = result ;
166
167
167
168
for ( const item of list ) {
168
- const object = _objectToRDF ( item , issuer , dataset , graphTerm ) ;
169
+ const object = _objectToRDF ( item , issuer , dataset , graphTerm , rdfDirection ) ;
169
170
const next = { termType : 'BlankNode' , value : issuer . getId ( ) } ;
170
171
dataset . push ( {
171
172
subject,
@@ -184,7 +185,7 @@ function _listToRDF(list, issuer, dataset, graphTerm) {
184
185
185
186
// Tail of list
186
187
if ( last ) {
187
- const object = _objectToRDF ( last , issuer , dataset , graphTerm ) ;
188
+ const object = _objectToRDF ( last , issuer , dataset , graphTerm , rdfDirection ) ;
188
189
dataset . push ( {
189
190
subject,
190
191
predicate : first ,
@@ -213,7 +214,7 @@ function _listToRDF(list, issuer, dataset, graphTerm) {
213
214
*
214
215
* @return the RDF literal or RDF resource.
215
216
*/
216
- function _objectToRDF ( item , issuer , dataset , graphTerm ) {
217
+ function _objectToRDF ( item , issuer , dataset , graphTerm , rdfDirection ) {
217
218
const object = { } ;
218
219
219
220
// convert value object to RDF
@@ -243,6 +244,14 @@ function _objectToRDF(item, issuer, dataset, graphTerm) {
243
244
} else if ( types . isNumber ( value ) ) {
244
245
object . value = value . toFixed ( 0 ) ;
245
246
object . datatype . value = datatype || XSD_INTEGER ;
247
+ } else if ( rdfDirection === 'i18n-datatype' &&
248
+ '@direction' in item )
249
+ {
250
+ const datatype = 'https://www.w3.org/ns/i18n#' +
251
+ ( item [ '@language' ] || '' ) +
252
+ `_${ item [ '@direction' ] } ` ;
253
+ object . datatype . value = datatype ;
254
+ object . value = value ;
246
255
} else if ( '@language' in item ) {
247
256
object . value = value ;
248
257
object . datatype . value = datatype || RDF_LANGSTRING ;
@@ -252,7 +261,8 @@ function _objectToRDF(item, issuer, dataset, graphTerm) {
252
261
object . datatype . value = datatype || XSD_STRING ;
253
262
}
254
263
} else if ( graphTypes . isList ( item ) ) {
255
- const _list = _listToRDF ( item [ '@list' ] , issuer , dataset , graphTerm ) ;
264
+ const _list =
265
+ _listToRDF ( item [ '@list' ] , issuer , dataset , graphTerm , rdfDirection ) ;
256
266
object . termType = _list . termType ;
257
267
object . value = _list . value ;
258
268
} else {
0 commit comments