Skip to content

Commit

Permalink
Add language and territory to output
Browse files Browse the repository at this point in the history
  • Loading branch information
ak-coram committed Jul 18, 2023
1 parent 95bfba8 commit 284986d
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions chronogram-cldr-parser.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,17 @@
(eras . ,(funcall parse-eras calendar))))
:intern-type t)))
(defun parse-cldr (contents)
(let ((root (plump:parse contents)))
(list (cons 'calendars (funcall parse-calendar root))))))
(let* ((root (plump:parse contents))
(language (plump:get-attribute (clss-select-first "ldml > identity > language" root)
"type"))
(territory-node (clss-select-first "ldml > identity > territory" root))
(territory (when territory-node
(plump:get-attribute territory-node "type")))
(calendars (funcall parse-calendar root)))
`((language . ,language)
,@(when territory
`((territory . ,territory)))
,@(when calendars
`((calendars . ,calendars)))))))

;; (parse-cldr (uiop:read-file-string "cldr/common/main/hu.xml"))
;; (parse-cldr (uiop:read-file-string "cldr-staging/production/common/main/en_GB.xml"))

0 comments on commit 284986d

Please sign in to comment.