123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365(**************************************************************************)(* ocaml-gettext: a library to translate messages *)(* *)(* Copyright (C) 2003-2008 Sylvain Le Gall <sylvain@le-gall.net> *)(* *)(* This library is free software; you can redistribute it and/or *)(* modify it under the terms of the GNU Lesser General Public *)(* License as published by the Free Software Foundation; either *)(* version 2.1 of the License, or (at your option) any later version; *)(* with the OCaml static compilation exception. *)(* *)(* 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. *)(* *)(* You should have received a copy of the GNU Lesser General Public *)(* License along with this library; if not, write to the Free Software *)(* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *)(* USA *)(**************************************************************************)(** Types and exception of ocaml-gettext.
@author Sylvain Le Gall
*)openGettextCategory(** {1 Core types of ocaml-gettext library} *)typerange=Int32.t*Int32.ttypetextdomain=stringtypelocale=stringtypedir=stringtypefilename=stringtypecodeset=string(** {1 Exceptions} *)exceptionCompileProblemReadingFileoffilename*string(** Filename wich generates the error message str
*)exceptionCompileExtractionFailedoffilename*string*int(** While extracting filename the command str returns exit code i.
*)exceptionCompileExtractionInterruptedoffilename*string*int(** While extracting filename the command receive signal i.
*)exceptionDomainFileDoesntExistoffilenamelist(** Cannot the filename corresponding to a textdomain among the specified files.
*)exceptionFormatInconsistentofstring*string(** The two strings returned doesn't have the same meaning regarding [Printf]
syntax.
*)exceptionGettextUninitialized(** A part of the code try to translate a string, but ocaml-gettext is not
initialized.
*)exceptionMoInvalidOptionsofLexing.lexbuf*string(** There is an invalid field in the content information of a MO file.
*)exceptionMoInvalidPluralsofLexing.lexbuf*string(** The plural-form field is not correct.
*)exceptionMoInvalidContentTypeofLexing.lexbuf*string(** The content-type field is not correct.
*)exceptionMoInvalidTranslationSingularofstring*int(** A plural translation of a singular string has occured.
*)exceptionMoInvalidTranslationPluralofstringlist*int(** An out-of-bound plural translation has occured.
*)exceptionMoJunkofstring*stringlist(** There is more plural translation than the number of plural forms.
*)exceptionMoEmptyEntry(**
*)exceptionMoInvalidFile(** A MO corrupted file has been read.
*)exceptionMoInvalidHeaderNegativeStrings(** The MO file specified a negative number of strings.
*)exceptionMoInvalidHeaderTableStringOutOfBoundofrange*range(** Offset of the string table is out of bound.
*)exceptionMoInvalidHeaderTableTranslationOutOfBoundofrange*range(** Offset of the translation table is out of bound.
*)exceptionMoInvalidHeaderTableTranslationStringOverlapofrange*range(** String and translation table overlap.
*)exceptionMoInvalidStringOutOfBoundofint*int(** The offset and length of a string entry leads to an access beyond the end
of the MO file.
*)exceptionMoInvalidTranslationOutOfBoundofint*int(** The offset and length of a translation entry leads to an access beyond the end
of the MO file.
*)exceptionMoCannotOpenFileofstring(** An error occured when trying to open a MO file.
*)exceptionPoInvalidFileofstring*Lexing.lexbuf*in_channel(** A PO file cannot be parsed.
*)exceptionPoFileInvalidIndexofstring*int(** When parsing a PO file, found an out of order table indices in a plural
form.
*)exceptionPoFileDoesntExistofstring(** The PO file doesn't exist.
*)exceptionPoInconsistentMergeofstring*string(** Cannot merge two PO files.
*)exceptionTranslateStringNotFoundofstring(** A string to translate cannot be found.
*)exceptionLocalePosixUnparseableofstring(** Cannot parse the POSIX representation of the locale.
*)(** {1 Modules signatures} *)typedependencies=(textdomain*codesetoption*diroption)listmoduletypeINIT_TYPE=sigvaltextdomain:textdomainvalcodeset:codesetoptionvaldir:diroptionvaldependencies:dependenciesend(* We stop documentation here, for the gettext API reference, all those types
are internals : use at your own risk.
*)(**/**)(** {1 Extended core types} *)moduleMapString=Map.Make(String)moduleSetString=Set.Make(String)moduleMapTextdomain=Map.Make(structtypet=textdomainletcompare=String.compareend)(** Defines behavior regarding exception in the ocaml-gettext library
*)typefailsafe=Ignore|InformStderrof(exn->string)|RaiseExceptiontypet={failsafe:failsafe;textdomains:(codesetoption*diroption)MapTextdomain.t;categories:localeMapCategory.t;language:localeoption;codeset:codeset;path:dirlist;default:textdomain;}(** Data structure handling initialization variable of ocaml-gettext
*)typet'=bool->textdomainoption->string->(string*int)option->category->string(** Function to translate effectively a string
*)(** {1 Types for MO file processing} *)(** Endianess of a MO file
*)typeendianess=BigEndian|LittleEndiantypemo_header={endianess:endianess;file_format_revision:int32;number_of_strings:int32;offset_table_strings:int32;offset_table_translation:int32;size_of_hashing_table:int32;offset_of_hashing_table:int32;}(** Specification of .MO file
@see <http://www.gnu.org/software/gettext/manual/html_mono/gettext.html#SEC136> GNU Gettext documentation.
Format of MO file :
byte
+------------------------------------------+
0 | magic number = 0x950412de |
| |
4 | file format revision = 0 |
| |
8 | number of strings | == N
| |
12 | offset of table with original strings | == O
| |
16 | offset of table with translation strings | == T
| |
20 | size of hashing table | == S
| |
24 | offset of hashing table | == H
| |
. .
. (possibly more entries later) .
. .
| |
O | length & offset 0th string ----------------.
O + 8 | length & offset 1st string ------------------.
... ... | |
O + ((N-1)*8)| length & offset (N-1)th string | | |
| | | |
T | length & offset 0th translation ---------------.
T + 8 | length & offset 1st translation -----------------.
... ... | | | |
T + ((N-1)*8)| length & offset (N-1)th translation | | | | |
| | | | | |
H | start hash table | | | | |
... ... | | | |
H + S * 4 | end hash table | | | | |
| | | | | |
| NUL terminated 0th string <----------------' | | |
| | | | |
| NUL terminated 1st string <------------------' | |
| | | |
... ... | |
| | | |
| NUL terminated 0th translation <---------------' |
| | |
| NUL terminated 1st translation <-----------------'
| |
... ...
| |
+------------------------------------------+
*)typemo_translation={project_id_version:stringoption;report_msgid_bugs_to:stringoption;pot_creation_date:stringoption;po_revision_date:stringoption;last_translator:stringoption;language_tream:stringoption;mime_version:stringoption;content_type:stringoption;content_transfer_encoding:stringoption;plural_forms:stringoption;(* The only interesting fields *)(* Those field are precomputed for regular use *)content_type_charset:string;nplurals:int;fun_plural_forms:int->int;}(** Details associated with ""
Project-Id-Version: PACKAGE VERSION\n
Report-Msgid-Bugs-To: \n
POT-Creation-Date: 2004-05-31 16:53+0200\n
PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n
Last-Translator: FULL NAME <EMAIL@ADDRESS>\n
Language-Team: LANGUAGE <LL@li.org>\n
MIME-Version: 1.0\n
Content-Type: text/plain; charset=CHARSET\n
Content-Transfer-Encoding: 8bit\n
Plural-Forms: specific ( 0 is false and 1 is
true
*)(** Base type of MO content : translation of string. The first string members are
the string identifier ( singular form ).
*)typetranslation=|Singularofstring*string|Pluralofstring*string*stringlist(** Types for the PO processing. The main difference with the type translation
comes from the necessity of keeping a maximum of comment.
*)typepo_translation=|PoSingularofstringlist*stringlist|PoPluralofstringlist*stringlist*stringlistlisttypepo_filepos=filename*int(** PO string localizator : represents in which file/lineno a string can be
found.
*)typepo_special=string(** PO keyword: represents special keyword like fuzzy, wrap, c-format...
*)typepo_commented_translation={po_comment_special:po_speciallist;po_comment_filepos:po_fileposlist;po_comment_translation:po_translation;}typepo_translations=po_commented_translationMapString.t(** Mapping of PO content using the string identifier as the key.
*)typepo_content={no_domain:po_translations;domain:po_translationsMapTextdomain.t;}(** Content of a PO file. Since comments should be saved, and that we only save
comments before and in message translation, we need to keep trace of the
last comments, which is not attached to any translation.
*)(** {1 Modules signatures} *)(** Signature for module handling transformation of initialization parameters
to concrete translation function.
*)moduletypeREALIZE_TYPE=sigvalrealize:t->t'end