cl-l10n
2021-12-09
Portable CL Locale Support
Upstream URL
Author
Sean Ross <sross@common-lisp.net>
Maintainer
Sean Ross <sross@common-lisp.net>
License
MIT
README for Package CL-L10N
Author: Sean Ross
i18n, CLDR stuff: Levente Mészáros, Attila Lendvai
Homepage: http://www.common-lisp.net/project/cl-l10n/
CLDR: http://unicode.org/cldr/
*** About
cl-l10n is a localization package for common-lisp.
It is distributed under an MIT style license although the locale files
themselves are distributed under the LGPL.
There is also i18n support, read on for details.
*** Emacs goodies
I have this in my init.el that, besides other things, adds better
indentation for DEFRESOURCES.
(require 'cl)
(let ((overrides
'((defclass* defclass)
(defcondition* defcondition)
(def (4 4 (&whole 4 &rest 2) &body))
(defresources (4 &rest (&whole 2 &lambda &body))))))
(dolist (el overrides)
(put (first el) 'common-lisp-indent-function
(if (symbolp (second el))
(get (second el) 'common-lisp-indent-function)
(second el)))))
*** API
See docs/cl-l10n.texi
*** i18n
When locales are loaded cl-l10n also tries to load locale-specific
resource files. They are simple lisp files that are read into the
*RESOURCE-PACKAGE* package. Use WITH-RESOURCE-PACKAGE
to bind it at an appriately high level of your application.
I suggest to create a separate package for language resources and
don't import it in your app, so you can easily see/search for
lang:foo references.
The resources in these files are either constants or lambdas. For
lambdas we create a function with the resource name that looks up
the locale specific implementation and calls it. This way you can
write in your code (lang:plural-of #"foot") and it will return
"feet" in the language given in *locale*.
#"" is a reader macro that expands into a lookup-resource call.
Resource lookup can fall back to less preferred languages when
*locale* is a list.
*** TODO/plans
The CLDR files contain formatting patterns that could be used for
generating/driving parsers, especially for date/time.
http://www.unicode.org/reports/tr35/tr35-21.html#Lenient_Parsing
Collation info should be used to generate locale sensitive string
comparators. For the whole (quite complex!) story read this:
http://www.unicode.org/reports/tr10/
Consider reinstating a dwim-ish date/time parser, but it brings up
more questions than i want to write up right now.
Consider the relationship with the local-time project, and decide
about responsibilities.
*** Testing
Run (asdf:test-system :cl-l10n) to test the code.
If you have unexpected failures, drop a mail to the mailing
list.
*** Troubleshooting
You can find the CL-L10N:PARSE-TIME function in the old branch of
cl-l10n:
darcs get https://www.common-lisp.net/project/cl-l10n/darcs/cl-l10n.unix-locale-files/