Common Lisp Package: CL-I18N

An internationalisation framework for Common Lisp

README:

FUNCTION

Public

INIT-TRANSLATION-TABLE (FILENAME &KEY (STORE-HASHTABLE T) (STORE-PLURAL-FUNCTION T) (UPDATE-TRANSLATION-TABLE T))

Load translations from a file (*translation-file-root* is used as a prefix for the actual path), storing them in a hash table. if store-hashtable is t *translation-table* is setf'd to the loaded table, if store-plural-function is t *plural-form-function* is setf'd too. The *plural-form-function* is setf'd too

LOAD-LANGUAGE (CATALOG &KEY (LOCALE *LOCALE*) (CATEGORIES *CATEGORIES*) (STORE-PLURAL-FUNCTION T) (STORE-HASHTABLE T) (UPDATE-TRANSLATION-TABLE T))

Load a language that will be used for all subsequent translations.

MAKE-TRANSLATION (TRANSLATION &OPTIONAL (FLAG +UNTRANSLATED-FLAG+) (PLURAL-FORM ) (PLURAL-TRANSLATED 'NIL))

Create an instance of a translation class

NTRANSLATE (STR1 STR2 N)

Translate a string guessing a plural form. str1 is the string to be translated str2 is the fallback plural form n is the number of the objects First str1 is checked to get the translated object, if found the nth element (as computed by the function *plural-form-function*) of its plural-translated slot is used as plural form. If this index is less than 0 or more than the length of plural-translated ntranslate return str2. If the translation object does not exists str2 is returned

SAVE-LANGUAGE (LANG &OPTIONAL (DESTINATION NIL) (TRANSLATION-TABLE NIL) (PLURAL-FUNCTION NIL))

Save a translation table to a file, default path is *translation-file-root* "/" lang

SLURP-FILE (FILENAME &KEY (CONVERT-TO-STRING T))

A simple way to slurp a file.

TRANSLATE (STR)

Translate a string. This will raise an error if the translation table has not been initialized beforehand. If the string doesn't have a translation a warning is emitted as well and the original string returned.

TRANSLATION-HASH-TABLE->LIST (HT)

Convert a translation table to a list with the format used to store the table in a file

USE-VALUE (VALUE &OPTIONAL CONDITION)

Transfer control and VALUE to a restart named USE-VALUE, or return NIL if none exists.

Undocumented

BRAZILIAN-PLURAL-FORM (N)

BULGARIAN-PLURAL-FORM (N)

CROATIAN-PLURAL-FORM (N)

CZECH-PLURAL-FORM (N)

DANISH-PLURAL-FORM (N)

DUTCH-PLURAL-FORM (N)

ENGLISH-PLURAL-FORM (N)

ESPERANTO-PLURAL-FORM (N)

ESTONIAN-PLURAL-FORM (N)

FAROESE-PLURAL-FORM (N)

FINNISH-PLURAL-FORM (N)

FRENCH-PLURAL-FORM (N)

GAEILGE-PLURAL-FORM (N)

GERMAN-PLURAL-FORM (N)

GREEK-PLURAL-FORM (N)

HEBREW-PLURAL-FORM (N)

HUNGARIAN-PLURAL-FORM (N)

IRISH-PLURAL-FORM (N)

ITALIAN-PLURAL-FORM (N)

LATVIAN-PLURAL-FORM (N)

LITHUANIAN-PLURAL-FORM (N)

N/=1-PLURAL-FORM (N)

NORWEGIAN-PLURAL-FORM (N)

PEEK-VALID-STREAM

POLISH-PLURAL-FORM (N)

PORTUGUESE-PLURAL-FORM (N)

RANDOM-STRING (STRINGS)

ROMANIAN-PLURAL-FORM (N)

RUSSIAN-PLURAL-FORM (N)

SERBIAN-PLURAL-FORM (N)

SLOVAK-PLURAL-FORM (N)

SLOVENIAN-PLURAL-FORM (N)

SPANISH-PLURAL-FORM (N)

SWEDISH-PLURAL-FORM (N)

TURKISH-PLURAL-FORM (N)

UKRAINIAN-PLURAL-FORM (N)

Private

READ-LISP-STRING (INPUT)

Parse a Lisp string. Expects "input" to point to the first character after the leading double quote. Slick version by Xach.

Undocumented

!= (&REST ARGS)

% (&REST ARGS)

&& (&REST ARGS)

1+CHAR@ (&KEY (GO-BACK T))

2BYTE->WORD (BYTE1 BYTE2)

2WORD->INT (WORD1 WORD2)

<* (&REST ARGS)

<=* (&REST ARGS)

== (&REST ARGS)

>* (&REST ARGS)

>=* (&REST ARGS)

BOOL-OR (&REST ARGS)

BUFFER-UCHAR-LENGTH (BUFFER)

BYTE->INT (BYTES)

CAT-PARENT-DIR (PARENT DIRENTRY)

CHAR@

CHAR@1+

COUNT-MO-FILES (ROOT)

COUNT-MO-FILES-DESCEND (ROOT)

COUNT-MO-FILES-DIRECT-CHILDREN (ROOT)

CREATE-BRAND-NEW-FILE (FILE)

EXCLUDED-PATH-P (DIR)

EXECUTE-EXPRESSION (STACK)

EXTRACT-PLURAL-FUNCTION (HEADER)

GET-FUNCTION-NAME (OBJ)

IS-!=-P (STR565)

IS-%-P (STR565)

IS-<-P (STR565)

IS-<=-P (STR565)

IS-==-P (STR565)

IS->-P (STR565)

IS->=-P (STR565)

IS-?-P (STR565)

IS-AND-OP-P (STR565)

IS-BINARY-OPERATOR (OP)

IS-BOOL-OP-P (STR)

IS-CLOSE-PAREN-P (STR565)

IS-COLON-P (STR565)

IS-END-EXPRESSION-P (STR565)

IS-FLAG-LINE-P (STR886)

IS-FUZZY-FLAG-P (STR565)

IS-MO-FILE-P (PATH &OPTIONAL (EXT mo))

IS-MSGID-PLURAL-P (STR886)

IS-MSGID-REGEXP-P (STR886)

IS-MSGSTR-REGEXP-P (STR886)

IS-MSGSTR[]-REGEXP-P (STR886)

IS-NUMBER-P (STR)

IS-OPEN-PAREN-P (STR565)

IS-OR-OP-P (STR565)

IS-TERNARY-OPERATOR (OP)

IS-VAR-P (STR565)

MAKE-BUFFER (&OPTIONAL (LENGTH +DEFAULT-BUFFER-SIZE+))

MO-REPOSITORY-P (DB)

PARSE-ANY-OPERATOR (OPER-LIST &KEY (TEST #'STRING=))

PARSE-ARITHMETIC-EXPRESSION (&OPTIONAL STACK)

PARSE-ARITHMETIC-OPERATOR

PARSE-BOOLEAN-EXPRESSION (&OPTIONAL (STACK 'NIL))

PARSE-BOOLEAN-OPERATOR

PARSE-CLOSE-PARENT

PARSE-COMPARISION-OPERATOR

PARSE-ENTRIES (&OPTIONAL (RES (MAKE-HASH-TABLE TEST 'EQUAL)))

PARSE-ESCAPED-STRING (&OPTIONAL (RES ) (DELIMC NIL))

PARSE-EXPRESSION

PARSE-HEADER

PARSE-IF-SYMBOL

PARSE-MSGID

PARSE-MSGID-GROUP

PARSE-MSGID-PLURAL

PARSE-MSGID-PLURAL-GROUP

PARSE-MSGSTR

PARSE-MSGSTR-GROUP

PARSE-MSGSTR-PLURAL

PARSE-MSGSTR-PLURAL-GROUP (&OPTIONAL (RES 'NIL))

PARSE-NAME (NAME)

PARSE-NUMBER

PARSE-OPEN-PARENT

PARSE-PLURAL-EXPRESSION

PARSE-PO-FILE

PARSE-TERNARY-EXPRESSION

PARSE-THEN-SYMBOL

PEEK-END-STREAM (&KEY (POS-OFFSET 0))

SCAN-MO-FILES (ROOT &OPTIONAL (DB 'NIL))

SEARCH-MO-REPOSITORY (ROOT)

SPLIT-ESCAPE (MSG)

STACK-IF (&REST ARGS)

STRING->FUNCTION (FUN)

UCHAR-LENGTH (LEADING-BYTE)

UNESCAPED-CHAR (CHAR)

UTF8-ENCODED-P (FILE)

MACRO

Public

WITH-TRANSLATION ((TRANSLATIONS PLURAL-FUNCTION) &BODY BODY)

Macro to switch between language at runtime

Undocumented

DEFINE-PARSER-SKELETON (NAME CLASSNAME &REST OTHER-VARS)

DEFINE-PLURAL-FORM ((LANG) &BODY BODY)

DEFINE-TOKENIZER ((CLASSNAME &REST REGEXPS) &BODY OTHER-COND-CLAUSE)

DEFNOCFUN (NAME ARGS &BODY BODY)

WITH-ERROR ((PREDICATE MSG &REST ARG-PREDICATE) &BODY BODY)

WITH-MO-FILE ((STREAM MOCLASS MOFILE) &REST BODY)

WITH-NO-ERRORS (&BODY BODY)

WITH-NO-ERRORS* (&BODY FORMS)

WITH-PO-FILE ((&KEY (BUFFER (MAKE-BUFFER 2)) (FILENAME NIL)) &REST BODY)

Private

Undocumented

DEFINE-IS-STUFF-P (TEST &REST OPERATORS)

DEFINE-PARSE-HEADER-CHUNK ((NAME SIZE &OPTIONAL (SLOT NAME)))

DEFINE-PARSE-OPERATORS (NAMES TEST &REST OPERATORS-LIST)

DO-DIRECTORY ((VAR) ROOT &BODY BODY)

IF-NOT-UTF8-READ-WHOLE ((FILENAME) &BODY BODY)

LET-NOERR (FORMS &BODY BODY)

LET-NOERR* (FORMS &BODY BODY)

MULTIPLE-INCREMENT (TIMES)

PARSE-TOKEN ((VAR PREDICATE MSG &REST PREDICATE-ARG) &BODY BODY)

POP-APPLY-BINARY-OPERATOR (STACK OPERATOR)

POP-APPLY-TERNARY-OPERATOR (STACK OPERATOR)

SCANNER-RE (RE)

WHEN-DEBUG (&BODY BODY)

WITH-FILE-POSITION ((VAR OBJECT) &BODY BODY)

WITH-LINE-MODE (&BODY BODY)

WITH-PARSE-STRINGS-CHUNKS ((STREAM START-OFFSET CHUNK-SIZE WHOLE-CHUNK-SIZE PARSE-LENGTH-FUN PARSE-OFFSET-FUNC) MOFILE)

WITH-USTRING ((VAR OBJECT) &BODY BODY)

WITH-VALID-STREAM (&BODY BODY)

GENERIC-FUNCTION

Public

Undocumented

GET-LINE (OBJECT &KEY LINE-SEPARATOR (LINE-SEPARATOR ))

IS-COMMENT-LINE-P (OBJECT LINE)

NEXT-TOKEN (OBJECT &KEY HOOK-TO-STRINGPOS (HOOK-TO-STRINGPOS T))

PARSE-COMMENT-LINE (OBJECT)

PEEK-TOKEN (OBJECT &OPTIONAL TEST)

PEEK-TOKEN-SUPPRESS-ERRORS (OBJECT &OPTIONAL TEST)

SEEK (OBJECT POS)

TRANSLATION-LIST->HASH-TABLE (SOURCE DEST)

Private

COPY-TRANSLATION (OBJECT OLD)

Copy an instance of translation class from old to object

Undocumented

ACTUAL-FILE-POSITION (OBJECT &OPTIONAL POS)

ADJUST-BUFFER (OBJECT)

ADJUST-BUFFER-BACKWARD (OBJECT)

CLOSE-FILE (OBJECT)

DECREMENT-POINTER (OBJECT)

ENLARGE-BUFFER (OBJECT)

GET-CHAR (OBJECT)

GET-CHAR-THEN-INCREMENT-POINTER (OBJECT)

INCREMENT-POINTER (OBJECT)

INCREMENT-POINTER-THEN-GET-CHAR (OBJECT)

INSIDE-BUFFER-P (OBJECT POS &KEY AS-CHAR (AS-CHAR NIL))

MOFILE->POFILE (OBJECT)

MOFILE->TRANSLATION (OBJECT &OPTIONAL ORIGINALS TRANSLATED PLURAL-FUNCTION TRANSLATIONS)

OUTSIDE-BUFFER-P (OBJECT POS)

PARSE-HASHING-TABLE-OFFSET (MOFILE STREAM)

PARSE-HASHING-TABLE-SIZE (MOFILE STREAM)

PARSE-MAGIC-NUMBER (OBJECT STREAM)

PARSE-MOFILE (OBJECT STREAM)

PARSE-OFFSET-ORIGINAL (MOFILE STREAM)

PARSE-OFFSET-TRANSLATIONS (MOFILE STREAM)

PARSE-ORIGINAL-STRING-LENGTH (MOFILE STREAM)

PARSE-ORIGINAL-STRING-OFFSET (MOFILE STREAM)

PARSE-ORIGINAL-STRINGS (OBJECT STREAM)

PARSE-STRING-NUMBER (MOFILE STREAM)

PARSE-TRANSLATED-STRING-LENGTH (MOFILE STREAM)

PARSE-TRANSLATED-STRING-OFFSET (MOFILE STREAM)

PARSE-TRANSLATED-STRINGS (OBJECT STREAM)

PARSE-VERSION-NUMBER (MOFILE STREAM)

READ-ADJUST-BUFFER (OBJECT)

REGEX-SCAN (OBJECT REGEX &OPTIONAL STICKY LAST-START LAST-END)

REGEX-SCAN-LINE-MODE (OBJECT REGEX &OPTIONAL STICKY LAST-START LAST-END)

REPLACE-BUFFER (OBJECT &KEY DIRECTION (DIRECTION FORWARD))

REPLACE-BUFFER-BACKWARD (OBJECT)

REPLACE-BUFFER-FORWARD (OBJECT)

STREAM-LENGTH (OBJECT)

TRUNCATE-BUFFER (OBJECT POS)

UNGET-CHAR (OBJECT &OPTIONAL POSITION)

VALID-STREAM-P (OBJECT)

SLOT-ACCESSOR

Public

FLAG (OBJECT)

The status of the translation, can be one of +fuzzy-flag+ +untranslated-flag+ or +translation+

SETFFLAG (NEW-VALUE OBJECT)

The status of the translation, can be one of +fuzzy-flag+ +untranslated-flag+ or +translation+

TRANSLATED (OBJECT)

The translated string

SETFTRANSLATED (NEW-VALUE OBJECT)

The translated string

Undocumented

COMMENT-LINE (OBJECT)

SETFCOMMENT-LINE (NEW-VALUE OBJECT)

Private

PLURAL-TRANSLATED (OBJECT)

a list of string for each valid plural form

SETFPLURAL-TRANSLATED (NEW-VALUE OBJECT)

a list of string for each valid plural form

Undocumented

BUFFER (OBJECT)

SETFBUFFER (NEW-VALUE OBJECT)

BUFFER-POSITION (OBJECT)

SETFBUFFER-POSITION (NEW-VALUE OBJECT)

CACHED-STRING (OBJECT)

SETFCACHED-STRING (NEW-VALUE OBJECT)

FILENAME (OBJECT)

SETFFILENAME (NEW-VALUE OBJECT)

HASHING-TABLE-OFFSET (OBJECT)

SETFHASHING-TABLE-OFFSET (NEW-VALUE OBJECT)

HASHING-TABLE-SIZE (OBJECT)

SETFHASHING-TABLE-SIZE (NEW-VALUE OBJECT)

INNER-STREAM (OBJECT)

SETFINNER-STREAM (NEW-VALUE OBJECT)

LINE-MODE (OBJECT)

SETFLINE-MODE (NEW-VALUE OBJECT)

LOGICAL-FILE-POSITION (OBJECT)

SETFLOGICAL-FILE-POSITION (NEW-VALUE OBJECT)

MAGIC-NUMBER (OBJECT)

SETFMAGIC-NUMBER (NEW-VALUE OBJECT)

MOFILE (OBJECT)

SETFMOFILE (NEW-VALUE OBJECT)

OFFSET-ORIGINAL (OBJECT)

SETFOFFSET-ORIGINAL (NEW-VALUE OBJECT)

OFFSET-TRANSLATIONS (OBJECT)

SETFOFFSET-TRANSLATIONS (NEW-VALUE OBJECT)

ORIGINAL-STRINGS (OBJECT)

SETFORIGINAL-STRINGS (NEW-VALUE OBJECT)

PARSING-ERRORS (OBJECT)

SETFPARSING-ERRORS (NEW-VALUE OBJECT)

PLURAL-FORM (OBJECT)

SETFPLURAL-FORM (NEW-VALUE OBJECT)

POFILE (OBJECT)

SETFPOFILE (NEW-VALUE OBJECT)

STATISTICS (OBJECT)

SETFSTATISTICS (NEW-VALUE OBJECT)

STRING-NUMBER (OBJECT)

SETFSTRING-NUMBER (NEW-VALUE OBJECT)

TRANSLATED-STRINGS (OBJECT)

SETFTRANSLATED-STRINGS (NEW-VALUE OBJECT)

UCHARS-COUNT (OBJECT)

SETFUCHARS-COUNT (NEW-VALUE OBJECT)

VERSION-NUMBER (OBJECT)

SETFVERSION-NUMBER (NEW-VALUE OBJECT)

VARIABLE

Public

*PLURAL-FORM-FUNCTION*

This is the function used by the library to figure out the right plural form

*TRANSLATION-FILE-ROOT*

The directory where translation files are stored. Defaults to current directory.

Undocumented

*DIRECTORY-SEP*

*DIRECTORY-SEP-REGEXP*

*FILE*

*HAS-ERRORS*

*PARSING-ERRORS*

*TRANSLATION-COLLECT*

Private

*TRANSLATION-TABLE*

The actual translation table used, it is an hashtable with the original (untranslated) string as key and an instance of the class translation as value

Undocumented

*ARITM-OP*

*BLANK-SPACE*

*BOOLEAN-OP*

*CATEGORIES*

*COMPAR-OP*

*DEBUG*

*LOCALE*

*MOFILE-REPO-EXCLUDE-PATH*

*N*

*SBCL-READTABLE*

*STRING-POS*

*VALID-DIR-AVERAGE-MOFILE-REPO*

*VALID-DIR-MOFILE-REPO*

*VALID-DIR-RATE-MOFILE-REPO*

*WELL-KNOWN-MOFILE-PATH*

CLASS

Public

TRANSLATION

The class that holds a translated string, its plural form and the translation status

Undocumented

PARSED-FILE

Private

Undocumented

BUFFERED-INPUT-FILE

MOFILE (OBJECT)

PO-PARSED-FILE

CONSTANT

Public

Undocumented

+FUZZY-FLAG+

+ID+

+PLURALS+

+PLURALS-FORM+

+STATUS+

+TRANSLATED-FLAG+

+TRANSLATION+

+UNTRANSLATED-FLAG+

Private

Undocumented

+!=+

+%+

+<+

+<=+

+==+

+>+

+>=+

+?+

+?-REGEX+

+AGNOSTIC-COMMENT+

+AND-OP+

+CLOSE-PAREN+

+CLOSE-PAREN-REGEX+

+COLON+

+DEFAULT-BUFFER-SIZE+

+DEFAULT-ELEMENT-TYPE+

+END-EXPRESSION+

+ESCAPE-NEWLINE+

+ESCAPE-STRING-ESCAPE-CHAR+

+ESCAPE-STRING-ESCAPED-NEWLINE+

+ESCAPED-STRING-DELIM+

+FLAG-FUZZY+

+FLAG-LINE+

+HASHING-TABLE-OFFSET-BYTE-SIZE+

+HASHING-TABLE-SIZE-BYTE-SIZE+

+LISP-TABLE-EXT+

+MO-MAGIC-NUMBER+

+MSGID+

+MSGID-PLURAL+

+MSGID-REGEXP+

+MSGSTR+

+MSGSTR-REGEXP+

+MSGSTR[]+

+MSGSTR[]-REGEXP+

+NEWLINE+

+NPLURALS-LABEL+

+NUMBER+

+OFFSET-ORIGINAL-BYTE-SIZE+

+OFFSET-TRANSLATION-BYTE-SIZE+

+OPEN-PAREN+

+OPEN-PAREN-REGEX+

+OR-OP+

+OR-OP-REGEX+

+ORIGINAL-STRINGS-LENGTH-CHUNK-SIZE+

+ORIGINAL-STRINGS-OFFSET-CHUNK-SIZE+

+ORIGINAL-STRINGS-OFFSET-SIZE-CHUNK-SIZE+

+PEEK-LENGTH-TOKENIZER-ON-ERROR+

+PLURAL-EXPRESSION-LABEL+

+PLURAL-FORM-LABEL+

+PO-COMMENT-LINE+

+POFILE-EXT+

+STREAM-ELEMENT-TYPE+

+STRING-NUM-BYTE-SIZE+

+STRING-NUM-BYTE-VERSION-NUMBER+

+TRANSLATED-STRINGS-LENGTH-CHUNK-SIZE+

+TRANSLATED-STRINGS-OFFSET-CHUNK-SIZE+

+TRANSLATED-STRINGS-OFFSET-SIZE-CHUNK-SIZE+

+UTX-EXT+

+VAR+