Skip to content

Commit

Permalink
multilang fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Shinmera committed Sep 27, 2018
1 parent 024207f commit 5b4f04d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
6 changes: 3 additions & 3 deletions documentation.lisp
Expand Up @@ -122,7 +122,7 @@ See COMPILE-SOURCE")
"Returns a suitable pathname making up the filename of the page.
By default for simple-pages this is the name \"index\" followed by
the language code of the page if the language is not \"en\" or \"eng\"
the language code of the page, if the language is not :en or :eng,
and the type \"html\".
See SIMPLE-PAGE")
Expand Down Expand Up @@ -248,8 +248,8 @@ See PAGE")
"Accessor to the language of a page.
The language should be a two or three-letter short-code that uniquely
identifies the language. See the ISO-639 language codes for all
available options.
identifies the language as a keyword. See the ISO-639 language codes for
all available options.
See PAGE")

Expand Down
10 changes: 5 additions & 5 deletions inference.lisp
Expand Up @@ -29,16 +29,16 @@
(unless language
(setf (language page) (or (when document (extract-language (file-namestring document)))
(when output (extract-language (file-namestring output)))
"en")))
:en)))
(unless (or (pathname-name output)
(pathname-type output))
(setf (output page) (merge-pathnames (filename page) (output page)))))

(defmethod filename ((page simple-page))
(let ((lang (unless (find (language page) '("en" "eng") :test #'string-equal)
(language page))))
(make-pathname :name (format NIL "index~@[-~a~]" lang)
:type "html")))
(make-pathname :name (if (find (language page) '(:en :eng))
"index"
(format NIL "index-~(~a~)" (language page)))
:type "html"))

(defmethod definition-wanted-p ((definition definitions:definition) (project simple-page))
(eql :external (definitions:visibility definition)))
Expand Down
4 changes: 2 additions & 2 deletions page.lisp
Expand Up @@ -10,7 +10,7 @@

(defclass page ()
((title :initarg :title :accessor title)
(language :initarg :language :initform "en" :accessor language)
(language :initarg :language :initform :en :accessor language)
(output :initarg :output :accessor output)
(project :initarg :project :accessor project))
(:default-initargs
Expand All @@ -21,7 +21,7 @@
(defmethod initialize-instance :after ((page page) &key output language)
(unless language
(setf (language page) (or (when output (extract-language (file-namestring output)))
"en"))))
:en))))

(defmethod print-object ((page page) stream)
(print-unreadable-object (page stream :type T)
Expand Down
3 changes: 2 additions & 1 deletion toolkit.lisp
Expand Up @@ -228,7 +228,8 @@

(defun extract-language (string)
(cl-ppcre:do-matches-as-strings (code "\\b\\w{2,3}\\b" string)
(let ((found (language-codes:names code)))
(let* ((code (find-symbol (string-upcase code) "KEYWORD"))
(found (when code (language-codes:names code))))
(when found
(return (values code found))))))

Expand Down

0 comments on commit 5b4f04d

Please sign in to comment.