Simple internationalization for Clojure
Create maps with internationalized resources (e.g. strings)
(def en-resources {:hi "hello {0}", "bye" "bye"})
(def es-resources {:hi "hola {0}", "bye" "adiós"})
(def es-ar-resources {"bye" "chau"})
Keys and values could be anything, but it's probably useful to use keywords or strings as keys.
Create a tree of resource bundles
(def tree (make-resource-tree en-resources
(locale "es") es-resources)
(locale "es" "AR") es-ar-resources))
Get your internationalized resources
(with-locale (locale "es" "AR")
(with-resources tree
(println (_ :hi "Rich") (_ "bye"))))
That would print "hola Rich" and "chau". :hi key is get from es-ar-resources bundle, "bye" key is get from the parent bundle es-resources.
There is and will be more to clji18n. To be documented...
Add [clji18n "0.1.1"] to your project.clj
Copyright (C) 2010 Sebastián Galkin
Distributed under the Eclipse Public License, the same as Clojure.