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
71f1d9dd
Commit
71f1d9dd
authored
Aug 20, 2003
by
Godefroid Chapelle
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
management of i18n:attributes was not similar
in both space and semicolon separated lists
parent
635ce2ab
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
34 deletions
+45
-34
lib/python/TAL/TALGenerator.py
lib/python/TAL/TALGenerator.py
+45
-34
No files found.
lib/python/TAL/TALGenerator.py
View file @
71f1d9dd
...
@@ -669,8 +669,8 @@ class TALGenerator:
...
@@ -669,8 +669,8 @@ class TALGenerator:
else:
else:
repldict = {}
repldict = {}
if i18nattrs:
if i18nattrs:
i18nattrs = _parseI18nAttributes(i18nattrs, attrlist, repldict,
i18nattrs = _parseI18nAttributes(i18nattrs, attrlist, repldict,
self.position,
self.
position, self.xml
)
self.
xml, self.source_file
)
else:
else:
i18nattrs = {}
i18nattrs = {}
# Convert repldict's name-->expr mapping to a
# Convert repldict's name-->expr mapping to a
...
@@ -678,9 +678,9 @@ class TALGenerator:
...
@@ -678,9 +678,9 @@ class TALGenerator:
for key, value in repldict.items():
for key, value in repldict.items():
if i18nattrs.get(key, None):
if i18nattrs.get(key, None):
raise I18NError(
raise I18NError(
("
attribute
[
%
s
]
cannot
both
be
part
of
tal
:
attributes
"
("
attribute
[
%
s
]
cannot
both
be
part
of
tal
:
attributes
" +
"
and
have
a
msgid
in
i18n
:
attributes
") % key,
"
and
have
a
msgid
in
i18n
:
attributes
") % key,
position)
position)
ce = self.compileExpression(value)
ce = self.compileExpression(value)
repldict[key] = ce, key in i18nattrs, i18nattrs.get(key)
repldict[key] = ce, key in i18nattrs, i18nattrs.get(key)
for key in i18nattrs:
for key in i18nattrs:
...
@@ -789,7 +789,7 @@ class TALGenerator:
...
@@ -789,7 +789,7 @@ class TALGenerator:
self.emitI18nVariable(varname)
self.emitI18nVariable(varname)
# Do not test for "
msgid
is
not
None
", i.e. we only want to test for
# Do not test for "
msgid
is
not
None
", i.e. we only want to test for
# explicit msgids here. See comment above.
# explicit msgids here. See comment above.
if msgid is not None:
if msgid is not None:
# in case tal:content, i18n:translate and i18n:name in the
# in case tal:content, i18n:translate and i18n:name in the
# same tag insertTranslation opcode has already been
# same tag insertTranslation opcode has already been
# emitted
# emitted
...
@@ -817,56 +817,67 @@ class TALGenerator:
...
@@ -817,56 +817,67 @@ class TALGenerator:
self.emitDefineMacro(defineMacro)
self.emitDefineMacro(defineMacro)
def _parseI18nAttributes(i18nattrs, attrlist, repldict, position, xml):
def _parseI18nAttributes(i18nattrs, attrlist, repldict, position,
xml, source_file):
def addAttribute(dic, attr, msgid, position, xml):
if not xml:
attr = attr.lower()
if attr in dic:
raise TALError(
"
attribute
may
only
be
specified
once
in
i18n
:
attributes
:
%
r"
% attr,
position)
dic[attr] = msgid
d = {}
d = {}
if ';' in i18nattrs:
if ';' in i18nattrs:
i18nattrlist = i18nattrs.split(';')
i18nattrlist = i18nattrs.split(';')
i18nattrlist = [attr.strip().split()
i18nattrlist = [attr.strip().split() for attr in i18nattrlist if attr.strip()]
for attr in i18nattrlist if attr.strip()]
for parts in i18nattrlist:
for parts in i18nattrlist:
if len(parts) > 2:
if len(parts) > 2:
raise TALError(
raise TALError("
illegal
i18n
:
attributes
specification
:
%
r" % parts,
"
illegal
i18n
:
attributes
specification
:
%
r" % spec,
position)
position)
if len(parts) == 2:
if len(parts) == 2:
attr, msgid = parts
attr, msgid = parts
else:
else:
# len(parts) == 1
# len(parts) == 1
attr = parts[0]
attr = parts[0]
msgid = None
msgid = None
if not xml:
addAttribute(d, attr, msgid, position, xml)
attr = attr.lower()
if attr in d:
raise TALError(
"
attribute
may
only
be
specified
once
in
i18n
:
attributes
:
"
+ `attr`,
position)
d[attr] = msgid
else:
else:
i18nattrlist = i18nattrs.split()
i18nattrlist = i18nattrs.split()
if len(i18nattrlist) == 2:
if len(i18nattrlist) == 2:
staticattrs = [attr[0] for attr in attrlist if len(attr) == 2]
staticattrs = [attr[0] for attr in attrlist if len(attr) == 2]
if ( (not i18nattrlist[1] in staticattrs)
if (not i18nattrlist[1] in staticattrs) and (not i18nattrlist[1] in repldict):
and (not i18nattrlist[1] in repldict)):
attr, msgid = i18nattrlist
attr, msgid = i18nattrlist
addAttribute(d, attr, msgid, position, xml)
d[attr] = msgid
else:
else:
import warnings
import warnings
warnings.warn(I18N_ATTRIBUTES_WARNING, DeprecationWarning)
warnings.warn('Space separated attributes in i18n:attributes'
+ ' are deprecated (i18n:attributes="
value
title
"). Please use'
+ ' semicolon to separate attributes'
+ ' (i18n:attributes="
value
;
title
").'
+ '
\
n
File %s at row, column %s
\
n
Attributes %s'
% (source_file, str(position), i18nattrs)
, DeprecationWarning)
msgid = None
for attr in i18nattrlist:
for attr in i18nattrlist:
d[attr] = None
addAttribute(d, attr, msgid, position, xml)
else:
else:
import warnings
import warnings
warnings.warn(I18N_ATTRIBUTES_WARNING, DeprecationWarning)
warnings.warn('Space separated attributes in i18n:attributes'
+ ' are deprecated (i18n:attributes="
value
title
"). Please use'
+ ' semicolon to separate attributes'
+ ' (i18n:attributes="
value
;
title
").'
+ '
\
n
File %s at row, column %s
\
n
Attributes %s'
% (source_file, str(position), i18nattrs)
, DeprecationWarning)
msgid = None
for attr in i18nattrlist:
for attr in i18nattrlist:
d[attr] = None
addAttribute(d, attr, msgid, position, xml)
return d
return d
I18N_ATTRIBUTES_WARNING = (
'Space separated attributes in i18n:attributes are deprecated'
' (i18n:attributes="
value
title
"). Please use a semicolon to'
' separate attributes (i18n:attributes="
value
;
title
").')
def test():
def test():
t = TALGenerator()
t = TALGenerator()
t.pushProgram()
t.pushProgram()
...
...
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