/*
- * "$Id: translate.c 4896 2006-01-08 03:57:45Z mike $"
+ * "$Id$"
*
- * HTTP-based translation program for the Common UNIX Printing System (CUPS).
+ * HTTP-based translation program for CUPS.
*
* This program uses Google to translate the CUPS template (cups.pot) to
* several different languages. The translation isn't perfect, but it's
* a start (better than working from scratch.)
*
+ * Copyright 2007-2010 by Apple Inc.
* Copyright 1997-2006 by Easy Software Products.
*
* These coded instructions, statements, and computer programs are the
- * property of Easy Software Products and are protected by Federal
- * copyright law. Distribution and use rights are outlined in the file
- * "LICENSE.txt" which should have been included with this file. If this
- * file is missing or damaged please contact Easy Software Products
- * at:
- *
- * Attn: CUPS Licensing Information
- * Easy Software Products
- * 44145 Airport View Drive, Suite 204
- * Hollywood, Maryland 20636 USA
- *
- * Voice: (301) 373-9600
- * EMail: cups-info@cups.org
- * WWW: http://www.cups.org
+ * property of Apple Inc. and are protected by Federal copyright
+ * law. Distribution and use rights are outlined in the file "LICENSE.txt"
+ * which should have been included with this file. If this file is
+ * file is missing or damaged, see the license at "http://www.cups.org/".
*
* Contents:
*
+ * main() - Main entry.
+ * save_messages() - Save messages to a .po file.
+ * translate_messages() - Translate messages using Google.
+ * write_string() - Write a quoted string to a file.
*/
/*
* Include necessary headers...
*/
-#include <cups/string.h>
-#include <cups/file.h>
-#include <cups/http.h>
-#include <cups/i18n.h>
-#include <stdlib.h>
+#include <cups/cups-private.h>
#include <unistd.h>
}
if (access(argv[1], 0))
- cat = _cupsMessageLoad("cups.pot");
+ cat = _cupsMessageLoad("cups.pot", 1);
else
- cat = _cupsMessageLoad(argv[1]);
+ cat = _cupsMessageLoad(argv[1], 1);
if (!cat)
{
*bufptr++ = '&';
*bufptr = '\0';
- sprintf(length, "%d", bufptr - buffer);
+ sprintf(length, "%d", (int)(bufptr - buffer));
/*
* Send the request...
httpPost(http, "/translate_t");
}
- httpWrite(http, buffer, bufptr - buffer);
+ httpWrite2(http, buffer, bufptr - buffer);
while ((status = httpUpdate(http)) == HTTP_CONTINUE);
bufptr = buffer;
bufend = buffer + sizeof(buffer) - 1;
- while ((bytes = httpRead(http, bufptr, bufend - bufptr)) > 0)
+ while ((bytes = httpRead2(http, bufptr, bufend - bufptr)) > 0)
bufptr += bytes;
if (bytes < 0)
*bufptr = '\0';
/*
- * Find the first textarea element - that will have the translation data...
+ * Find the div containing translation
*/
- if ((bufptr = strstr(buffer, "<textarea")) == NULL)
+ if ((bufptr = strstr(buffer, "<div id=result_box")) == NULL)
{
/*
* No textarea, abort!
*/
- puts("NO TEXTAREA!");
+ puts("NO div id=result_box!");
ret = 0;
break;
}
* textarea doesn't end, abort!
*/
- puts("TEXTAREA SHORT DATA!");
+ puts("DIV SHORT DATA!");
ret = 0;
break;
}
bufptr ++;
- if ((bufend = strstr(bufptr, "</textarea>")) == NULL)
+ if ((bufend = strstr(bufptr, "</div>")) == NULL)
{
/*
* textarea doesn't close, abort!
*/
- puts("/TEXTAREA SHORT DATA!");
+ puts("/DIV SHORT DATA!");
ret = 0;
break;
}
/*
- * End of "$Id: translate.c 4896 2006-01-08 03:57:45Z mike $".
+ * End of "$Id$".
*/