Menu
Home
Blog
Add-ons
Forum
Wiki
Developers
Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
dependencies
vendor
mozbrowser
locales
generic
extract-bookmarks.py
Go to the documentation of this file.
1
# ***** BEGIN LICENSE BLOCK *****
2
# Version: MPL 1.1/GPL 2.0/LGPL 2.1
3
#
4
# The contents of this file are subject to the Mozilla Public License Version
5
# 1.1 (the "License"); you may not use this file except in compliance with
6
# the License. You may obtain a copy of the License at
7
# http://www.mozilla.org/MPL/
8
#
9
# Software distributed under the License is distributed on an "AS IS" basis,
10
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
11
# for the specific language governing rights and limitations under the
12
# License.
13
#
14
# The Original Code is the Mozilla Browser code.
15
#
16
# The Initial Developer of the Original Code is
17
# the Mozilla Foundation.
18
# Portions created by the Initial Developer are Copyright (C) 2008
19
# the Initial Developer. All Rights Reserved.
20
#
21
# Contributor(s):
22
# Axel Hecht <l10n@mozilla.com>
23
#
24
# Alternatively, the contents of this file may be used under the terms of
25
# either the GNU General Public License Version 2 or later (the "GPL"), or
26
# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27
# in which case the provisions of the GPL or the LGPL are applicable instead
28
# of those above. If you wish to allow use of your version of this file only
29
# under the terms of either the GPL or the LGPL, and not to allow others to
30
# use your version of this file under the terms of the MPL, indicate your
31
# decision by deleting the provisions above and replace them with the notice
32
# and other provisions required by the GPL or the LGPL. If you do not delete
33
# the provisions above, a recipient may use your version of this file under
34
# the terms of any one of the MPL, the GPL or the LGPL.
35
#
36
# ***** END LICENSE BLOCK *****
37
38
import
sys
39
import
re
40
import
codecs
41
try
:
42
from
Mozilla.Parser
import
getParser
43
except
ImportError:
44
sys.exit(
'''extract-bookmarks needs compare-locales
45
46
Find that on http://pypi.python.org/pypi/compare-locales.
47
This script has been tested with version 0.6, and might work with future
48
versions.'''
)
49
50
ll=re.compile(
'\.(title|a|dd|h[0-9])$'
)
51
52
p = getParser(sys.argv[1])
53
p.readFile(sys.argv[1])
54
55
template =
'''#filter emptyLines
56
57
# LOCALIZATION NOTE: The 'en-US' strings in the URLs will be replaced with
58
# your locale code, and link to your translated pages as soon as they're
59
# live.
60
61
#define bookmarks_title %s
62
#define bookmarks_heading %s
63
64
# LOCALIZATION NOTE (bookmarks_addons):
65
# link title for https://en-US.add-ons.mozilla.com/en-US/firefox/bookmarks/
66
#define bookmarks_addons %s
67
68
#define bookmarks_toolbarfolder %s
69
#define bookmarks_toolbarfolder_description %s
70
71
# LOCALIZATION NOTE (getting_started):
72
# link title for http://www.mozilla.com/en-US/firefox/central/
73
#define getting_started %s
74
75
# LOCALIZATION NOTE (latest_headlines):
76
# link title for the live bookmarks sample, a redirect on
77
# http://fxfeeds.mozilla.com/en-US/firefox/headlines.xml
78
# Changing the redirect is subject to approval of l10n-drivers.
79
#define latest_headlines %s
80
81
# LOCALIZATION NOTE (firefox_heading):
82
# Firefox links folder name
83
#define firefox_heading %s
84
85
# LOCALIZATION NOTE (firefox_help):
86
# link title for http://www.mozilla.com/en-US/firefox/help/
87
#define firefox_help %s
88
89
# LOCALIZATION NOTE (firefox_customize):
90
# link title for http://www.mozilla.com/en-US/firefox/customize/
91
#define firefox_customize %s
92
93
# LOCALIZATION NOTE (firefox_community):
94
# link title for http://www.mozilla.com/en-US/firefox/community/
95
#define firefox_community %s
96
97
# LOCALIZATION NOTE (firefox_about):
98
# link title for http://www.mozilla.com/en-US/firefox/about/
99
#define firefox_about %s
100
101
#unfilter emptyLines'''
102
103
strings = tuple(e.val
for
e
in
p
if
ll.search(e.key))
104
105
print
codecs.utf_8_encode(template % strings)[0]