Skip to content

Commit

Permalink
Merge pull request pleonex#51 from ph777/new/i18n
Browse files Browse the repository at this point in the history
Add support for xml:lang in xs:description element
  • Loading branch information
pleonex authored Jun 11, 2018
2 parents 37023dc + 5895bba commit 86cb434
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions lib/xsdParser.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,23 @@ module.exports =

## Get documentation string from node
getDocumentation: (node) ->
@normalizeString(node?.annotation?[0].documentation[0]._ ?
node?.annotation?[0].documentation[0])
langUser = navigator.language
docs = node?.annotation?[0].documentation
if ! docs
return null

docEn = null
docAny = null
for doc in docs
langDoc = doc.$?.lang
if langDoc == langUser
return @normalizeString(doc._)
if langDoc == 'en'
docEn = doc
else
docAny = doc
return @normalizeString(if docEn then docEn._ else
if docAny then docAny._)

# Initialize a type object from a Simple or Complex type node.
initTypeObject: (node, typeName) ->
Expand Down Expand Up @@ -432,3 +446,4 @@ module.exports =
else
attributes.push attr
type.xsdAttributes = attributes

0 comments on commit 86cb434

Please sign in to comment.