From efb8df7f2ca8b37a0f44a8744b8d31f396c007c9 Mon Sep 17 00:00:00 2001 From: Fei Long Wang Date: Sat, 22 Feb 2014 14:49:53 +0800 Subject: [PATCH] Document for API message localization This patch will add document about how to use the API message localization. Partially implements bp i18n-messages Change-Id: I389103574fc52feed96c592cbafbb52faccda939 --- doc/source/glanceapi.rst | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/doc/source/glanceapi.rst b/doc/source/glanceapi.rst index 26f9b42a10..c63bcfd23c 100644 --- a/doc/source/glanceapi.rst +++ b/doc/source/glanceapi.rst @@ -669,3 +669,43 @@ New API Calls where is one of ``pending``, ``accepted``, or ``rejected``. The {memberId} is the tenant ID of the image member. + + +API Message Localization +--------------------------------------- +Glance supports HTTP message localization. For example, an HTTP client can +receive API messages in Chinese even if the locale language of the server is +English. + +How to use it +************* +To receive localized API messages, the HTTP client needs to specify the +**Accept-Language** header to indicate the language to use to translate the +message. For more info about Accept-Language, please refer http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html + +A typical curl API request will be like below:: + + curl -i -X GET -H 'Accept-Language: zh' -H 'Content-Type: application/json' + http://127.0.0.1:9292/v2/images/aaa + +Then the response will be like the following:: + + HTTP/1.1 404 Not Found + Content-Length: 234 + Content-Type: text/html; charset=UTF-8 + X-Openstack-Request-Id: req-54d403a0-064e-4544-8faf-4aeef086f45a + Date: Sat, 22 Feb 2014 06:26:26 GMT + + + + 404 Not Found + + +

404 Not Found

+ 找不到任何具有标识 aaa 的映像

+ + + +.. note:: + Be sure there is the language package under /usr/share/locale-langpack/ on + the target Glance server.