* remove linewrap
authorWilfried Göesgens <willi@citadel.org>
Sun, 22 Feb 2009 11:12:02 +0000 (11:12 +0000)
committerWilfried Göesgens <willi@citadel.org>
Sun, 22 Feb 2009 11:12:02 +0000 (11:12 +0000)
+ add I18N Dumpmode; with -G we will parse all templates, and output all i18n strings in a c-like syntax into the given file.

webcit/static/t/iconbar.html
webcit/subst.c
webcit/webserver.c

index 21cff7b84b3623f6c929af7afbf4f074c10f9c73..d048d4a4f62dc82a2f93273d5f65a25f47db5c53 100644 (file)
@@ -43,8 +43,7 @@
 </a>
 </li>
 <li id="ib_users" class="ib_button">
-<a class="ib_button_link" href="do_template?template=who" title="<?_("See who is online right
-now")>"><span>
+<a class="ib_button_link" href="do_template?template=who" title="<?_("See who is online right now")>"><span>
 <?_("Online users")>
 </span>
 </a>
index 3231c931e086dfd5157eaf35f6b95b107ef81612..c4abfc890612b69b1700e01ce77bb1d3531b85e8 100644 (file)
@@ -32,9 +32,11 @@ HashList *Iterators;
 HashList *Conditionals;
 HashList *SortHash;
 
+int DumpTemplateI18NStrings = 0;
 int LoadTemplates = 0;
 int dbg_bactrace_template_errors = 0;
 WCTemplputParams NoCtx;
+StrBuf *I18nDump = NULL;
 
 #define SV_GETTEXT 1
 #define SV_CONDITIONAL 2
@@ -1138,6 +1140,9 @@ TemplateParam *GetNextParameter(StrBuf *Buf, const char **pCh, const char *pe, W
               (*pch == ',' )||
               (*pch == '\n')) pch ++;
 
+       if (DumpTemplateI18NStrings && (Parm->Type == TYPE_GETTEXT)) {
+               StrBufAppendPrintf(I18nDump, "_(\"%s\");\n", Parm->Start);
+       }
        *pCh = pch;
        return Parm;
 }
@@ -1250,6 +1255,9 @@ WCTemplateToken *NewTemplateSubstitute(StrBuf *Buf,
                        NewToken->Flags = 0;
                        break;
                }
+               if (DumpTemplateI18NStrings) {
+                       StrBufAppendPrintf(I18nDump, "_(\"%s\");\n", NewToken->Params[0]->Start);
+               }
                break;
        case SV_SUBTEMPL:
                if (NewToken->nParameters != 1) {
index b89035870b009d1373fce419961e8ed6c0d5d120..2227d7fbab8896934515c42f53d7cda8660e9065 100644 (file)
@@ -612,6 +612,8 @@ const char *nix(void *vptr) {snprintf(foobuf, 32, "%0x", (long) vptr); return fo
 #endif 
 extern int dbg_analyze_msg;
 extern int dbg_bactrace_template_errors;
+extern int DumpTemplateI18NStrings;
+extern StrBuf *I18nDump;
 void InitTemplateCache(void);
 extern int LoadTemplates;
 extern void LoadZoneFiles(void);
@@ -640,6 +642,7 @@ int main(int argc, char **argv)
        char *mo = NULL;
 #endif /* ENABLE_NLS */
        char uds_listen_path[PATH_MAX]; /* listen on a unix domain socket? */
+       const char *I18nDumpFile;
 
        WildFireInitBacktrace(argv[0], 2);
 
@@ -675,9 +678,9 @@ int main(int argc, char **argv)
 
        /* Parse command line */
 #ifdef HAVE_OPENSSL
-       while ((a = getopt(argc, argv, "h:i:p:t:T:x:dD:cfsZ")) != EOF)
+       while ((a = getopt(argc, argv, "h:i:p:t:T:x:dD:G:cfsZ")) != EOF)
 #else
-       while ((a = getopt(argc, argv, "h:i:p:t:T:x:dD:cfZ")) != EOF)
+       while ((a = getopt(argc, argv, "h:i:p:t:T:x:dD:G:cfZ")) != EOF)
 #endif
                switch (a) {
                case 'h':
@@ -746,12 +749,17 @@ int main(int argc, char **argv)
                case 's':
                        is_https = 1;
                        break;
+               case 'G':
+                       DumpTemplateI18NStrings = 1;
+                       I18nDump = NewStrBufPlain(HKEY("int foo(void)\n{\n"));
+                       I18nDumpFile = optarg;
+                       break;
                default:
                        fprintf(stderr, "usage: webcit "
                                "[-i ip_addr] [-p http_port] "
                                "[-t tracefile] [-c] [-f] "
                                "[-T Templatedebuglevel] "
-                               "[-d] [-Z] "
+                               "[-d] [-Z] [-G i18ndumpfile] "
 #ifdef HAVE_OPENSSL
                                "[-s] "
 #endif
@@ -766,7 +774,7 @@ int main(int argc, char **argv)
        }
 
        /* daemonize, if we were asked to */
-       if (running_as_daemon) {
+       if (!DumpTemplateI18NStrings && running_as_daemon) {
                start_daemon(pidfile);
        }
        else {
@@ -842,6 +850,18 @@ int main(int argc, char **argv)
        initialize_axdefs();
 
        InitTemplateCache();
+       if (DumpTemplateI18NStrings) {
+               FILE *fd;
+               StrBufAppendBufPlain(I18nDump, HKEY("}\n"), 0);
+               fd = fopen(I18nDumpFile, "w");
+               if (fd == NULL) {
+                       lprintf(1, "unable to open I18N dumpfile [%s]\n", I18nDumpFile);
+                       return -1;
+               }
+               fwrite(ChrPtr(I18nDump), 1, StrLength(I18nDump), fd);
+               fclose(fd);
+               return 0;
+       }
 
        if (!access("static.local/webcit.css", R_OK)) {
                csslocal = NewStrBufPlain(HKEY("<link href=\"static.local/webcit.css\" rel=\"stylesheet\" type=\"text/css\">"));