Merge remote branch 'clouserw/l10n'

This commit is contained in:
Jeff Balogh 2009-12-28 20:18:42 -05:00
Родитель 3b6f2daca3 a341f81b61
Коммит 5b83d5f643
3 изменённых файлов: 195 добавлений и 0 удалений

88
locale/extract-po.py Executable file
Просмотреть файл

@ -0,0 +1,88 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Extract python and AMO template files into a .pot. Some ideas stolen from
http://dev.pocoo.org/projects/zine/browser/scripts/extract-messages
"""
from os import path
from babel.messages import Catalog
from babel.messages.extract import extract_from_dir
from babel.messages.pofile import write_po
from jinja2 import ext
KEYWORDS = {
'_': None,
'gettext': None,
'ngettext': (1, 2),
}
METHODS = [
('apps/**.py', 'python'),
('**/templates/**.html', 'extract-po:extract_amo_template'),
]
COMMENT_TAGS = ['L10n:']
def extract_amo_template(fileobj, keywords, comment_tags, options):
""" Extract localizable strings from a template (.html) file. We piggyback
on jinja2's babel_extract() function but tweak the output before it's
returned. Specifically, we strip whitespace from both ends of the msgid.
Jinja2 doesn't strip whitespace unless you specifically request it by
using dashes in your {% trans %}.
See babel_extract() for more details.
One thing missing from template extraction is developer comments for
localizers. babel_extract() does not support comments. Bug at
http://dev.pocoo.org/projects/jinja/ticket/362
"""
for lineno, funcname, message, comments in \
list(ext.babel_extract(fileobj, keywords, comment_tags, options)):
if isinstance(message, basestring):
message = message.strip()
elif isinstance(message, list):
message = [x.strip() for x in message if x is not None]
yield lineno, funcname, message, comments
def main():
root = path.abspath(path.join(path.dirname(__file__), path.pardir))
print "Extracting all strings (%s)..." % root
catalog = Catalog(
project="addons.mozilla.org",
copyright_holder="Mozilla Corporation",
msgid_bugs_address="dev-l10n-web@lists.mozilla.org",
last_translator="AMO Team <dev-l10n-web@lists.mozilla.org>",
language_team="AMO Team <dev-l10n-web@lists.mozilla.org>",
charset='utf-8')
def callback(filename, method, options):
if method != 'ignore':
print " %s" % filename
extracted = extract_from_dir(root, method_map=METHODS, keywords=KEYWORDS,
comment_tags=COMMENT_TAGS, callback=callback)
for filename, lineno, message, comments in extracted:
catalog.add(message, None, [(filename, lineno)],
auto_comments=comments)
f = file(path.join(root, 'locale', 'keys.pot'), 'w')
try:
write_po(f, catalog, width=79)
finally:
f.close()
print 'done'
if __name__ == '__main__':
main()

106
locale/keys.pot Normal file
Просмотреть файл

@ -0,0 +1,106 @@
# Translations template for addons.mozilla.org.
# Copyright (C) 2009 Mozilla Corporation
# This file is distributed under the same license as the addons.mozilla.org
# project.
# FIRST AUTHOR <EMAIL@ADDRESS>, 2009.
#
#, fuzzy
msgid ""
msgstr ""
"Project-Id-Version: addons.mozilla.org VERSION\n"
"Report-Msgid-Bugs-To: dev-l10n-web@lists.mozilla.org\n"
"POT-Creation-Date: 2009-12-28 16:27-0800\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=utf-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Generated-By: Babel 0.9.4\n"
#: apps/amo/templates/amo/paginator.html:10
msgid "Next"
msgstr ""
#: apps/amo/templates/amo/paginator.html:15
#, python-format
msgid ""
"Results <strong>%(begin)s</strong>&ndash;<strong>%(end)s</strong>\n"
" of %(count)s"
msgstr ""
#: apps/reviews/helpers.py:13
msgid "Not yet rated"
msgstr ""
#: apps/reviews/helpers.py:16
#, python-format
msgid "Rated %s out of 5 stars"
msgstr ""
#: apps/reviews/templates/reviews/navigation.html:4
msgid "Back to {0}"
msgstr ""
#: apps/reviews/templates/reviews/review_list.html:6
msgid "Reviews for {0}"
msgstr ""
#: apps/reviews/templates/reviews/review_list.html:17
#, python-format
msgid "by %(user)s on %(date)s"
msgstr ""
#: templates/base.html:4
msgid "Mozilla Add-ons"
msgstr ""
#: templates/categories.html:3
msgid "Categories"
msgstr ""
#: templates/header.html:5
#, python-format
msgid "Return to the %(app)s Add-ons homepage"
msgstr ""
#: templates/header.html:5
msgid "Firefox"
msgstr ""
#: templates/header.html:6
#, python-format
msgid ""
"Add-ons <em>for</em> <img alt=\"Firefox\" src=\"%(url)s\">\n"
" <strong>Firefox</strong>"
msgstr ""
#: templates/header.html:13 templates/header.html:14
msgid "Mozilla"
msgstr ""
#: templates/header.html:19
msgid "Find add-ons for other applications"
msgstr ""
#: templates/header.html:20
msgid "Other Applications"
msgstr ""
#: templates/search.html:5
msgid "search for add-ons"
msgstr ""
#: templates/search.html:6
msgid "within"
msgstr ""
#: templates/search.html:8
msgid "all add-ons"
msgstr ""
#: templates/user_login.html:2
#, python-format
msgid "<a href=\"%(reg)s\">Register</a> or <a href=\"%(login)s\">Log in</a>"
msgstr ""

Просмотреть файл

@ -3,6 +3,7 @@ Jinja2==2.2.1
MySQL-python==1.2.3c1
python-memcached==1.45
Werkzeug==0.5.1
Babel==0.9.4
Sphinx==0.6.3