Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commite1e8d89

Browse files
committed
Fix#85: remove localization of error messages.
It doesn't make sense to localize error messages, given they arepurely technical in content.
1 parentf1176e1 commite1e8d89

File tree

7 files changed

+184
-203
lines changed

7 files changed

+184
-203
lines changed

‎html5lib/constants.py

Lines changed: 153 additions & 155 deletions
Large diffs are not rendered by default.

‎html5lib/filters/lint.py

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
from __future__importabsolute_import,division,unicode_literals
22

3-
fromgettextimportgettext
4-
_=gettext
5-
63
from .import_base
74
from ..constantsimportcdataElements,rcdataElements,voidElements
85

@@ -23,24 +20,24 @@ def __iter__(self):
2320
iftypein ("StartTag","EmptyTag"):
2421
name=token["name"]
2522
ifcontentModelFlag!="PCDATA":
26-
raiseLintError(_("StartTag not in PCDATA content model flag: %(tag)s")% {"tag":name})
23+
raiseLintError("StartTag not in PCDATA content model flag: %(tag)s"% {"tag":name})
2724
ifnotisinstance(name,str):
28-
raiseLintError(_("Tag name is not a string: %(tag)r")% {"tag":name})
25+
raiseLintError("Tag name is not a string: %(tag)r"% {"tag":name})
2926
ifnotname:
30-
raiseLintError(_("Empty tag name"))
27+
raiseLintError("Empty tag name")
3128
iftype=="StartTag"andnameinvoidElements:
32-
raiseLintError(_("Void element reported as StartTag token: %(tag)s")% {"tag":name})
29+
raiseLintError("Void element reported as StartTag token: %(tag)s"% {"tag":name})
3330
eliftype=="EmptyTag"andnamenotinvoidElements:
34-
raiseLintError(_("Non-void element reported as EmptyTag token: %(tag)s")% {"tag":token["name"]})
31+
raiseLintError("Non-void element reported as EmptyTag token: %(tag)s"% {"tag":token["name"]})
3532
iftype=="StartTag":
3633
open_elements.append(name)
3734
forname,valueintoken["data"]:
3835
ifnotisinstance(name,str):
39-
raiseLintError(_("Attribute name is not a string: %(name)r")% {"name":name})
36+
raiseLintError("Attribute name is not a string: %(name)r"% {"name":name})
4037
ifnotname:
41-
raiseLintError(_("Empty attribute name"))
38+
raiseLintError("Empty attribute name")
4239
ifnotisinstance(value,str):
43-
raiseLintError(_("Attribute value is not a string: %(value)r")% {"value":value})
40+
raiseLintError("Attribute value is not a string: %(value)r"% {"value":value})
4441
ifnameincdataElements:
4542
contentModelFlag="CDATA"
4643
elifnameinrcdataElements:
@@ -51,43 +48,43 @@ def __iter__(self):
5148
eliftype=="EndTag":
5249
name=token["name"]
5350
ifnotisinstance(name,str):
54-
raiseLintError(_("Tag name is not a string: %(tag)r")% {"tag":name})
51+
raiseLintError("Tag name is not a string: %(tag)r"% {"tag":name})
5552
ifnotname:
56-
raiseLintError(_("Empty tag name"))
53+
raiseLintError("Empty tag name")
5754
ifnameinvoidElements:
58-
raiseLintError(_("Void element reported as EndTag token: %(tag)s")% {"tag":name})
55+
raiseLintError("Void element reported as EndTag token: %(tag)s"% {"tag":name})
5956
start_name=open_elements.pop()
6057
ifstart_name!=name:
61-
raiseLintError(_("EndTag (%(end)s) does not match StartTag (%(start)s)")% {"end":name,"start":start_name})
58+
raiseLintError("EndTag (%(end)s) does not match StartTag (%(start)s)"% {"end":name,"start":start_name})
6259
contentModelFlag="PCDATA"
6360

6461
eliftype=="Comment":
6562
ifcontentModelFlag!="PCDATA":
66-
raiseLintError(_("Comment not in PCDATA content model flag"))
63+
raiseLintError("Comment not in PCDATA content model flag")
6764

