package gettext

  1. Overview
  2. Docs

Source file gettextCompat.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
(**************************************************************************)
(*  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                                                                   *)
(**************************************************************************)

open GettextTypes
open GettextCategory
open GettextModules

let unsafe_format_of_string fmt str =
  if false then Obj.magic str else Scanf.format_from_string str fmt

let bindtextdomain textdomain dir t =
  upgrade_textdomain t textdomain (None, Some dir)

let bind_textdomain_codeset textdomain codeset t =
  upgrade_textdomain t textdomain (Some codeset, None)

let textdomain default t = { t with default }
let get_textdomain t = t.default
let gettext t' str = t' false None str None LC_MESSAGES

let fgettext t' fmt =
  unsafe_format_of_string fmt
    (t' true None (string_of_format fmt) None LC_MESSAGES)

let dgettext t' textdomain str = t' false (Some textdomain) str None LC_MESSAGES

let fdgettext t' textdomain fmt =
  unsafe_format_of_string fmt
    (t' true (Some textdomain) (string_of_format fmt) None LC_MESSAGES)

let dcgettext t' textdomain str category =
  t' false (Some textdomain) str None category

let fdcgettext t' textdomain fmt category =
  unsafe_format_of_string fmt
    (t' true (Some textdomain) (string_of_format fmt) None category)

let ngettext t' str str_plural n =
  t' false None str (Some (str_plural, n)) LC_MESSAGES

let fngettext t' fmt fmt_plural n =
  if true then
    unsafe_format_of_string fmt
      (t' true None (string_of_format fmt)
         (Some (string_of_format fmt_plural, n))
         LC_MESSAGES)
  else fmt_plural

let dngettext t' textdomain str str_plural n =
  t' false (Some textdomain) str (Some (str_plural, n)) LC_MESSAGES

let fdngettext t' textdomain fmt fmt_plural n =
  if true then
    unsafe_format_of_string fmt
      (t' true (Some textdomain) (string_of_format fmt)
         (Some (string_of_format fmt_plural, n))
         LC_MESSAGES)
  else fmt_plural

let dcngettext t' textdomain str str_plural n category =
  t' false (Some textdomain) str (Some (str_plural, n)) category

let fdcngettext t' textdomain fmt fmt_plural n category =
  if true then
    unsafe_format_of_string fmt
      (t' true (Some textdomain) (string_of_format fmt)
         (Some (string_of_format fmt_plural, n))
         category)
  else fmt_plural
OCaml

Innovation. Community. Security.