64 |
}; |
}; |
65 |
|
|
66 |
struct loaded_domain_s { |
struct loaded_domain_s { |
67 |
|
/* Full file name to the MO file */ |
68 |
char *file_name; |
char *file_name; |
69 |
|
/* Last modification date of the MO file */ |
70 |
time_t modify_time; |
time_t modify_time; |
71 |
|
|
72 |
char *data; |
char *data; |
73 |
int must_swap; |
int must_swap; |
74 |
DWORD nstrings; |
DWORD nstrings; |
175 |
} while (to_read > 0); |
} while (to_read > 0); |
176 |
fclose (fp); |
fclose (fp); |
177 |
|
|
178 |
/* Using the magic number we can test whether it really is a message |
/* Using the magic number we can test whether it really is a message catalog file. */ |
|
* catalog file. */ |
|
179 |
if (data->magic != MAGIC && data->magic != MAGIC_SWAPPED) { |
if (data->magic != MAGIC && data->magic != MAGIC_SWAPPED) { |
180 |
/* The magic number is wrong: not a message catalog file. */ |
/* The magic number is wrong: not a message catalog file. */ |
181 |
free (data); |
free (data); |
231 |
size_t pos = strlen (buf); |
size_t pos = strlen (buf); |
232 |
while (pos > 0 && buf[--pos] != '\\') |
while (pos > 0 && buf[--pos] != '\\') |
233 |
; |
; |
234 |
buf[pos+1] = '\0'; |
buf[pos + 1] = '\0'; |
235 |
return buf; |
return buf; |
236 |
} |
} |
237 |
|
|
243 |
get_locale_name (const char *file) |
get_locale_name (const char *file) |
244 |
{ |
{ |
245 |
const char *lang = gettext_get_langid (); |
const char *lang = gettext_get_langid (); |
246 |
char *name, *ext; |
char buf[MAX_PATH+1]; |
|
char *p, buf[MAX_PATH+1]; |
|
247 |
|
|
248 |
p = strrchr (file, '.'); |
char *p = strrchr (file, '.'); |
249 |
if (p == NULL) { |
if (p == NULL) { |
250 |
p = new char[strlen(file)+strlen(lang)+2+1]; |
p = new char[strlen(file)+strlen(lang)+2+1]; |
251 |
sprintf (p, "%s.%s", file, lang); |
sprintf (p, "%s.%s", file, lang); |
252 |
return p; |
return p; |
253 |
} |
} |
254 |
name = substr (file, 0, p - file); |
char *name = substr (file, 0, p - file); |
255 |
ext = substr (file, p - file + 1, strlen(file)); |
char *ext = substr (file, p - file + 1, strlen(file)); |
256 |
p = get_module_dir (buf, MAX_PATH); |
p = get_module_dir (buf, MAX_PATH); |
257 |
if (!p) |
if (!p) |
258 |
BUG (NULL); |
BUG (NULL); |
319 |
|
|
320 |
/* Try to load the user domain, either from |
/* Try to load the user domain, either from |
321 |
the WinPT.exe directory or from the registry */ |
the WinPT.exe directory or from the registry */ |
322 |
int |
void |
323 |
gettext_set_user_domain (void) |
gettext_set_user_domain (void) |
324 |
{ |
{ |
325 |
if (!gettext_is_required ()) |
if (!gettext_is_required ()) |
326 |
return 0; |
return; |
327 |
|
|
328 |
gettext_domain_t domain = NULL; |
gettext_domain_t domain = NULL; |
329 |
char *file = get_locale_name ("winpt.mo"); |
char *file = get_locale_name ("winpt.mo"); |
333 |
domain = load_modir_domain (); |
domain = load_modir_domain (); |
334 |
free_if_alloc (file); |
free_if_alloc (file); |
335 |
gettext_update_domain (domain); |
gettext_update_domain (domain); |
|
return 0; |
|
336 |
} |
} |
337 |
|
|
338 |
|
|