6865
eliftypein ("Characters","SpaceCharacters"):
6966
data=token["data"]
7067
ifnotisinstance(data,str):
71-
raiseLintError(_("Attribute name is not a string: %(name)r")% {"name":data})
68+
raiseLintError("Attribute name is not a string: %(name)r"% {"name":data})
7269
ifnotdata:
73-
raiseLintError(_("%(type)s token with empty data")% {"type":type})
70+
raiseLintError("%(type)s token with empty data"% {"type":type})
7471
iftype=="SpaceCharacters":
7572
data=data.strip(spaceCharacters)
7673
ifdata:
77-
raiseLintError(_("Non-space character(s) found in SpaceCharacters token: %(token)r")% {"token":data})
74+
raiseLintError("Non-space character(s) found in SpaceCharacters token: %(token)r"% {"token":data})
7875

7976
eliftype=="Doctype":
8077
name=token["name"]
8178
ifcontentModelFlag!="PCDATA":
82-
raiseLintError(_("Doctype not in PCDATA content model flag: %(name)s")% {"name":name})
79+
raiseLintError("Doctype not in PCDATA content model flag: %(name)s"% {"name":name})
8380
ifnotisinstance(name,str):
84-
raiseLintError(_("Tag name is not a string: %(tag)r")% {"tag":name})
81+
raiseLintError("Tag name is not a string: %(tag)r"% {"tag":name})
8582
# XXX: what to do with token["data"] ?
8683

8784
eliftypein ("ParseError","SerializeError"):
8885
pass
8986

9087
else:
91-
raiseLintError(_("Unknown token type: %(type)s")% {"type":type})
88+
raiseLintError("Unknown token type: %(type)s"% {"type":type})
9289

9390
yieldtoken

‎html5lib/serializer/htmlserializer.py

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
from __future__importabsolute_import,division,unicode_literals
22
fromsiximporttext_type
33

4-
importgettext
5-
_=gettext.gettext
6-
74
try:
85
fromfunctoolsimportreduce
96
exceptImportError:
@@ -208,7 +205,7 @@ def serialize(self, treewalker, encoding=None):
208205
iftoken["systemId"]:
209206
iftoken["systemId"].find('"')>=0:
210207
iftoken["systemId"].find("'")>=0:
211-
self.serializeError(_("System identifer contains both single and double quote characters"))
208+
self.serializeError("System identifer contains both single and double quote characters")
212209
quote_char="'"
213210
else:
214211
quote_char='"'
@@ -220,7 +217,7 @@ def serialize(self, treewalker, encoding=None):
220217
eliftypein ("Characters","SpaceCharacters"):
221218
iftype=="SpaceCharacters"orin_cdata:
222219
ifin_cdataandtoken["data"].find("</")>=0:
223-
self.serializeError(_("Unexpected </ in CDATA"))
220+
self.serializeError("Unexpected </ in CDATA")
224221
yieldself.encode(token["data"])
225222
else:
226223
yieldself.encode(escape(token["data"]))
@@ -231,7 +228,7 @@ def serialize(self, treewalker, encoding=None):
231228
ifnameinrcdataElementsandnotself.escape_rcdata:
232229
in_cdata=True
233230
elifin_cdata:
234-
self.serializeError(_("Unexpected child element of a CDATA element"))
231+
self.serializeError("Unexpected child element of a CDATA element")
235232
for (attr_namespace,attr_name),attr_valueintoken["data"].items():
236233
# TODO: Add namespace support here
237234
k=attr_name
@@ -279,20 +276,20 @@ def serialize(self, treewalker, encoding=None):
279276
ifnameinrcdataElements:
280277
in_cdata=False
281278
elifin_cdata:
282-
self.serializeError(_("Unexpected child element of a CDATA element"))
279+
self.serializeError("Unexpected child element of a CDATA element")
283280
yieldself.encodeStrict("</%s>"%name)
284281

285282
eliftype=="Comment":
286283
data=token["data"]
287284
ifdata.find("--")>=0:
288-
self.serializeError(_("Comment contains --"))
285+
self.serializeError("Comment contains --")
289286
yieldself.encodeStrict("<!--%s-->"%token["data"])
290287

