| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2013 The Chromium Authors. All rights reserved. | 2 # Copyright 2013 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 localize.py -- Generates an output file from the given template replacing | 7 localize.py -- Generates an output file from the given template replacing |
| 8 variables and localizing strings. | 8 variables and localizing strings. |
| 9 | 9 |
| 10 The script uses Jinja2 template processing library (src/third_party/jinja2). | 10 The script uses Jinja2 template processing library (src/third_party/jinja2). |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 649 | 649 |
| 650 | 650 |
| 651 def Localize(source, locales, options): | 651 def Localize(source, locales, options): |
| 652 # Set the list of languages to use. | 652 # Set the list of languages to use. |
| 653 languages = map(NormalizeLanguageCode, locales) | 653 languages = map(NormalizeLanguageCode, locales) |
| 654 context = { 'languages' : languages } | 654 context = { 'languages' : languages } |
| 655 | 655 |
| 656 # Load the localized messages. | 656 # Load the localized messages. |
| 657 message_map = MessageMap(languages, options.locale_dir) | 657 message_map = MessageMap(languages, options.locale_dir) |
| 658 | 658 |
| 659 # Add OFFICIAL_BUILD variable the same way chrome/tools/build/version.py | 659 # Add OFFICIAL_BUILD variable the same way build/util/version.py |
| 660 # does. | 660 # does. |
| 661 if os.environ.get('CHROME_BUILD_TYPE') == '_official': | 661 if os.environ.get('CHROME_BUILD_TYPE') == '_official': |
| 662 context['official_build'] = '1' | 662 context['official_build'] = '1' |
| 663 else: | 663 else: |
| 664 context['official_build'] = '0' | 664 context['official_build'] = '0' |
| 665 | 665 |
| 666 # Add all variables defined in the command line. | 666 # Add all variables defined in the command line. |
| 667 if options.define: | 667 if options.define: |
| 668 for define in options.define: | 668 for define in options.define: |
| 669 context.update(dict([define.split('=', 1)])); | 669 context.update(dict([define.split('=', 1)])); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 774 parser.error( | 774 parser.error( |
| 775 'Either --output or --locale_output must be specified but not both') | 775 'Either --output or --locale_output must be specified but not both') |
| 776 if not options.template and not options.print_only: | 776 if not options.template and not options.print_only: |
| 777 parser.error('The template name is required unless --print_only is used') | 777 parser.error('The template name is required unless --print_only is used') |
| 778 | 778 |
| 779 return Localize(options.template, locales, options) | 779 return Localize(options.template, locales, options) |
| 780 | 780 |
| 781 if __name__ == '__main__': | 781 if __name__ == '__main__': |
| 782 sys.exit(DoMain(sys.argv[1:])) | 782 sys.exit(DoMain(sys.argv[1:])) |
| 783 | 783 |
| OLD | NEW |