summaryrefslogtreecommitdiff
path: root/fluid/code.cxx
diff options
context:
space:
mode:
authorMichael R Sweet <michael.r.sweet@gmail.com>2000-04-24 18:22:50 +0000
committerMichael R Sweet <michael.r.sweet@gmail.com>2000-04-24 18:22:50 +0000
commit8ff6d1daf49861b28bafc9e905ff9dcd910653be (patch)
tree34d788d13090ec2ac8a586af3e443de928ad37f1 /fluid/code.cxx
parentcd914369a657d7806dfd86b1fe7e3535f43d779b (diff)
FLUID changes to support GNU gettext and POSIX catgets under FLTK 1.0;
will work on changes for 2.0 later this week... (please let me know what you think...) git-svn-id: file:///fltk/svn/fltk/branches/branch-1.0@1082 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'fluid/code.cxx')
-rw-r--r--fluid/code.cxx91
1 files changed, 88 insertions, 3 deletions
diff --git a/fluid/code.cxx b/fluid/code.cxx
index 6503e02c9..d1ffcde91 100644
--- a/fluid/code.cxx
+++ b/fluid/code.cxx
@@ -1,5 +1,5 @@
//
-// "$Id: code.cxx,v 1.9.2.3 2000/02/25 03:44:21 mike Exp $"
+// "$Id: code.cxx,v 1.9.2.4 2000/04/24 18:22:50 mike Exp $"
//
// Code output routines for the Fast Light Tool Kit (FLTK).
//
@@ -35,6 +35,12 @@
static FILE *code_file;
static FILE *header_file;
+int msgnum;
+extern int i18n_type;
+extern const char* i18n_include;
+extern const char* i18n_function;
+extern const char* i18n_file;
+extern const char* i18n_set;
// return true if c can be in a C identifier. I needed this so
// it is not messed up by locale settings:
@@ -279,9 +285,18 @@ int write_code(const char *s, const char *t) {
}
write_declare("#include <FL/Fl.H>");
-
+ if (i18n_type && i18n_include_input->value()[0]) {
+ if (i18n_include_input->value()[0] != '<' &&
+ i18n_include_input->value()[0] != '\"')
+ write_c("#include \"%s\"\n", i18n_include_input->value());
+ else
+ write_c("#include %s\n", i18n_include_input->value());
+ if (i18n_type == 2)
+ write_c("extern nl_catd %s;\n", i18n_file_input->value());
+ }
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();
@@ -302,6 +317,76 @@ int write_code(const char *s, const char *t) {
return x >= 0 && y >= 0;
}
+int write_strings(const char *sfile) {
+ FILE *fp = fopen(sfile, "w");
+ Fl_Type *p;
+
+ if (!fp) return 1;
+
+ switch (i18n_type) {
+ case 0 : /* None, just put static text out */
+ fprintf(fp, "# generated by Fast Light User Interface Designer (fluid) version %.4f\n",
+ FL_VERSION);
+ for (p = Fl_Type::first; p; p = p->next) {
+ if (p->is_widget() && p->label() && !((Fl_Widget_Type *)p)->image) {
+ for (const char *s = p->label(); *s; s ++)
+ if (*s < 32 || *s > 126 || *s == '\"')
+ fprintf(fp, "\\%03o", *s);
+ else
+ putc(*s, fp);
+ putc('\n', fp);
+ }
+ }
+ break;
+ case 1 : /* GNU gettext, put a .po file out */
+ fprintf(fp, "# generated by Fast Light User Interface Designer (fluid) version %.4f\n",
+ FL_VERSION);
+ for (p = Fl_Type::first; p; p = p->next) {
+ if (p->is_widget() && p->label() && !((Fl_Widget_Type *)p)->image) {
+ const char *s;
+
+ fputs("msgid \"", fp);
+ for (s = p->label(); *s; s ++)
+ if (*s < 32 || *s > 126 || *s == '\"')
+ fprintf(fp, "\\%03o", *s);
+ else
+ putc(*s, fp);
+ fputs("\"\n", fp);
+
+ fputs("msgstr \"", fp);
+ for (s = p->label(); *s; s ++)
+ if (*s < 32 || *s > 126 || *s == '\"')
+ fprintf(fp, "\\%03o", *s);
+ else
+ putc(*s, fp);
+ fputs("\"\n", fp);
+ }
+ }
+ 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_input->value());
+ fputs("$quote \"\n", fp);
+
+ for (p = Fl_Type::first; p; p = p->next) {
+ if (p->is_widget() && p->label() && !((Fl_Widget_Type *)p)->image) {
+ fprintf(fp, "%d \"", msgnum ++);
+ for (const char *s = p->label(); *s; s ++)
+ if (*s < 32 || *s > 126 || *s == '\"')
+ fprintf(fp, "\\%03o", *s);
+ else
+ putc(*s, fp);
+ fputs("\"\n", fp);
+ }
+ }
+ break;
+ }
+
+ return fclose(fp);
+}
+
////////////////////////////////////////////////////////////////
void Fl_Type::write_static() {}
@@ -312,5 +397,5 @@ void Fl_Type::write_code1() {
void Fl_Type::write_code2() {}
//
-// End of "$Id: code.cxx,v 1.9.2.3 2000/02/25 03:44:21 mike Exp $".
+// End of "$Id: code.cxx,v 1.9.2.4 2000/04/24 18:22:50 mike Exp $".
//