OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/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 """Generate keyboard layout and hotkey data for the keyboard overlay. | 6 """Generate keyboard layout and hotkey data for the keyboard overlay. |
7 | 7 |
8 This script fetches data from the keyboard layout and hotkey data spreadsheet, | 8 This script fetches data from the keyboard layout and hotkey data spreadsheet, |
9 and output the data depending on the option. | 9 and output the data depending on the option. |
10 | 10 |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 'glyph_back': 'back', | 56 'glyph_back': 'back', |
57 'glyph_backspace': 'backspace', | 57 'glyph_backspace': 'backspace', |
58 'glyph_brightness_down': 'bright down', | 58 'glyph_brightness_down': 'bright down', |
59 'glyph_brightness_up': 'bright up', | 59 'glyph_brightness_up': 'bright up', |
60 'glyph_enter': 'enter', | 60 'glyph_enter': 'enter', |
61 'glyph_forward': 'forward', | 61 'glyph_forward': 'forward', |
62 'glyph_fullscreen': 'full screen', | 62 'glyph_fullscreen': 'full screen', |
63 # Kana/Eisu key on Japanese keyboard | 63 # Kana/Eisu key on Japanese keyboard |
64 'glyph_ime': u'\u304b\u306a\u0020\u002f\u0020\u82f1\u6570', | 64 'glyph_ime': u'\u304b\u306a\u0020\u002f\u0020\u82f1\u6570', |
65 'glyph_lock': 'lock', | 65 'glyph_lock': 'lock', |
66 'glyph_overview': 'switch window', | 66 'glyph_overview': 'maximize', |
67 'glyph_power': 'power', | 67 'glyph_power': 'power', |
68 'glyph_right': 'right', | 68 'glyph_right': 'right', |
69 'glyph_reload': 'reload', | 69 'glyph_reload': 'reload', |
70 'glyph_search': 'search', | 70 'glyph_search': 'search', |
71 'glyph_shift': 'shift', | 71 'glyph_shift': 'shift', |
72 'glyph_tab': 'tab', | 72 'glyph_tab': 'tab', |
73 'glyph_tools': 'tools', | 73 'glyph_tools': 'tools', |
74 'glyph_volume_down': 'vol. down', | 74 'glyph_volume_down': 'vol. down', |
75 'glyph_volume_mute': 'mute', | 75 'glyph_volume_mute': 'mute', |
76 'glyph_volume_up': 'vol. up', | 76 'glyph_volume_up': 'vol. up', |
(...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
353 i18nContent = Toi18nContent(behavior) | 353 i18nContent = Toi18nContent(behavior) |
354 action_to_id[action] = i18nContent | 354 action_to_id[action] = i18nContent |
355 data = {'keyboardGlyph': keyboard_glyph_data, | 355 data = {'keyboardGlyph': keyboard_glyph_data, |
356 'shortcut': action_to_id, | 356 'shortcut': action_to_id, |
357 'layouts': layouts} | 357 'layouts': layouts} |
358 out = file(outfile, 'w') | 358 out = file(outfile, 'w') |
359 out.write(GenerateCopyrightHeader() + '\n') | 359 out.write(GenerateCopyrightHeader() + '\n') |
360 json_data = json.dumps(data, sort_keys=True, indent=2) | 360 json_data = json.dumps(data, sort_keys=True, indent=2) |
361 # Remove redundant spaces after ',' | 361 # Remove redundant spaces after ',' |
362 json_data = json_data.replace(', \n', ',\n') | 362 json_data = json_data.replace(', \n', ',\n') |
363 out.write('var %s = %s;' % (var_name, json_data)) | 363 out.write('var %s = %s;\n' % (var_name, json_data)) |
364 | 364 |
365 | 365 |
366 def OutputGrd(hotkey_data, outfile): | 366 def OutputGrd(hotkey_data, outfile): |
367 """Outputs a snippet used for a grd file.""" | 367 """Outputs a snippet used for a grd file.""" |
368 print 'Generating: %s' % outfile | 368 print 'Generating: %s' % outfile |
369 desc = 'The text in the keyboard overlay to explain the shortcut.' | 369 desc = 'The text in the keyboard overlay to explain the shortcut.' |
370 out = file(outfile, 'w') | 370 out = file(outfile, 'w') |
371 for behavior in UniqueBehaviors(hotkey_data): | 371 for behavior in UniqueBehaviors(hotkey_data): |
372 out.write(GRD_SNIPPET_TEMPLATE % (ToMessageName(behavior), desc, behavior)) | 372 out.write(GRD_SNIPPET_TEMPLATE % (ToMessageName(behavior), desc, behavior)) |
373 | 373 |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
431 if options.grd: | 431 if options.grd: |
432 OutputGrd(hotkey_data, options.out + '.grd') | 432 OutputGrd(hotkey_data, options.out + '.grd') |
433 if options.cc: | 433 if options.cc: |
434 OutputCC(hotkey_data, options.out + '.cc') | 434 OutputCC(hotkey_data, options.out + '.cc') |
435 if options.altgr: | 435 if options.altgr: |
436 OutputAltGr(keyboard_glyph_data, options.out + '.altgr') | 436 OutputAltGr(keyboard_glyph_data, options.out + '.altgr') |
437 | 437 |
438 | 438 |
439 if __name__ == '__main__': | 439 if __name__ == '__main__': |
440 main() | 440 main() |
OLD | NEW |