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

Side by Side Diff: remoting/webapp/verify-webapp.py

Issue 10703034: Remove 'Enable' button on unsupported platforms. Added 'No hosts' message. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Split 'no hosts' message into two sentences and display the second only if hosting is not supported. Created 8 years, 5 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) 2011 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2011 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 a given messages.json file defines all the strings used by the 6 """Verifies that a given messages.json file defines all the strings used by the
7 a given set of files. For file formats where it is not possible to infer which 7 a given set of 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
11 LocalizeString(/*i18n-content*/"PRODUCT_NAME"); 11 LocalizeString(/*i18n-content*/"PRODUCT_NAME");
12 12
13 This script also recognises localized strings in HTML and manifest.json files: 13 This script also recognises localized strings in HTML and manifest.json files:
14 14
15 HTML: <span i18n-content="PRODUCT_NAME"></span> 15 HTML: <span i18n-content="PRODUCT_NAME"></span>
16 or ...i18n-value-name-1="BUTTON_NAME"...
16 manifest.json: __MSG_PRODUCT_NAME__ 17 manifest.json: __MSG_PRODUCT_NAME__
17 18
18 Note that these forms must be exact; extra spaces are not permitted, though 19 Note that these forms must be exact; extra spaces are not permitted, though
19 either single or double quotes are recognized. 20 either single or double quotes are recognized.
20 21
21 In addition, the script checks that all the messages are still in use; if 22 In addition, the script checks that all the messages are still in use; if
22 this is not the case then a warning is issued, but the script still succeeds. 23 this is not the case then a warning is issued, but the script still succeeds.
23 """ 24 """
24 25
25 import json 26 import json
26 import os 27 import os
27 import re 28 import re
28 import sys 29 import sys
29 30
30 all_tags = set([]) 31 all_tags = set([])
31 32
32 WARNING_MESSAGE = """ 33 WARNING_MESSAGE = """
33 To remove this warning, either remove the unused tags from 34 To remove this warning, either remove the unused tags from
34 messages.json, add the files that use the tags listed above to 35 messages.json, add the files that use the tags listed above to
35 remoting.gyp, or annotate existing uses of those tags with the 36 remoting.gyp, or annotate existing uses of those tags with the
36 prefix /*i18n-content*/ 37 prefix /*i18n-content*/
37 """ 38 """
38 39
39 40
40 def ExtractTagFromLine(line): 41 def ExtractTagFromLine(line):
41 """Extract a tag from a line of HTML, C++, JS or JSON.""" 42 """Extract a tag from a line of HTML, C++, JS or JSON."""
42 # HTML-style 43 # HTML-style (tags)
43 m = re.search('i18n-content=[\'"]([^\'"]*)[\'"]', line) 44 m = re.search('i18n-content=[\'"]([^\'"]*)[\'"]', line)
44 if m: return m.group(1) 45 if m: return m.group(1)
46 # HTML-style (substitutions)
47 m = re.search('i18n-value-name-[1-9]=[\'"]([^\'"]*)[\'"]', line)
48 if m: return m.group(1)
45 # C++/Javascript style 49 # C++/Javascript style
46 m = re.search('/\*i18n-content\*/[\'"]([^\`"]*)[\'"]', line) 50 m = re.search('/\*i18n-content\*/[\'"]([^\`"]*)[\'"]', line)
47 if m: return m.group(1) 51 if m: return m.group(1)
48 # Manifest style 52 # Manifest style
49 m = re.search('__MSG_(.*)__', line) 53 m = re.search('__MSG_(.*)__', line)
50 if m: return m.group(1) 54 if m: return m.group(1)
51 return None 55 return None
52 56
53 57
54 def CheckFileForUnknownTag(filename, messages): 58 def CheckFileForUnknownTag(filename, messages):
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 if exit_code == 0: 103 if exit_code == 0:
100 f = open(touch_file, 'a') 104 f = open(touch_file, 'a')
101 f.close() 105 f.close()
102 os.utime(touch_file, None) 106 os.utime(touch_file, None)
103 107
104 return exit_code 108 return exit_code
105 109
106 110
107 if __name__ == '__main__': 111 if __name__ == '__main__':
108 sys.exit(main()) 112 sys.exit(main())
OLDNEW
« remoting/webapp/host_controller.js ('K') | « remoting/webapp/remoting.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698