From 284986dde2a94e6bc27cb0a8506423e95843ca75 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81kos=20Kiss?= Date: Tue, 18 Jul 2023 04:27:55 +0200 Subject: [PATCH] Add language and territory to output --- chronogram-cldr-parser.lisp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/chronogram-cldr-parser.lisp b/chronogram-cldr-parser.lisp index 37c1e57..9af6ead 100644 --- a/chronogram-cldr-parser.lisp +++ b/chronogram-cldr-parser.lisp @@ -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"))