Thu, 22 Jan 2015 13:21:57 +0100
Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6
1 # This Source Code Form is subject to the terms of the Mozilla Public
2 # License, v. 2.0. If a copy of the MPL was not distributed with this
3 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
5 import sys
6 import re
7 import codecs
8 try:
9 from Mozilla.Parser import getParser
10 except ImportError:
11 sys.exit('''extract-bookmarks needs compare-locales
13 Find that on http://pypi.python.org/pypi/compare-locales.
14 This script has been tested with version 0.6, and might work with future
15 versions.''')
17 ll=re.compile('\.(title|a|dd|h[0-9])$')
19 p = getParser(sys.argv[1])
20 p.readFile(sys.argv[1])
22 template = '''#filter emptyLines
24 # LOCALIZATION NOTE: The 'en-US' strings in the URLs will be replaced with
25 # your locale code, and link to your translated pages as soon as they're
26 # live.
28 #define bookmarks_title %s
29 #define bookmarks_heading %s
31 #define bookmarks_toolbarfolder %s
32 #define bookmarks_toolbarfolder_description %s
34 # LOCALIZATION NOTE (getting_started):
35 # link title for https://www.mozilla.org/en-US/firefox/central/
36 #define getting_started %s
38 # LOCALIZATION NOTE (firefox_heading):
39 # Firefox links folder name
40 #define firefox_heading %s
42 # LOCALIZATION NOTE (firefox_help):
43 # link title for https://www.mozilla.org/en-US/firefox/help/
44 #define firefox_help %s
46 # LOCALIZATION NOTE (firefox_customize):
47 # link title for https://www.mozilla.org/en-US/firefox/customize/
48 #define firefox_customize %s
50 # LOCALIZATION NOTE (firefox_community):
51 # link title for https://www.mozilla.org/en-US/contribute/
52 #define firefox_community %s
54 # LOCALIZATION NOTE (firefox_about):
55 # link title for https://www.mozilla.org/en-US/about/
56 #define firefox_about %s
58 #unfilter emptyLines'''
60 strings = tuple(e.val for e in p if ll.search(e.key))
62 print codecs.utf_8_encode(template % strings)[0]