From: msweet Date: Mon, 12 Aug 2013 19:49:44 +0000 (+0000) Subject: Localize HTTP status codes based on Accept-Lanaguage () X-Git-Tag: v2.2b1~867 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=41e6c1f1fdc13479cc65bb64e9ae7924c35ca08f;p=thirdparty%2Fcups.git Localize HTTP status codes based on Accept-Lanaguage () git-svn-id: svn+ssh://src.apple.com/svn/cups/cups.org/trunk@11233 a1ca3aef-8c08-0410-bb20-df032aa958be --- diff --git a/cups/http-private.h b/cups/http-private.h index d0ea961a01..016dfe2ba7 100644 --- a/cups/http-private.h +++ b/cups/http-private.h @@ -23,6 +23,7 @@ */ # include "config.h" +# include # include # include @@ -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); diff --git a/cups/http-support.c b/cups/http-support.c index 1aa4a16348..bec39d0f4d 100644 --- a/cups/http-support.c +++ b/cups/http-support.c @@ -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)); } diff --git a/scheduler/client.c b/scheduler/client.c index 01d620f60e..f07a491d33 100644 --- a/scheduler/client.c +++ b/scheduler/client.c @@ -2579,7 +2579,8 @@ cupsdSendError(cupsd_client_t *con, /* I - Connection */ "

%s

\n" "\n" "\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);