let find t languages category textdomain =
let search_path =
(
try
match MapTextdomain.find textdomain t.textdomains with
(_,Some dir) -> [dir]
| (_,None) -> []
with Not_found ->
[]
) @ t.path
in
let ctest = test (And(Exists,Is_readable))
in
let rec find_mo_file_aux dir languages =
match languages with
language :: tl ->
let current_filename = make_filename dir language category textdomain
in
if ctest current_filename then
current_filename
else
find_mo_file_aux dir tl
| [] ->
raise Not_found
in
let rec find_mo_file path languages =
match path with
dir :: tl ->
(
try
find_mo_file_aux dir languages
with Not_found ->
find_mo_file tl languages
)
| [] ->
raise Not_found
in
try
find_mo_file search_path languages
with Not_found ->
raise (DomainFileDoesntExist(
List.flatten (
List.map (
fun dir ->
List.map (
fun language ->
make_filename dir language category textdomain
) languages
) search_path
)
)
)