Skip to content

Commit 102f036

Browse files
I18n and l10n support (FR and ES) (#57)
Add a first set of translations for French and Spanish
1 parent 2bc0340 commit 102f036

File tree

7 files changed

+489
-67
lines changed

7 files changed

+489
-67
lines changed

MANIFEST.in

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
include README
22
include LICENSE
33
include CHANGES.*
4+
recursive-include sphinxcontrib *.pot *.po *.mo

sphinxcontrib/httpdomain.py

Lines changed: 73 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
"""
1111

1212
import re
13+
import os
1314

1415
from docutils import nodes
1516

@@ -26,7 +27,8 @@
2627
from sphinx.util.nodes import make_refnode
2728
from sphinx.util.docfields import GroupedField, TypedField
2829
from sphinx.util.docutils import Reporter, LoggingReporter
29-
from sphinx.locale import _
30+
from sphinx.locale import get_translation
31+
_ = get_translation('httpdomain')
3032

3133
logger = logging.getLogger(__name__)
3234

@@ -186,59 +188,59 @@ def __init__(self, name, type):
186188

187189

188190
HTTP_STATUS_CODES = {
189-
100: 'Continue',
190-
101: 'Switching Protocols',
191-
102: 'Processing',
192-
200: 'OK',
193-
201: 'Created',
194-
202: 'Accepted',
195-
203: 'Non Authoritative Information',
196-
204: 'No Content',
197-
205: 'Reset Content',
198-
206: 'Partial Content',
199-
207: 'Multi Status',
200-
226: 'IM Used', # see RFC 3229
201-
300: 'Multiple Choices',
202-
301: 'Moved Permanently',
203-
302: 'Found',
204-
303: 'See Other',
205-
304: 'Not Modified',
206-
305: 'Use Proxy',
207-
307: 'Temporary Redirect',
208-
400: 'Bad Request',
209-
401: 'Unauthorized',
210-
402: 'Payment Required', # unused
211-
403: 'Forbidden',
212-
404: 'Not Found',
213-
405: 'Method Not Allowed',
214-
406: 'Not Acceptable',
215-
407: 'Proxy Authentication Required',
216-
408: 'Request Timeout',
217-
409: 'Conflict',
218-
410: 'Gone',
219-
411: 'Length Required',
220-
412: 'Precondition Failed',
221-
413: 'Request Entity Too Large',
222-
414: 'Request URI Too Long',
223-
415: 'Unsupported Media Type',
224-
416: 'Requested Range Not Satisfiable',
225-
417: 'Expectation Failed',
226-
418: "I'm a teapot", # see RFC 2324
227-
422: 'Unprocessable Entity',
228-
423: 'Locked',
229-
424: 'Failed Dependency',
230-
426: 'Upgrade Required',
231-
429: 'Too Many Requests',
232-
449: 'Retry With', # proprietary MS extension
233-
451: 'Unavailable For Legal Reasons',
234-
500: 'Internal Server Error',
235-
501: 'Not Implemented',
236-
502: 'Bad Gateway',
237-
503: 'Service Unavailable',
238-
504: 'Gateway Timeout',
239-
505: 'HTTP Version Not Supported',
240-
507: 'Insufficient Storage',
241-
510: 'Not Extended'
191+
100: _('Continue'),
192+
101: _('Switching Protocols'),
193+
102: _('Processing'),
194+
200: _('OK'),
195+
201: _('Created'),
196+
202: _('Accepted'),
197+
203: _('Non Authoritative Information'),
198+
204: _('No Content'),
199+
205: _('Reset Content'),
200+
206: _('Partial Content'),
201+
207: _('Multi Status'),
202+
226: _('IM Used'), # see RFC 3229
203+
300: _('Multiple Choices'),
204+
301: _('Moved Permanently'),
205+
302: _('Found'),
206+
303: _('See Other'),
207+
304: _('Not Modified'),
208+
305: _('Use Proxy'),
209+
307: _('Temporary Redirect'),
210+
400: _('Bad Request'),
211+
401: _('Unauthorized'),
212+
402: _('Payment Required'), # unused
213+
403: _('Forbidden'),
214+
404: _('Not Found'),
215+
405: _('Method Not Allowed'),
216+
406: _('Not Acceptable'),
217+
407: _('Proxy Authentication Required'),
218+
408: _('Request Timeout'),
219+
409: _('Conflict'),
220+
410: _('Gone'),
221+
411: _('Length Required'),
222+
412: _('Precondition Failed'),
223+
413: _('Request Entity Too Large'),
224+
414: _('Request URI Too Long'),
225+
415: _('Unsupported Media Type'),
226+
416: _('Requested Range Not Satisfiable'),
227+
417: _('Expectation Failed'),
228+
418: _("I'm a teapot"), # see RFC 2324
229+
422: _('Unprocessable Entity'),
230+
423: _('Locked'),
231+
424: _('Failed Dependency'),
232+
426: _('Upgrade Required'),
233+
429: _('Too Many Requests'),
234+
449: _('Retry With'), # proprietary MS extension
235+
451: _('Unavailable For Legal Reasons'),
236+
500: _('Internal Server Error'),
237+
501: _('Not Implemented'),
238+
502: _('Bad Gateway'),
239+
503: _('Service Unavailable'),
240+
504: _('Gateway Timeout'),
241+
505: _('HTTP Version Not Supported'),
242+
507: _('Insufficient Storage'),
243+
510: _('Not Extended')
242244
}
243245

244246
WEBDAV_STATUS_CODES = [207, 422, 423, 424, 507]
@@ -266,36 +268,36 @@ def http_resource_anchor(method, path):
266268
class HTTPResource(ObjectDescription):
267269

268270
doc_field_types = [
269-
TypedField('parameter', label='Parameters',
271+
TypedField('parameter', label=_('Parameters'),
270272
names=('param', 'parameter', 'arg', 'argument'),
271273
typenames=('paramtype', 'type')),
272-
TypedField('jsonparameter', label='JSON Parameters',
274+
TypedField('jsonparameter', label=_('JSON Parameters'),
273275
names=('jsonparameter', 'jsonparam', 'json'),
274276
typenames=('jsonparamtype', 'jsontype')),
275-
TypedField('requestjsonobject', label='Request JSON Object',
277+
TypedField('requestjsonobject', label=_('Request JSON Object'),
276278
names=('reqjsonobj', 'reqjson', '<jsonobj', '<json'),
277279
typenames=('reqjsonobj', '<jsonobj')),
278-
TypedField('requestjsonarray', label='Request JSON Array of Objects',
280+
TypedField('requestjsonarray', label=_('Request JSON Array of Objects'),
279281
names=('reqjsonarr', '<jsonarr'),
280282
typenames=('reqjsonarrtype', '<jsonarrtype')),
281-
TypedField('responsejsonobject', label='Response JSON Object',
283+
TypedField('responsejsonobject', label=_('Response JSON Object'),
282284
names=('resjsonobj', 'resjson', '>jsonobj', '>json'),
283285
typenames=('resjsonobj', '>jsonobj')),
284-
TypedField('responsejsonarray', label='Response JSON Array of Objects',
286+
TypedField('responsejsonarray', label=_('Response JSON Array of Objects'),
285287
names=('resjsonarr', '>jsonarr'),
286288
typenames=('resjsonarrtype', '>jsonarrtype')),
287-
TypedField('queryparameter', label='Query Parameters',
289+
TypedField('queryparameter', label=_('Query Parameters'),
288290
names=('queryparameter', 'queryparam', 'qparam', 'query'),
289291
typenames=('queryparamtype', 'querytype', 'qtype')),
290-
GroupedField('formparameter', label='Form Parameters',
292+
GroupedField('formparameter', label=_('Form Parameters'),
291293
names=('formparameter', 'formparam', 'fparam', 'form')),
292-
GroupedField('requestheader', label='Request Headers',
294+
GroupedField('requestheader', label=_('Request Headers'),
293295
rolename='header',
294296
names=('<header', 'reqheader', 'requestheader')),
295-
GroupedField('responseheader', label='Response Headers',
297+
GroupedField('responseheader', label=_('Response Headers'),
296298
rolename='header',
297299
names=('>header', 'resheader', 'responseheader')),
298-
GroupedField('statuscode', label='Status Codes',
300+
GroupedField('statuscode', label=_('Status Codes'),
299301
rolename='statuscode',
300302
names=('statuscode', 'status', 'code'))
301303
]
@@ -531,7 +533,7 @@ def result_nodes(self, document, env, node, is_ref):
531533
class HTTPIndex(Index):
532534

533535
name = 'routingtable'
534-
localname = 'HTTP Routing Table'
536+
localname = _('HTTP Routing Table')
535537
shortname = 'routing table'
536538

537539
def __init__(self, *args, **kwargs):
@@ -798,13 +800,17 @@ def setup(app):
798800
app.add_domain(HTTPDomain)
799801
app.connect('doctree-read', register_routingtable_as_label)
800802

803+
package_dir = os.path.abspath(os.path.dirname(__file__))
804+
locale_dir = os.path.join(package_dir, 'locale')
805+
app.add_message_catalog('httpdomain', locale_dir)
806+
801807
try:
802808
get_lexer_by_name('http')
803809
except ClassNotFound:
804810
app.add_lexer('http', HTTPLexer())
805811
app.add_config_value('http_index_ignore_prefixes', [], None)
806812
app.add_config_value('http_index_shortname', 'routing table', True)
807-
app.add_config_value('http_index_localname', 'HTTP Routing Table', True)
813+
app.add_config_value('http_index_localname', _('HTTP Routing Table'), True)
808814
app.add_config_value('http_strict_mode', True, None)
809815
app.add_config_value('http_headers_ignore_prefixes', ['X-'], None)
810816
return {"parallel_read_safe": True,
1.13 KB
Binary file not shown.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Spanish (Spain) translations for PROJECT.
2+
# Copyright (C) 2022 ORGANIZATION
3+
# This file is distributed under the same license as the PROJECT project.
4+
# FIRST AUTHOR <EMAIL@ADDRESS>, 2022.
5+
#
6+
msgid ""
7+
msgstr ""
8+
"Project-Id-Version: PROJECT VERSION\n"
9+
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
10+
"POT-Creation-Date: 2022-04-19 11:04+0200\n"
11+
"PO-Revision-Date: 2022-04-25 10:40+0200\n"
12+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13+
"Language: es_ES\n"
14+
"Language-Team: es_ES <LL@li.org>\n"
15+
"Plural-Forms: nplurals=2; plural=(n != 1)\n"
16+
"MIME-Version: 1.0\n"
17+
"Content-Type: text/plain; charset=utf-8\n"
18+
"Content-Transfer-Encoding: 8bit\n"
19+
"Generated-By: Babel 2.9.1\n"
20+
21+
#: sphinxcontrib/httpdomain.py:271
22+
msgid "Parameters"
23+
msgstr "Parámetros"
24+
25+
#: sphinxcontrib/httpdomain.py:274
26+
msgid "JSON Parameters"
27+
msgstr "Parámetros JSON"
28+
29+
#: sphinxcontrib/httpdomain.py:277
30+
msgid "Request JSON Object"
31+
msgstr "Objeto JSON de solicitud"
32+
33+
#: sphinxcontrib/httpdomain.py:280
34+
msgid "Request JSON Array of Objects"
35+
msgstr "Lista de objetos JSON de solicitud"
36+
37+
#: sphinxcontrib/httpdomain.py:283
38+
msgid "Response JSON Object"
39+
msgstr "Objeto JSON de respuesta"
40+
41+
#: sphinxcontrib/httpdomain.py:286
42+
msgid "Response JSON Array of Objects"
43+
msgstr "Lista de objetos JSON de respuesta"
44+
45+
#: sphinxcontrib/httpdomain.py:289
46+
msgid "Query Parameters"
47+
msgstr "Parámetros de consulta"
48+
49+
#: sphinxcontrib/httpdomain.py:292
50+
msgid "Form Parameters"
51+
msgstr "Parámetros de Forma"
52+
53+
#: sphinxcontrib/httpdomain.py:294
54+
msgid "Request Headers"
55+
msgstr "Encabezados de solicitud"
56+
57+
#: sphinxcontrib/httpdomain.py:297
58+
msgid "Response Headers"
59+
msgstr "Encabezados de respuesta"
60+
61+
#: sphinxcontrib/httpdomain.py:300
62+
msgid "Status Codes"
63+
msgstr "Códigos de Status"
64+
65+
#: sphinxcontrib/httpdomain.py:794
66+
msgid "HTTP Routing Table"
67+
msgstr "Tabla de enrutamiento HTTP"
68+
1.12 KB
Binary file not shown.
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# French (France) translations for PROJECT.
2+
# Copyright (C) 2022 ORGANIZATION
3+
# This file is distributed under the same license as the PROJECT project.
4+
# FIRST AUTHOR <EMAIL@ADDRESS>, 2022.
5+
#
6+
msgid ""
7+
msgstr ""
8+
"Project-Id-Version: PROJECT VERSION\n"
9+
"Report-Msgid-Bugs-To: EMAIL@ADDRESS\n"
10+
"POT-Creation-Date: 2022-04-19 11:04+0200\n"
11+
"PO-Revision-Date: 2022-04-25 10:40+0200\n"
12+
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
13+
"Language: fr_FR\n"
14+
"Language-Team: fr_FR <LL@li.org>\n"
15+
"Plural-Forms: nplurals=2; plural=(n > 1)\n"
16+
"MIME-Version: 1.0\n"
17+
"Content-Type: text/plain; charset=utf-8\n"
18+
"Content-Transfer-Encoding: 8bit\n"
19+
"Generated-By: Babel 2.9.1\n"
20+
21+
#: sphinxcontrib/httpdomain.py:271
22+
msgid "Parameters"
23+
msgstr "Paramètres"
24+
25+
#: sphinxcontrib/httpdomain.py:274
26+
msgid "JSON Parameters"
27+
msgstr "Paramètre JSON"
28+
29+
#: sphinxcontrib/httpdomain.py:277
30+
msgid "Request JSON Object"
31+
msgstr "Objet JSON de requête"
32+
33+
#: sphinxcontrib/httpdomain.py:280
34+
msgid "Request JSON Array of Objects"
35+
msgstr "Tableau d'objets JSON de requête"
36+
37+
#: sphinxcontrib/httpdomain.py:283
38+
msgid "Response JSON Object"
39+
msgstr "Objet JSON de réponse"
40+
41+
#: sphinxcontrib/httpdomain.py:286
42+
msgid "Response JSON Array of Objects"
43+
msgstr "Tableau d'objets JSON de réponse"
44+
45+
#: sphinxcontrib/httpdomain.py:289
46+
msgid "Query Parameters"
47+
msgstr "Paramètres de requête"
48+
49+
#: sphinxcontrib/httpdomain.py:292
50+
msgid "Form Parameters"
51+
msgstr "Paramètres de la forme"
52+
53+
#: sphinxcontrib/httpdomain.py:294
54+
msgid "Request Headers"
55+
msgstr "En-têtes de requête"
56+
57+
#: sphinxcontrib/httpdomain.py:297
58+
msgid "Response Headers"
59+
msgstr "En-têtes de réponse"
60+
61+
#: sphinxcontrib/httpdomain.py:300
62+
msgid "Codes de status"
63+
msgstr "Códigos de Status"
64+
65+
#: sphinxcontrib/httpdomain.py:794
66+
msgid "HTTP Routing Table"
67+
msgstr "Table de routage HTTP"
68+

0 commit comments

Comments
 (0)