OLD | NEW |
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 Loading... |
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 |
OLD | NEW |