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

Side by Side 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, 8 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « grit/gather/interface.py ('k') | grit/gather/tr_html.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 '''A baseclass for simple gatherers that store their gathered resource in a 6 '''A baseclass for simple gatherers that store their gathered resource in a
7 list. 7 list.
8 ''' 8 '''
9 9
10 import re 10 import re
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
118 if chunk == '': 118 if chunk == '':
119 return 119 return
120 120
121 unescaped_text = self.UnEscape(chunk) 121 unescaped_text = self.UnEscape(chunk)
122 if self.single_message_: 122 if self.single_message_:
123 self.single_message_.AppendText(unescaped_text) 123 self.single_message_.AppendText(unescaped_text)
124 else: 124 else:
125 self.skeleton_.append(self.uberclique.MakeClique( 125 self.skeleton_.append(self.uberclique.MakeClique(
126 tclib.Message(text=unescaped_text))) 126 tclib.Message(text=unescaped_text)))
127 self.translatable_chunk_ = True 127 self.translatable_chunk_ = True
128
129 def SubstituteMessages(self, substituter):
130 '''Applies substitutions to all messages in the tree.
131
132 Goes through the skeleton and finds all MessageCliques.
133
134 Args:
135 substituter: a grit.util.Substituter object.
136 '''
137 if self.single_message_:
138 self.single_message_ = substituter.SubstituteMessage(self.single_message_)
139 new_skel = []
140 for chunk in self.skeleton_:
141 if isinstance(chunk, clique.MessageClique):
142 old_message = chunk.GetMessage()
143 new_message = substituter.SubstituteMessage(old_message)
144 if new_message is not old_message:
145 new_skel.append(self.uberclique.MakeClique(new_message))
146 continue
147 new_skel.append(chunk)
148 self.skeleton_ = new_skel
OLDNEW
« 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