browser/locales/generic/extract-bookmarks.py

Thu, 22 Jan 2015 13:21:57 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Thu, 22 Jan 2015 13:21:57 +0100
branch
TOR_BUG_9701
changeset 15
b8a032363ba2
permissions
-rw-r--r--

Incorporate requested changes from Mozilla in review:
https://bugzilla.mozilla.org/show_bug.cgi?id=1123480#c6

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

mercurial