307 |
load_modir_domain (void) |
load_modir_domain (void) |
308 |
{ |
{ |
309 |
gettext_domain_t domain = NULL; |
gettext_domain_t domain = NULL; |
|
StringBuffer s; |
|
|
char *modir; |
|
310 |
|
|
311 |
modir = get_reg_entry_mo (); |
char *modir = get_reg_entry_mo (); |
312 |
if (!modir) |
if (!modir) |
313 |
return NULL; |
return NULL; |
314 |
if (dir_exist_check (modir)) { |
if (dir_exist_check (modir)) { |
315 |
free_if_alloc (modir); |
free_if_alloc (modir); |
316 |
return NULL; |
return NULL; |
317 |
} |
} |
318 |
s = modir; |
StringBuffer s = modir; |
319 |
if (modir[strlen (modir)-1] != '\\') |
if (modir[strlen (modir)-1] != '\\') |
320 |
s += "\\"; |
s += "\\"; |
321 |
s += "winpt.mo"; |
s += "winpt.mo"; |
322 |
|
|
323 |
const char *fname = s.getBuffer(); |
const char *fname = s.getBuffer(); |
324 |
if (!file_exist_check (fname)) |
if (!file_exist_check (fname)) |
325 |
domain = load_domain (fname); |
domain = load_domain (fname); |
399 |
domain->trans_tab[idx].offset); |
domain->trans_tab[idx].offset); |
400 |
if (!domain->mapped[idx]) |
if (!domain->mapped[idx]) |
401 |
domain->mapped[idx] = 1; |
domain->mapped[idx] = 1; |
402 |
return (const char*)p; |
return (const char *)p; |
403 |
} |
} |
404 |
|
|
405 |
|
|
406 |
const char * |
const char * |
407 |
gettext (const char *msgid) |
gettext (const char *msgid) |
408 |
{ |
{ |
|
gettext_domain_t domain; |
|
409 |
size_t act = 0; |
size_t act = 0; |
410 |
size_t top, bottom; |
size_t top, bottom; |
411 |
|
|
412 |
domain = the_domain; |
gettext_domain_t domain = the_domain; |
413 |
if (domain == NULL) |
if (domain == NULL) |
414 |
goto not_found; |
goto not_found; |
415 |
|
|
436 |
idx -= domain->hash_size - incr; |
idx -= domain->hash_size - incr; |
437 |
else |
else |
438 |
idx += incr; |
idx += incr; |
439 |
nstr = SWAPIT(domain->must_swap, domain->hash_tab[idx]); |
nstr = SWAPIT (domain->must_swap, domain->hash_tab[idx]); |
440 |
if (!nstr) |
if (!nstr) |
441 |
goto not_found; /* Hash table entry is empty. */ |
goto not_found; /* Hash table entry is empty. */ |
442 |
|
|
454 |
array of messages. */ |
array of messages. */ |
455 |
bottom = 0; |
bottom = 0; |
456 |
top = domain->nstrings; |
top = domain->nstrings; |
457 |
while (bottom < top) { |
while (bottom < top) { |
|
int cmp_val; |
|
|
|
|
458 |
act = (bottom + top) / 2; |
act = (bottom + top) / 2; |
459 |
cmp_val = strcmp (msgid, domain->data + SWAPIT(domain->must_swap, |
int cmp_val = strcmp (msgid, domain->data + SWAPIT(domain->must_swap, |
460 |
domain->orig_tab[act].offset)); |
domain->orig_tab[act].offset)); |
461 |
if (cmp_val < 0) |
if (cmp_val < 0) |
462 |
top = act; |
top = act; |
463 |
else if (cmp_val > 0) |
else if (cmp_val > 0) |
476 |
const char* |
const char* |
477 |
gettext_get_langid (void) |
gettext_get_langid (void) |
478 |
{ |
{ |
479 |
LANGID lang; |
LANGID lang = GetUserDefaultLangID (); |
|
|
|
|
lang = GetUserDefaultLangID (); |
|
480 |
if (PRIMARYLANGID (lang) == LANG_ENGLISH) |
if (PRIMARYLANGID (lang) == LANG_ENGLISH) |
481 |
return NULL; |
return NULL; |
482 |
|
|
491 |
/* Take a table with control item IDs and their translation |
/* Take a table with control item IDs and their translation |
492 |
and set each text to the translated value. */ |
and set each text to the translated value. */ |
493 |
void |
void |
494 |
gettext_localize_dialog (HWND dlg, struct gettext_tab_s *tab, |
gettext_localize_dialog (HWND dlg, struct gettext_tab_s *tab, const char *title) |
|
const char *title) |
|
495 |
{ |
{ |
496 |
for (int i=0; tab[i].trans != NULL; i++) |
for (int i=0; tab[i].trans != NULL; i++) |
497 |
SetDlgItemText (dlg, tab[i].ctlid, tab[i].trans); |
SetDlgItemText (dlg, tab[i].ctlid, tab[i].trans); |