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

Side by Side Diff: remoting/tools/verify_resources.py

Issue 20985002: Localized Chromoting Host on Mac and Linux. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 7 years, 4 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 | « remoting/tools/build/remoting_localize.py ('k') | remoting/unittests-Info.plist » ('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 """Verifies that GRD resource files define all the strings used by a given 6 """Verifies that GRD resource files define all the strings used by a given
7 set of source files. For file formats where it is not possible to infer which 7 set of source files. For file formats where it is not possible to infer which
8 strings represent message identifiers, localized strings should be explicitly 8 strings represent message identifiers, localized strings should be explicitly
9 annotated with the string "i18n-content", for example: 9 annotated with the string "i18n-content", for example:
10 10
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 # HTML-style (tags) 55 # HTML-style (tags)
56 m = re.search('i18n-content=[\'"]([^\'"]*)[\'"]', line) 56 m = re.search('i18n-content=[\'"]([^\'"]*)[\'"]', line)
57 if m: return m.group(1) 57 if m: return m.group(1)
58 # HTML-style (substitutions) 58 # HTML-style (substitutions)
59 m = re.search('i18n-value-name-[1-9]=[\'"]([^\'"]*)[\'"]', line) 59 m = re.search('i18n-value-name-[1-9]=[\'"]([^\'"]*)[\'"]', line)
60 if m: return m.group(1) 60 if m: return m.group(1)
61 elif file_type == 'js': 61 elif file_type == 'js':
62 # Javascript style 62 # Javascript style
63 m = re.search('/\*i18n-content\*/[\'"]([^\`"]*)[\'"]', line) 63 m = re.search('/\*i18n-content\*/[\'"]([^\`"]*)[\'"]', line)
64 if m: return m.group(1) 64 if m: return m.group(1)
65 elif file_type == 'cc': 65 elif file_type == 'cc' or file_type == 'mm':
66 # C++ style 66 # C++ style
67 m = re.search('IDR_([A-Z0-9_]*)', line) 67 m = re.search('IDR_([A-Z0-9_]*)', line)
68 if m: return m.group(1) 68 if m: return m.group(1)
69 m = re.search('/\*i18n-content\*/["]([^\`"]*)["]', line) 69 m = re.search('/\*i18n-content\*/["]([^\`"]*)["]', line)
70 if m: return m.group(1) 70 if m: return m.group(1)
71 elif file_type == 'json': 71 elif file_type == 'json':
72 # Manifest style 72 # Manifest style
73 m = re.search('__MSG_(.*)__', line) 73 m = re.search('__MSG_(.*)__', line)
74 if m: return m.group(1) 74 if m: return m.group(1)
75 elif file_type == 'jinja2': 75 elif file_type == 'jinja2':
76 # Jinja2 template file 76 # Jinja2 template file
77 m = re.search('\{\%\s+trans\s+\%\}([A-Z0-9_]+)\{\%\s+endtrans\s+\%\}', line) 77 m = re.search('\{\%\s+trans\s+\%\}([A-Z0-9_]+)\{\%\s+endtrans\s+\%\}', line)
78 if m: return m.group(1) 78 if m: return m.group(1)
79 return None 79 return None
80 80
81 81
82 def VerifyFile(filename, messages, used_tags): 82 def VerifyFile(filename, messages, used_tags):
83 """ 83 """
84 Parse |filename|, looking for tags and report any that are not included in 84 Parse |filename|, looking for tags and report any that are not included in
85 |messages|. Return True if all tags are present and correct, or False if 85 |messages|. Return True if all tags are present and correct, or False if
86 any are missing. If no tags are found, print a warning message and return 86 any are missing. If no tags are found, print a warning message and return
87 True. 87 True.
88 """ 88 """
89 89
90 base_name, extension = os.path.splitext(filename) 90 base_name, extension = os.path.splitext(filename)
91 extension = extension[1:] 91 extension = extension[1:]
92 if extension not in ['js', 'cc', 'html', 'json', 'jinja2']: 92 if extension not in ['js', 'cc', 'html', 'json', 'jinja2', 'mm']:
93 raise Exception("Unknown file type: %s" % extension) 93 raise Exception("Unknown file type: %s" % extension)
94 94
95 result = True 95 result = True
96 matches = False 96 matches = False
97 f = open(filename, 'r') 97 f = open(filename, 'r')
98 lines = f.readlines() 98 lines = f.readlines()
99 for i in xrange(0, len(lines)): 99 for i in xrange(0, len(lines)):
100 tag = ExtractTagFromLine(extension, lines[i]) 100 tag = ExtractTagFromLine(extension, lines[i])
101 if tag: 101 if tag:
102 tag = tag.upper() 102 tag = tag.upper()
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
150 if exit_code == 0: 150 if exit_code == 0:
151 f = open(options.touch, 'a') 151 f = open(options.touch, 'a')
152 f.close() 152 f.close()
153 os.utime(options.touch, None) 153 os.utime(options.touch, None)
154 154
155 return exit_code 155 return exit_code
156 156
157 157
158 if __name__ == '__main__': 158 if __name__ == '__main__':
159 sys.exit(main()) 159 sys.exit(main())
OLDNEW
« no previous file with comments | « remoting/tools/build/remoting_localize.py ('k') | remoting/unittests-Info.plist » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698