Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(313)

Unified Diff: grit/node/base.py

Issue 9965022: Allow substitution of messages as variables in other messages. (Closed) Base URL: https://grit-i18n.googlecode.com/svn/trunk
Patch Set: Fix unit tests for policy writers. Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « grit/gather/tr_html.py ('k') | grit/node/io_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: grit/node/base.py
diff --git a/grit/node/base.py b/grit/node/base.py
index c8f1dd248029727cfdd6cf46f712051f9c21ee21..17770122f785a49e80cb64467a6bd832bb0b37bc 100644
--- a/grit/node/base.py
+++ b/grit/node/base.py
@@ -222,11 +222,8 @@ class Node(grit.format.interface.ItemFormatter):
return header + self.FormatXml()
# Compliance with ItemFormatter interface.
- def Format(self, item, lang_re = None, begin_item=True):
- if not begin_item:
- return ''
- else:
- return item.FormatXml()
+ def Format(self, item, lang_re = None):
+ return item.FormatXml()
def FormatXml(self, indent = u'', one_line = False):
'''Returns this node and all nodes below it as an XML
@@ -322,6 +319,17 @@ class Node(grit.format.interface.ItemFormatter):
for child in process_last:
child.RunGatherers(recursive=recursive, debug=debug)
+ def SubstituteMessages(self, substituter):
+ '''Applies substitutions to all messages in the tree.
+
+ Called as a final step of RunGatherers.
+
+ Args:
+ substituter: a grit.util.Substituter object.
+ '''
+ for child in self.children:
+ child.SubstituteMessages(substituter)
+
def ItemFormatter(self, type):
'''Returns an instance of the item formatter for this object of the
specified type, or None if not supported.
@@ -338,18 +346,17 @@ class Node(grit.format.interface.ItemFormatter):
return None
def SatisfiesOutputCondition(self):
- '''Returns true if this node is either not a child of an <if> element
- or if it is a child of an <if> element and the conditions for it being
- output are satisfied.
+ '''Returns true if this node is either not a descendant of an <if> element,
+ or if all conditions on its <if> element ancestors are satisfied.
Used to determine whether to return item formatters for formats that
obey conditional output of resources (e.g. the RC formatters).
'''
from grit.node import misc
- if not self.parent or not isinstance(self.parent, misc.IfNode):
- return True
+ if self.parent:
+ return self.parent.SatisfiesOutputCondition()
else:
- return self.parent.IsConditionSatisfied()
+ return True
def _IsValidChild(self, child):
'''Returns true if 'child' is a valid child of this node.
@@ -553,6 +560,10 @@ class Node(grit.format.interface.ItemFormatter):
'''
self._whitelist_marked_as_skip = mark_skipped
+ def ExpandVariables(self):
+ '''Whether we need to expand variables on a given node.'''
+ return False
+
class ContentNode(Node):
'''Convenience baseclass for nodes that can have content.'''
« no previous file with comments | « grit/gather/tr_html.py ('k') | grit/node/io_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698