package gettext
Internationalization library (i18n)
Install
Dune Dependency
Authors
Maintainers
Sources
gettext-v0.4.2.tbz
sha256=8b672c7c521b8ac753c6a90925243cdd367dd5202e7c1e5d1a2507b11ad5d6a7
sha512=72bad53ce15ccc5113e4cfdc76b56c633926bb3702623964e006a99d21a758e7d47f0b9b67bebffe8b9a0c5f4d018cb7d4ae665568dfab52070ed355d5f9d31b
doc/src/gettext.base/gettextFormat.ml.html
Source file gettextFormat.ml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
(**************************************************************************) (* 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 *) (**************************************************************************) (** Check string equivalence regarding printf use. @author Sylvain Le Gall *) open GettextTypes open GettextUtils (** [check_format failsafe translation] Returns a translation structure if all the string contained in the translation are equivalent of str_id, regarding printf format. If not, replace each string which conflict by str_id, in the result. *) let check_format failsafe translation = let format_lst_of_string str = let lexbuf = Lexing.from_string str in GettextFormat_parser.main GettextFormat_lexer.token lexbuf in (* return true in case of problem *) let check_format_lst_lst lst1 lst2 = let check_format_lst_lst_aux b s1 s2 = b || String.compare s1 s2 <> 0 in try List.fold_left2 check_format_lst_lst_aux false lst1 lst2 with Invalid_argument _ -> true in let check_format_lst_str lst str = check_format_lst_lst lst (format_lst_of_string str) in let choose_format lst_ref str_ref str = if check_format_lst_str lst_ref str then fail_or_continue failsafe (FormatInconsistent (str, str_ref)) str_ref else str in match translation with | Singular (str_id, str) -> let lst_id = format_lst_of_string str_id in Singular (str_id, choose_format lst_id str_id str) | Plural (str_id, str_plural, lst) -> let lst_id = format_lst_of_string str_id in let valid_str_plural = choose_format lst_id str_id str_plural in let valid_lst = match lst with | trans_singular :: trans_plurals -> choose_format lst_id str_id trans_singular :: List.map (choose_format lst_id valid_str_plural) trans_plurals | [] -> [] in Plural (str_id, valid_str_plural, valid_lst)
sectionYPositions = computeSectionYPositions($el), 10)"
x-init="setTimeout(() => sectionYPositions = computeSectionYPositions($el), 10)"
>