1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/locales/generic/extract-bookmarks.py Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,62 @@ 1.4 +# This Source Code Form is subject to the terms of the Mozilla Public 1.5 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.6 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.7 + 1.8 +import sys 1.9 +import re 1.10 +import codecs 1.11 +try: 1.12 + from Mozilla.Parser import getParser 1.13 +except ImportError: 1.14 + sys.exit('''extract-bookmarks needs compare-locales 1.15 + 1.16 +Find that on http://pypi.python.org/pypi/compare-locales. 1.17 +This script has been tested with version 0.6, and might work with future 1.18 +versions.''') 1.19 + 1.20 +ll=re.compile('\.(title|a|dd|h[0-9])$') 1.21 + 1.22 +p = getParser(sys.argv[1]) 1.23 +p.readFile(sys.argv[1]) 1.24 + 1.25 +template = '''#filter emptyLines 1.26 + 1.27 +# LOCALIZATION NOTE: The 'en-US' strings in the URLs will be replaced with 1.28 +# your locale code, and link to your translated pages as soon as they're 1.29 +# live. 1.30 + 1.31 +#define bookmarks_title %s 1.32 +#define bookmarks_heading %s 1.33 + 1.34 +#define bookmarks_toolbarfolder %s 1.35 +#define bookmarks_toolbarfolder_description %s 1.36 + 1.37 +# LOCALIZATION NOTE (getting_started): 1.38 +# link title for https://www.mozilla.org/en-US/firefox/central/ 1.39 +#define getting_started %s 1.40 + 1.41 +# LOCALIZATION NOTE (firefox_heading): 1.42 +# Firefox links folder name 1.43 +#define firefox_heading %s 1.44 + 1.45 +# LOCALIZATION NOTE (firefox_help): 1.46 +# link title for https://www.mozilla.org/en-US/firefox/help/ 1.47 +#define firefox_help %s 1.48 + 1.49 +# LOCALIZATION NOTE (firefox_customize): 1.50 +# link title for https://www.mozilla.org/en-US/firefox/customize/ 1.51 +#define firefox_customize %s 1.52 + 1.53 +# LOCALIZATION NOTE (firefox_community): 1.54 +# link title for https://www.mozilla.org/en-US/contribute/ 1.55 +#define firefox_community %s 1.56 + 1.57 +# LOCALIZATION NOTE (firefox_about): 1.58 +# link title for https://www.mozilla.org/en-US/about/ 1.59 +#define firefox_about %s 1.60 + 1.61 +#unfilter emptyLines''' 1.62 + 1.63 +strings = tuple(e.val for e in p if ll.search(e.key)) 1.64 + 1.65 +print codecs.utf_8_encode(template % strings)[0]