Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Z
Zope
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
Zope
Commits
cf2deff3
Commit
cf2deff3
authored
Aug 09, 2005
by
Fred Drake
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
avoid a number of superfluous differences between the Zope 2 and Zope 3
implementations of the TAL interpreter
parent
adbcd6d5
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
17 deletions
+13
-17
lib/python/TAL/TALInterpreter.py
lib/python/TAL/TALInterpreter.py
+13
-17
No files found.
lib/python/TAL/TALInterpreter.py
View file @
cf2deff3
...
...
@@ -31,24 +31,20 @@ from TALDefs import getProgramVersion, getProgramMode
from
TALGenerator
import
TALGenerator
from
TranslationContext
import
TranslationContext
BOOLEAN_HTML_ATTRS
=
[
# This will become (MessageID, Message) when we use Zope 3.1 as a base:
I18nMessageTypes
=
MessageID
# TODO: In Python 2.4 we can use frozenset() instead of dict.fromkeys()
BOOLEAN_HTML_ATTRS
=
dict
.
fromkeys
([
# List of Boolean attributes in HTML that should be rendered in
# minimized form (e.g. <img ismap> rather than <img ismap="">)
# From http://www.w3.org/TR/xhtml1/#guidelines (C.10)
#
XXX
The problem with this is that this is not valid XML and
#
TODO:
The problem with this is that this is not valid XML and
# can't be parsed back!
"compact"
,
"nowrap"
,
"ismap"
,
"declare"
,
"noshade"
,
"checked"
,
"disabled"
,
"readonly"
,
"multiple"
,
"selected"
,
"noresize"
,
"defer"
]
def
_init
():
d
=
{}
for
s
in
BOOLEAN_HTML_ATTRS
:
d
[
s
]
=
1
return
d
BOOLEAN_HTML_ATTRS
=
_init
()
])
_nulljoin
=
''
.
join
_spacejoin
=
' '
.
join
...
...
@@ -502,7 +498,7 @@ class TALInterpreter:
if
text
is
self
.
Default
:
self
.
interpret
(
stuff
[
1
])
return
if
isinstance
(
text
,
MessageID
):
if
isinstance
(
text
,
I18nMessageTypes
):
# Translate this now.
text
=
self
.
engine
.
translate
(
text
.
domain
,
text
,
text
.
mapping
)
s
=
cgi
.
escape
(
text
)
...
...
@@ -537,8 +533,8 @@ class TALInterpreter:
else
:
value
=
self
.
engine
.
evaluate
(
expression
)
# evaluate() does not do any I18n, so we do it here.
if
isinstance
(
value
,
MessageID
):
# evaluate() does not do any I18n, so we do it here.
if
isinstance
(
value
,
I18nMessageTypes
):
# Translate this now.
value
=
self
.
engine
.
translate
(
value
.
domain
,
value
,
value
.
mapping
)
...
...
@@ -589,8 +585,8 @@ class TALInterpreter:
if
len
(
stuff
)
>
2
:
obj
=
self
.
engine
.
evaluate
(
stuff
[
2
])
xlated_msgid
=
self
.
translate
(
msgid
,
default
,
i18ndict
,
obj
)
#
XXX
I can't decide whether we want to cgi escape the translated
# string or not. OT
1
H not doing this could introduce a cross-site
#
TODO:
I can't decide whether we want to cgi escape the translated
# string or not. OT
O
H not doing this could introduce a cross-site
# scripting vector by allowing translators to sneak JavaScript into
# translations. OTOH, for implicit interpolation values, we don't
# want to escape stuff like ${name} <= "<b>Timmy</b>".
...
...
@@ -654,7 +650,7 @@ class TALInterpreter:
i18ndict
.
update
(
obj
)
if
not
self
.
i18nInterpolate
:
return
msgid
#
XXX
We need to pass in one of context or target_language
#
TODO:
We need to pass in one of context or target_language
return
self
.
engine
.
translate
(
self
.
i18nContext
.
domain
,
msgid
,
i18ndict
,
default
=
default
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment