cl-i18n is a gettext-style internationalization framework for Common Lisp.

cage 6109f3d5a2 - using web issue tracker. 1 month ago
doc 104a4fc4bb -[feature] Loading of Gettext MO files added; 6 years ago
examples e24d64d750 - [feature] add find-locale function. 3 years ago
CHANGELOG 9204bf4be9 - File format of the translation table changed; 6 years ago
COPYING f7c8616d8f - Native format file for dictionary changed again (now save the plural function too); 6 years ago
COPYING.LESSER f7c8616d8f - Native format file for dictionary changed again (now save the plural function too); 6 years ago
LICENSE 5d9a56c590 - added missing license information. 6 years ago
README.org 6109f3d5a2 - using web issue tracker. 1 month ago
base.lisp 195e5ad7b2 - exported a function to get the reference of the translation table. 2 years ago
buffered-input-file.lisp f3fb44cb55 - Rewritten an improved all the routines to extract strings that need to be translated; 2 years ago
cl-i18n.asd f07d007bbf - fixed email; 3 months ago
conditions.lisp afce479131 - package conditions renamed to i18n-conditions; 6 years ago
extraction-translatable-strings.lisp f3fb44cb55 - Rewritten an improved all the routines to extract strings that need to be translated; 2 years ago
function-name.lisp 87044c0ac3 - [fix] added missed function-name.lisp. 6 years ago
i18n-utils.lisp f3fb44cb55 - Rewritten an improved all the routines to extract strings that need to be translated; 2 years ago
mofile.lisp 114acd0b5c - PO file parsing optimized; 6 years ago
package.lisp 195e5ad7b2 - exported a function to get the reference of the translation table. 2 years ago
parser.lisp f3fb44cb55 - Rewritten an improved all the routines to extract strings that need to be translated; 2 years ago
plural-forms.lisp 8635fa3dee - [feature] added a minimal support for gettext po file format; 6 years ago
pofile.lisp f3fb44cb55 - Rewritten an improved all the routines to extract strings that need to be translated; 2 years ago
translation-class.lisp 650c708ee1 Switching from osicat to uiop 4 years ago
utils.lisp e24d64d750 - [feature] add find-locale function. 3 years ago
utx-file.lisp f3fb44cb55 - Rewritten an improved all the routines to extract strings that need to be translated; 2 years ago

README.org

http://quickdocs.org/badge/cl-i18n.svg

Prerequisites:

  • ASDF
  • uiop (if your ASDF version is < 3)
  • cl-ppcre
  • alexandria
  • babel

Installation:

The best way to get cl-i18n working is using the excellent quicklisp


(ql:quickload "cl-i18n")

Usage

    This library can load translations from file formats of the following types:
  • GNU gettext text file (AKA PO files);
  • GNU gettext binary file (AKA MO files);
  • its native file formats (essentially a Common lisp S-exp).

Check the examples/ directory for an usage example.

Extracting translatable strings:


(cl-i18n-utils:gen-translation-file "/src/" "klingon.lisp"
                                    :ext "lisp$"
                                    :prefix-re "#!\"")

Will extract all #! strings1 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 #!"Blood and honour!")))

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.

Locating GNU message catalog files

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).

Simple example

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..."))

Old version incompatibility

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

Bugs and issues

Please file bug report on the issue tracker.

Known issues

  • Documentation is missing;
  • Source code is mostly undocumented;
  • PO file parser is slow.

License

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.

    Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
  1. Redistributions of source code must retain the above copyright
  2. notice, this list of conditions and the following disclaimer.
  3. Redistributions in binary form must reproduce the above copyright
  4. notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  5. The names of the authors and contributors may not be used to endorse
  6. or promote products derived from this software without specific prior written permission.

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.

NO WARRANTY

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.

Contributors:

  • Leslie P. Polzer (base)
  • Vilson Vieira (string extractor)
  • Cage (developer and maintainer)

2 If you use a function like:


  (defun _ (a) (translate a))

You can use \\(_\\p{white_space}+\" as :prefix-re argument.


  1. DEFINITION NOT FOUND
  2. DEFINITION NOT FOUND