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

Unified Diff: grit/gather/skeleton_gatherer.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/interface.py ('k') | grit/gather/tr_html.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « grit/gather/interface.py ('k') | grit/gather/tr_html.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698