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

Side by Side Diff: grit/format/policy_templates/writers/plist_strings_writer.py

Issue 631223003: Include chromium version number in policy templates (Closed) Base URL: http://grit-i18n.googlecode.com/svn/trunk/
Patch Set: Created 6 years, 2 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
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 6
7 from grit.format.policy_templates.writers import plist_helper 7 from grit.format.policy_templates.writers import plist_helper
8 from grit.format.policy_templates.writers import template_writer 8 from grit.format.policy_templates.writers import template_writer
9 9
10 10
11 def GetWriter(config): 11 def GetWriter(config):
12 '''Factory method for creating PListStringsWriter objects. 12 '''Factory method for creating PListStringsWriter objects.
13 See the constructor of TemplateWriter for description of 13 See the constructor of TemplateWriter for description of
14 arguments. 14 arguments.
15 ''' 15 '''
16 return PListStringsWriter(['mac'], config) 16 return PListStringsWriter(['mac'], config)
17 17
18 18
19 class PListStringsWriter(template_writer.TemplateWriter): 19 class PListStringsWriter(template_writer.TemplateWriter):
20 '''Outputs localized string table files for the Mac policy file. 20 '''Outputs localized string table files for the Mac policy file.
21 These files are named Localizable.strings and they are in the 21 These files are named Localizable.strings and they are in the
22 [lang].lproj subdirectories of the manifest bundle. 22 [lang].lproj subdirectories of the manifest bundle.
23 ''' 23 '''
24 24
25 def WriteComment(self, comment):
26 self._out.append('/* ' + comment + ' */' )
27
25 def _AddToStringTable(self, item_name, caption, desc): 28 def _AddToStringTable(self, item_name, caption, desc):
26 '''Add a title and a description of an item to the string table. 29 '''Add a title and a description of an item to the string table.
27 30
28 Args: 31 Args:
29 item_name: The name of the item that will get the title and the 32 item_name: The name of the item that will get the title and the
30 description. 33 description.
31 title: The text of the title to add. 34 title: The text of the title to add.
32 desc: The text of the description to add. 35 desc: The text of the description to add.
33 ''' 36 '''
34 caption = caption.replace('"', '\\"') 37 caption = caption.replace('"', '\\"')
(...skipping 21 matching lines...) Expand all
56 # Append the captions of enum items to the description string. 59 # Append the captions of enum items to the description string.
57 item_descs = [] 60 item_descs = []
58 for item in policy['items']: 61 for item in policy['items']:
59 item_descs.append(str(item['value']) + ' - ' + item['caption']) 62 item_descs.append(str(item['value']) + ' - ' + item['caption'])
60 desc = '\n'.join(item_descs) + '\n' + desc 63 desc = '\n'.join(item_descs) + '\n' + desc
61 64
62 self._AddToStringTable(policy['name'], policy['label'], desc) 65 self._AddToStringTable(policy['name'], policy['label'], desc)
63 66
64 def BeginTemplate(self): 67 def BeginTemplate(self):
65 app_name = plist_helper.GetPlistFriendlyName(self.config['app_name']) 68 app_name = plist_helper.GetPlistFriendlyName(self.config['app_name'])
69 if self._GetChromiumVersionString() is not None:
70 self.WriteComment(self.config['build'] + ''' version: ''' + \
71 self._GetChromiumVersionString())
66 self._AddToStringTable( 72 self._AddToStringTable(
67 app_name, 73 app_name,
68 self.config['app_name'], 74 self.config['app_name'],
69 self.messages['mac_chrome_preferences']['text']) 75 self.messages['mac_chrome_preferences']['text'])
70 76
71 def Init(self): 77 def Init(self):
72 # A buffer for the lines of the string table being generated. 78 # A buffer for the lines of the string table being generated.
73 self._out = [] 79 self._out = []
74 80
75 def GetTemplateText(self): 81 def GetTemplateText(self):
76 return '\n'.join(self._out) 82 return '\n'.join(self._out)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698