Index: grit/gather/skeleton_gatherer.py |
diff --git a/grit/gather/skeleton_gatherer.py b/grit/gather/skeleton_gatherer.py |
index b1246580f964ba5492173ac259f17f17a34ccd63..ba440aa4bc4ebe3a2f73b4a497d10bf8fbb1297f 100644 |
--- a/grit/gather/skeleton_gatherer.py |
+++ b/grit/gather/skeleton_gatherer.py |
@@ -125,3 +125,24 @@ class SkeletonGatherer(interface.GathererBase): |
self.skeleton_.append(self.uberclique.MakeClique( |
tclib.Message(text=unescaped_text))) |
self.translatable_chunk_ = True |
+ |
+ def SubstituteMessages(self, substituter): |
+ '''Applies substitutions to all messages in the tree. |
+ |
+ Goes through the skeleton and finds all MessageCliques. |
+ |
+ Args: |
+ substituter: a grit.util.Substituter object. |
+ ''' |
+ if self.single_message_: |
+ self.single_message_ = substituter.SubstituteMessage(self.single_message_) |
+ new_skel = [] |
+ for chunk in self.skeleton_: |
+ if isinstance(chunk, clique.MessageClique): |
+ old_message = chunk.GetMessage() |
+ new_message = substituter.SubstituteMessage(old_message) |
+ if new_message is not old_message: |
+ new_skel.append(self.uberclique.MakeClique(new_message)) |
+ continue |
+ new_skel.append(chunk) |
+ self.skeleton_ = new_skel |