@@ -128,7 +128,8 @@ function _graphToRDF(dataset, graph, graphTerm, issuer, options) {
128128 }
129129
130130 // 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 ) ;
132133 // skip null objects (they are relative IRIs)
133134 if ( object ) {
134135 dataset . push ( {
@@ -154,7 +155,7 @@ function _graphToRDF(dataset, graph, graphTerm, issuer, options) {
154155 *
155156 * @return the head of the list.
156157 */
157- function _listToRDF ( list , issuer , dataset , graphTerm ) {
158+ function _listToRDF ( list , issuer , dataset , graphTerm , rdfDirection ) {
158159 const first = { termType : 'NamedNode' , value : RDF_FIRST } ;
159160 const rest = { termType : 'NamedNode' , value : RDF_REST } ;
160161 const nil = { termType : 'NamedNode' , value : RDF_NIL } ;
@@ -165,7 +166,7 @@ function _listToRDF(list, issuer, dataset, graphTerm) {
165166 let subject = result ;
166167
167168 for ( const item of list ) {
168- const object = _objectToRDF ( item , issuer , dataset , graphTerm ) ;
169+ const object = _objectToRDF ( item , issuer , dataset , graphTerm , rdfDirection ) ;
169170 const next = { termType : 'BlankNode' , value : issuer . getId ( ) } ;
170171 dataset . push ( {
171172 subject,
@@ -184,7 +185,7 @@ function _listToRDF(list, issuer, dataset, graphTerm) {
184185
185186 // Tail of list
186187 if ( last ) {
187- const object = _objectToRDF ( last , issuer , dataset , graphTerm ) ;
188+ const object = _objectToRDF ( last , issuer , dataset , graphTerm , rdfDirection ) ;
188189 dataset . push ( {
189190 subject,
190191 predicate : first ,
@@ -213,7 +214,7 @@ function _listToRDF(list, issuer, dataset, graphTerm) {
213214 *
214215 * @return the RDF literal or RDF resource.
215216 */
216- function _objectToRDF ( item , issuer , dataset , graphTerm ) {
217+ function _objectToRDF ( item , issuer , dataset , graphTerm , rdfDirection ) {
217218 const object = { } ;
218219
219220 // convert value object to RDF
@@ -243,6 +244,14 @@ function _objectToRDF(item, issuer, dataset, graphTerm) {
243244 } else if ( types . isNumber ( value ) ) {
244245 object . value = value . toFixed ( 0 ) ;
245246 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 ;
246255 } else if ( '@language' in item ) {
247256 object . value = value ;
248257 object . datatype . value = datatype || RDF_LANGSTRING ;
@@ -252,7 +261,8 @@ function _objectToRDF(item, issuer, dataset, graphTerm) {
252261 object . datatype . value = datatype || XSD_STRING ;
253262 }
254263 } 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 ) ;
256266 object . termType = _list . termType ;
257267 object . value = _list . value ;
258268 } else {
0 commit comments