Skip to content

Commit

Permalink
Consider script and variant when parsing / making dist
Browse files Browse the repository at this point in the history
  • Loading branch information
ak-coram committed Jul 18, 2023
1 parent ab09908 commit 2711fbd
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 10 deletions.
14 changes: 13 additions & 1 deletion chronogram-cldr-parser.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -114,13 +114,25 @@
(territory-node (clss-select-first "ldml > identity > territory" root))
(territory (when territory-node
(plump:get-attribute territory-node "type")))
(script-node (clss-select-first "ldml > identity > script" root))
(script (when script-node
(plump:get-attribute script-node "type")))
(variant-node (clss-select-first "ldml > identity > variant" root))
(variant (when variant-node
(plump:get-attribute variant-node "type")))
(calendars (funcall parse-calendar root)))
(values `((language . ,language)
,@(when script
`((script . ,script)))
,@(when territory
`((territory . ,territory)))
,@(when variant
`((variant . ,variant)))
,@(when calendars
`((calendars . ,calendars))))
language
territory))))
script
territory
variant))))

;; (parse-cldr (uiop:read-file-string "cldr-staging/production/common/main/en_GB.xml"))
19 changes: 10 additions & 9 deletions chronogram-dist.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,17 @@
(in-package #:chronogram-dist)

(defun make-chronogram-info (contents dist-dir)
(multiple-value-bind (info language territory)
(multiple-value-bind (info language script territory variant)
(chronogram-cldr-parser:parse-cldr contents)
(with-open-file (stream (if territory
(format nil "~a~a_~a.lisp"
dist-dir
language
territory)
(format nil "~a~a.lisp"
dist-dir
language))
(with-open-file (stream (format nil "~a~{~a~^_~}.lisp"
dist-dir
`(,language
,@(when script
(list script))
,@(when territory
(list territory))
,@(when variant
(list variant))))
:direction :output
:if-exists :supersede
:if-does-not-exist :create)
Expand Down

0 comments on commit 2711fbd

Please sign in to comment.