mirror of
https://github.com/fltk/fltk.git
synced 2026-06-05 16:12:13 +08:00
I18N didn't work right for menus - the messages numbers were wrong.
Added new "msgnum()" method to Fl_Type to handle computing the message number on the fly. Now initialize nl_catd and locale settings directly in the static variables so that menu labels are correctly looked up. This hack shouldn't be necessary in 2.0... git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1124 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
+15
-9
@@ -1,9 +1,9 @@
|
||||
//
|
||||
// "$Id: code.cxx,v 1.9.2.5 2000/04/25 01:57:51 mike Exp $"
|
||||
// "$Id: code.cxx,v 1.9.2.6 2000/05/16 12:26:06 mike Exp $"
|
||||
//
|
||||
// Code output routines for the Fast Light Tool Kit (FLTK).
|
||||
//
|
||||
// Copyright 1998-1999 by Bill Spitzak and others.
|
||||
// Copyright 1998-2000 by Bill Spitzak and others.
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Library General Public
|
||||
@@ -35,7 +35,8 @@
|
||||
|
||||
static FILE *code_file;
|
||||
static FILE *header_file;
|
||||
int msgnum;
|
||||
|
||||
extern char i18n_program[];
|
||||
extern int i18n_type;
|
||||
extern const char* i18n_include;
|
||||
extern const char* i18n_function;
|
||||
@@ -293,12 +294,17 @@ int write_code(const char *s, const char *t) {
|
||||
write_c("#include %s\n", i18n_include);
|
||||
if (i18n_type == 2) {
|
||||
if (i18n_file[0]) write_c("extern nl_catd %s;\n", i18n_file);
|
||||
else write_c("static nl_catd _catalog = (nl_catd)-1;\n");
|
||||
else {
|
||||
write_c("// Initialize I18N stuff now for menus...\n");
|
||||
write_c("#include <locale.h>\n");
|
||||
write_c("static char *_locale = setlocale(LC_MESSAGES, \"\");\n");
|
||||
write_c("static nl_catd _catalog = catopen(\"%s\", 0);\n",
|
||||
i18n_program);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (t && include_H_from_C)
|
||||
write_c("#include \"%s\"\n", filename_name(t));
|
||||
msgnum = 1;
|
||||
for (Fl_Type* p = Fl_Type::first; p;) {
|
||||
// write all static data for this & all children first
|
||||
p->write_static();
|
||||
@@ -322,6 +328,7 @@ int write_code(const char *s, const char *t) {
|
||||
int write_strings(const char *sfile) {
|
||||
FILE *fp = fopen(sfile, "w");
|
||||
Fl_Type *p;
|
||||
int i;
|
||||
|
||||
if (!fp) return 1;
|
||||
|
||||
@@ -366,15 +373,14 @@ int write_strings(const char *sfile) {
|
||||
}
|
||||
break;
|
||||
case 2 : /* POSIX catgets, put a .msg file out */
|
||||
msgnum = 1;
|
||||
fprintf(fp, "$ generated by Fast Light User Interface Designer (fluid) version %.4f\n",
|
||||
FL_VERSION);
|
||||
fprintf(fp, "$set %s\n", i18n_set);
|
||||
fputs("$quote \"\n", fp);
|
||||
|
||||
for (p = Fl_Type::first; p; p = p->next) {
|
||||
for (i = 1, p = Fl_Type::first; p; p = p->next) {
|
||||
if (p->is_widget() && p->label() && !((Fl_Widget_Type *)p)->image) {
|
||||
fprintf(fp, "%d \"", msgnum ++);
|
||||
fprintf(fp, "%d \"", i ++);
|
||||
for (const char *s = p->label(); *s; s ++)
|
||||
if (*s < 32 || *s > 126 || *s == '\"')
|
||||
fprintf(fp, "\\%03o", *s);
|
||||
@@ -399,5 +405,5 @@ void Fl_Type::write_code1() {
|
||||
void Fl_Type::write_code2() {}
|
||||
|
||||
//
|
||||
// End of "$Id: code.cxx,v 1.9.2.5 2000/04/25 01:57:51 mike Exp $".
|
||||
// End of "$Id: code.cxx,v 1.9.2.6 2000/05/16 12:26:06 mike Exp $".
|
||||
//
|
||||
|
||||
Reference in New Issue
Block a user