291288
eliftype=="Entity":
292289
name=token["name"]
293290
key=name+";"
294291
ifkeynotinentities:
295-
self.serializeError(_("Entity %s not recognized"%name))
292+
self.serializeError("Entity %s not recognized"%name)
296293
ifself.resolve_entitiesandkeynotinxmlEntities:
297294
data=entities[key]
298295
else:

‎html5lib/treewalkers/_base.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
__all__= ["DOCUMENT","DOCTYPE","TEXT","ELEMENT","COMMENT","ENTITY","UNKNOWN",
55
"TreeWalker","NonRecursiveTreeWalker"]
66

7-
importgettext
8-
_=gettext.gettext
9-
107
fromxml.domimportNode
118

129
DOCUMENT=Node.DOCUMENT_NODE
@@ -61,7 +58,7 @@ def emptyTag(self, namespace, name, attrs, hasChildren=False):
6158
"namespace":to_text(namespace),
6259
"data":attrs}
6360
ifhasChildren:
64-
yieldself.error(_("Void element has children"))
61+
yieldself.error("Void element has children")
6562

6663
defstartTag(self,namespace,name,attrs):
6764
assertnamespaceisNoneorisinstance(namespace,string_types),type(namespace)
@@ -125,7 +122,7 @@ def entity(self, name):
125122
return {"type":"Entity","name":text_type(name)}
126123

127124
defunknown(self,nodeType):
128-
returnself.error(_("Unknown node type: ")+nodeType)
125+
returnself.error("Unknown node type: "+nodeType)
129126

130127

131128
classNonRecursiveTreeWalker(TreeWalker):

‎html5lib/treewalkers/dom.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@
22

33
fromxml.domimportNode
44

5-
importgettext
6-
_=gettext.gettext
7-
85
from .import_base
96

107

‎html5lib/treewalkers/etree.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,6 @@
77
fromordereddictimportOrderedDict
88
exceptImportError:
99
OrderedDict=dict
10-
importgettext
11-
_=gettext.gettext
1210

1311
importre
1412

‎html5lib/treewalkers/lxmletree.py

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,6 @@
44
fromlxmlimportetree
55
from ..treebuilders.etreeimporttag_regexp
66

7-
fromgettextimportgettext
8-
_=gettext
9-
107
from .import_base
118

129
from ..importihatexml
@@ -130,7 +127,7 @@ def __init__(self, tree):
130127
defgetNodeDetails(self,node):
131128
ifisinstance(node,tuple):# Text node
132129
node,key=node
133-
assertkeyin ("text","tail"),_("Text nodes are text or tail, found %s")%key
130+
assertkeyin ("text","tail"),"Text nodes are text or tail, found %s"%key
134131
return_base.TEXT,ensure_str(getattr(node,key))
135132

136133
elifisinstance(node,Root):
@@ -169,7 +166,7 @@ def getNodeDetails(self, node):
169166
attrs,len(node)>0ornode.text)
170167

171168
defgetFirstChild(self,node):
172-
assertnotisinstance(node,tuple),_("Text nodes have no children")
169+
assertnotisinstance(node,tuple),"Text nodes have no children"
173170

174171
assertlen(node)ornode.text,"Node has no children"
175172
ifnode.text:
@@ -180,7 +177,7 @@ def getFirstChild(self, node):
180177
defgetNextSibling(self,node):
181178
ifisinstance(node,tuple):# Text node
182179
node,key=node
183-
assertkeyin ("text","tail"),_("Text nodes are text or tail, found %s")%key
180+
assertkeyin ("text","tail"),"Text nodes are text or tail, found %s"%key
184181
ifkey=="text":
185182
# XXX: we cannot use a "bool(node) and node[0] or None" construct here
186183
# because node[0] might evaluate to False if it has no child element
@@ -196,7 +193,7 @@ def getNextSibling(self, node):
196193
defgetParentNode(self,node):
197194
ifisinstance(node,tuple):# Text node
198195
node,key=node
199-
assertkeyin ("text","tail"),_("Text nodes are text or tail, found %s")%key
196+
assertkeyin ("text","tail"),"Text nodes are text or tail, found %s"%key
200197
ifkey=="text":
201198
returnnode
202199
# else: fallback to "normal" processing

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp