cl-i18n is a gettext-style internationalization framework for Common Lisp.
cage a802f1eb74 - updated changelog and NEWS.org. | 1 år sedan | |
---|---|---|
doc | 12 år sedan | |
examples | 9 år sedan | |
COPYING | 12 år sedan | |
COPYING.LESSER | 12 år sedan | |
Changelog | 1 år sedan | |
LICENSE | 13 år sedan | |
NEWS.org | 1 år sedan | |
README.org | 1 år sedan | |
README.txt | 1 år sedan | |
base.lisp | 5 år sedan | |
buffered-input-file.lisp | 5 år sedan | |
cl-i18n.asd | 1 år sedan | |
conditions.lisp | 5 år sedan | |
extraction-translatable-strings.lisp | 8 år sedan | |
function-name.lisp | 12 år sedan | |
fuzzy-matching.lisp | 1 år sedan | |
i18n-utils.lisp | 5 år sedan | |
mofile.lisp | 5 år sedan | |
package.lisp | 3 år sedan | |
parser.lisp | 8 år sedan | |
plural-forms.lisp | 5 år sedan | |
pofile.lisp | 8 år sedan | |
test.lisp | 1 år sedan | |
translation-class.lisp | 5 år sedan | |
utils.lisp | 5 år sedan | |
utx-file.lisp | 8 år sedan |
http://quickdocs.org/badge/cl-i18n.svg
The best way to get cl-i18n working is using the excellent quicklisp
(ql:quickload "cl-i18n")
Check the examples/
directory for an usage example.
;; define two convenience functions
(defun _ (a) (cl-i18n:translate a))
(defun n_ (s f n) (cl-i18n:ntranslate s f n))
(cl-i18n-utils:gen-translation-file "/src/" "klingon.lisp"
:ext "lisp$"
:prefix-re "\\(_\\s+")
(cl-i18n-utils:gen-translation-file "/src/" "klingon.lisp"
:ext "lisp$"
:prefix-re "\\(n_\\s+")
Will extract all (_…
strings from all the
files in directory /src
which name ends in "lisp" and set up a
basic translation resource in klingon.lisp (Note: the output file
if exists will be overwritten).
To make it work with CL-WHO, use the “str” directive, as in
(with-html-output *out*
(:p (str (_ "Peace and love!"))))
Please note that the library can accept gettext MO or PO files so nothing prevents you using GNU xgettext to extracts strings that needs to be translated and use its output as translation file.
According to GNU gettext manual the path to the catalog is system dipendent, the function search-mo-repository will try to figure out where that catalog could be; but its implementation is slow, memory consuming and sometimes fails (i.e. crash).
Here is a way similar to GNU gettext style API; please note we are
assuming /usr/share/locale/
as the path where the catalog can be
found and foo.mo is there.
We also let the library guess the right locale with find-locale
.
(let ((*translation-file-root* "/usr/share/locale/"))
(load-language "foo" :locale (find-locale))
(format t "~a~%" (_ "Browse"))
(format t "~a~%" (_ "Save as...")))
During the development of this library I have implemented a couple of string functions that I think could be useful beyond i18n.
This version deeply changed the file format of the translation table, however you can convert from the old format to the new one with:
(cl-i18n-utils:convert-save-dictionary oldfile-path new-filepath)
Note: the output file if exists will be overwritten
Please file bug report on the issue tracker.
This library is released under Lisp Lesser General Public license (see COPYING.LESSER file)
Examples are released under GPL version 3 or later
doc/internals/pofiles_grammar
is © 2012 cage and is licensed under
Creative Commons Attribution-ShareAlike 3.0 Unported
File function-name.lisp was got from cl-store © 2004 Sean Ross and included here with the original license stated below.
Copyright (c) 2004 Sean Ross All rights reserved.
THIS SOFTWARE IS PROVIDED BY THE AUTHORS AND CONTRIBUTORS ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.