1
(**************************************************************************)
2
(* ocaml-gettext: a library to translate messages *)
4
(* Copyright (C) 2003-2008 Sylvain Le Gall <sylvain@le-gall.net> *)
6
(* This library is free software; you can redistribute it and/or *)
7
(* modify it under the terms of the GNU Lesser General Public *)
8
(* License as published by the Free Software Foundation; either *)
9
(* version 2.1 of the License, or (at your option) any later version; *)
10
(* with the OCaml static compilation exception. *)
12
(* This library is distributed in the hope that it will be useful, *)
13
(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)
14
(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *)
15
(* Lesser General Public License for more details. *)
17
(* You should have received a copy of the GNU Lesser General Public *)
18
(* License along with this library; if not, write to the Free Software *)
19
(* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 *)
21
(**************************************************************************)
23
(** Signature of module for domain management.
24
@author Sylvain Le Gall
28
open FilePath.DefaultPath;;
30
open FileUtil.StrUtil;;
33
open GettextCategory;;
35
(* BUG : a mettre � jour *)
36
(** compute_path textdomain category t : return the path to the
37
mo file corresponding to textdomain and category. Language is
38
guessed from category binding. If the textdomain is not found,
39
it tries to use the build default to find the file. The file
40
returned exists and is readable. If such a file doesn't exists
41
an exception DomainFileDoesntExist is thrown. If the function is
42
unable to guess the current language an exception
43
DomainLanguageNotSet is thrown.
46
let make_filename dir language category textdomain =
47
(* http://www.gnu.org/software/gettext/manual/html_mono/gettext.html#SEC148
48
dir_name/locale/LC_category/domain_name.mo *)
50
(* BUG : should use add_extension *)
51
dir; language; string_of_category category; textdomain ^ ".mo"
56
let find t languages category textdomain =
60
match MapTextdomain.find textdomain t.textdomains with
67
let ctest = test (And(Exists,Is_readable))
69
let rec find_mo_file_aux dir languages =
72
let current_filename = make_filename dir language category textdomain
74
if ctest current_filename then
77
find_mo_file_aux dir tl
81
let rec find_mo_file path languages =
86
find_mo_file_aux dir languages
88
find_mo_file tl languages
94
find_mo_file search_path languages
96
raise (DomainFileDoesntExist(
102
make_filename dir language category textdomain