let add_textdomain_category t map_translate textdomain category =
try
let filename =
GettextDomain.find
t
(fst (Locale.get_locale t category))
category
textdomain
in
let in_enc =
let chn =
open_in_bin filename
in
let mo_header = GettextMo.input_mo_header chn
in
let mo_informations = GettextMo.input_mo_informations t.failsafe chn mo_header
in
close_in chn;
mo_informations.content_type_charset
in
let out_enc =
try
match (MapTextdomain.find textdomain t.textdomains) with
(Some codeset, _) -> codeset
| (None, _) -> snd (Locale.get_locale t category)
with Not_found ->
snd (Locale.get_locale t category)
in
let recode =
Charset.recode (Charset.create t in_enc out_enc)
in
MapTranslate.add
(textdomain,category)
(Translate.create t filename recode)
map_translate
with DomainFileDoesntExist(filenames) as exc ->
map_translate