]> git.ipfire.org Git - thirdparty/cups.git/commitdiff
Localize HTTP status codes based on Accept-Lanaguage (<rdar://problem/14201195>)
authormsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Mon, 12 Aug 2013 19:49:44 +0000 (19:49 +0000)
committermsweet <msweet@a1ca3aef-8c08-0410-bb20-df032aa958be>
Mon, 12 Aug 2013 19:49:44 +0000 (19:49 +0000)
git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11233 a1ca3aef-8c08-0410-bb20-df032aa958be

cups/http-private.h
cups/http-support.c
scheduler/client.c

index d0ea961a014c50c781a9c291377e049fb7e1afd4..016dfe2ba756de6b74895eb8716aca2053e78bb4 100644 (file)
@@ -23,6 +23,7 @@
  */
 
 #  include "config.h"
+#  include <cups/language.h>
 #  include <stddef.h>
 #  include <stdlib.h>
 
@@ -422,6 +423,7 @@ extern const char   *_httpResolveURI(const char *uri, char *resolved_uri,
                                         size_t resolved_size, int options,
                                         int (*cb)(void *context),
                                         void *context);
+extern const char      *_httpStatus(cups_lang_t *lang, http_status_t status);
 extern int             _httpUpdate(http_t *http, http_status_t *status);
 extern int             _httpWait(http_t *http, int msec, int usessl);
 
index 1aa4a16348ada16dda5d7815abd7e84e34cf4a07..bec39d0f4dd7b48bb017bddac3f4340e6b2b798a 100644 (file)
@@ -35,6 +35,8 @@
  *                         components.
  *   httpSeparateURI()   - Separate a Universal Resource Identifier into its
  *                         components.
+ *   _httpStatus()        - Return the localized string describing a HTTP
+ *                          status code.
  *   httpStatus()        - Return a short string describing a HTTP status
  *                         code.
  *   _cups_hstrerror()   - hstrerror() emulation function for Solaris and
@@ -1322,21 +1324,17 @@ httpSeparateURI(
 
 
 /*
- * 'httpStatus()' - Return a short string describing a HTTP status code.
+ * '_httpStatus()' - Return the localized string describing a HTTP status code.
  *
- * The returned string is localized to the current POSIX locale and is based
- * on the status strings defined in RFC 2616.
+ * The returned string is localized using the passed message catalog.
  */
 
 const char *                           /* O - Localized status string */
-httpStatus(http_status_t status)       /* I - HTTP status code */
+_httpStatus(cups_lang_t   *lang,       /* I - Language */
+            http_status_t status)      /* I - HTTP status code */
 {
   const char   *s;                     /* Status string */
-  _cups_globals_t *cg = _cupsGlobals();        /* Global data */
-
 
-  if (!cg->lang_default)
-    cg->lang_default = cupsLangDefault();
 
   switch (status)
   {
@@ -1419,7 +1417,27 @@ httpStatus(http_status_t status) /* I - HTTP status code */
        break;
   }
 
-  return (_cupsLangString(cg->lang_default, s));
+  return (_cupsLangString(lang, s));
+}
+
+
+/*
+ * 'httpStatus()' - Return a short string describing a HTTP status code.
+ *
+ * The returned string is localized to the current POSIX locale and is based
+ * on the status strings defined in RFC 2616.
+ */
+
+const char *                           /* O - Localized status string */
+httpStatus(http_status_t status)       /* I - HTTP status code */
+{
+  _cups_globals_t *cg = _cupsGlobals();        /* Global data */
+
+
+  if (!cg->lang_default)
+    cg->lang_default = cupsLangDefault();
+
+  return (_httpStatus(cg->lang_default, status));
 }
 
 
index 01d620f60e34134dff3de3f3417406fe636eb169..f07a491d3379185d4a2d97acd43efb5b03d100b6 100644 (file)
@@ -2579,7 +2579,8 @@ cupsdSendError(cupsd_client_t *con,       /* I - Connection */
             "<P>%s</P>\n"
             "</BODY>\n"
             "</HTML>\n",
-            httpStatus(code), redirect, httpStatus(code), text);
+            _httpStatus(con->language, code), redirect,
+            _httpStatus(con->language, code), text);
 
     if (httpPrintf(HTTP(con), "Content-Type: text/html; charset=utf-8\r\n") < 0)
       return (0);