use lazy translations where we need them

This commit is contained in:
Jeff Balogh 2010-03-04 10:41:07 -08:00
Родитель a9362c4571
Коммит 25c3062b76
4 изменённых файлов: 60 добавлений и 57 удалений

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

@ -3,7 +3,7 @@ Miscellaneous helpers that make Django compatible with AMO.
"""
from licenses import license_text
from l10n import ugettext as _
from l10n import ugettext_lazy as _
class cached_property(object):
@ -109,25 +109,25 @@ ADDON_PERSONA = 9
# Singular
ADDON_TYPE = {
ADDON_ANY: _('Any'),
ADDON_EXTENSION: _('Extension'),
ADDON_THEME: _('Theme'),
ADDON_DICT: _('Dictionary'),
ADDON_SEARCH: _('Search Engine'),
ADDON_PLUGIN: _('Plugin'),
ADDON_LPAPP: _('Language Pack (Application)'),
ADDON_PERSONA: _('Persona'),
ADDON_ANY: _(u'Any'),
ADDON_EXTENSION: _(u'Extension'),
ADDON_THEME: _(u'Theme'),
ADDON_DICT: _(u'Dictionary'),
ADDON_SEARCH: _(u'Search Engine'),
ADDON_PLUGIN: _(u'Plugin'),
ADDON_LPAPP: _(u'Language Pack (Application)'),
ADDON_PERSONA: _(u'Persona'),
}
# Plural
ADDON_TYPES = {
ADDON_ANY: _('Any'),
ADDON_EXTENSION: _('Extensions'),
ADDON_THEME: _('Themes'),
ADDON_DICT: _('Dictionaries & Language Packs'),
ADDON_SEARCH: _('Search Tools'),
ADDON_PLUGIN: _('Plugins'),
ADDON_PERSONA: _('Personas'),
ADDON_ANY: _(u'Any'),
ADDON_EXTENSION: _(u'Extensions'),
ADDON_THEME: _(u'Themes'),
ADDON_DICT: _(u'Dictionaries & Language Packs'),
ADDON_SEARCH: _(u'Search Tools'),
ADDON_PLUGIN: _(u'Plugins'),
ADDON_PERSONA: _(u'Personas'),
}
@ -135,7 +135,7 @@ ADDON_TYPES = {
class FIREFOX:
id = 1
short = 'firefox'
pretty = _('Firefox')
pretty = _(u'Firefox')
browser = True
types = [ADDON_EXTENSION, ADDON_THEME, ADDON_DICT, ADDON_SEARCH,
ADDON_PLUGIN, ADDON_PERSONA]
@ -145,7 +145,7 @@ class FIREFOX:
class THUNDERBIRD:
id = 18
short = 'thunderbird'
pretty = _('Thunderbird')
pretty = _(u'Thunderbird')
browser = True
types = [ADDON_EXTENSION, ADDON_THEME, ADDON_DICT, ADDON_PERSONA]
guid = '{3550f703-e582-4d05-9a08-453d09bdfdc6}'
@ -153,7 +153,7 @@ class THUNDERBIRD:
class SEAMONKEY:
id = 59
short = 'seamonkey'
pretty = _('SeaMonkey')
pretty = _(u'SeaMonkey')
browser = True
types = [ADDON_EXTENSION, ADDON_THEME, ADDON_DICT, ADDON_SEARCH,
ADDON_PLUGIN]
@ -163,7 +163,7 @@ class SEAMONKEY:
class SUNBIRD:
id = 52
short = 'sunbird'
pretty = _('Sunbird')
pretty = _(u'Sunbird')
types = [ADDON_EXTENSION, ADDON_THEME, ADDON_DICT]
guid = '{718e30fb-e89b-41dd-9da7-e25a45638b28}'
@ -171,7 +171,7 @@ class SUNBIRD:
class MOBILE:
id = 60
short = 'mobile'
pretty = _('Mobile')
pretty = _(u'Mobile')
browser = True
types = [ADDON_EXTENSION, ADDON_THEME, ADDON_DICT, ADDON_SEARCH]
guid = '{a23983c0-fd0e-11dc-95ff-0800200c9a66}'
@ -184,7 +184,7 @@ class MOZILLA:
"""
id = 2
short = 'mz'
pretty = _('Mozilla')
pretty = _(u'Mozilla')
browser = True
types = [ADDON_EXTENSION, ADDON_THEME, ADDON_DICT, ADDON_SEARCH,
ADDON_PLUGIN]
@ -219,13 +219,13 @@ PLATFORMS = {
'sun': PLATFORM_SUN,
'sunos': PLATFORM_SUN,
'solaris': PLATFORM_SUN,
PLATFORM_ANY: _('Any'),
PLATFORM_ALL: _('All'),
PLATFORM_LINUX: _('Linux'),
PLATFORM_MAC: _('Mac OS X'),
PLATFORM_BSD: _('BSD'),
PLATFORM_WIN: _('Windows'),
PLATFORM_SUN: _('Solaris'),
PLATFORM_ANY: _(u'Any'),
PLATFORM_ALL: _(u'All'),
PLATFORM_LINUX: _(u'Linux'),
PLATFORM_MAC: _(u'Mac OS X'),
PLATFORM_BSD: _(u'BSD'),
PLATFORM_WIN: _(u'Windows'),
PLATFORM_SUN: _(u'Solaris'),
}
# Built-in Licenses
@ -243,25 +243,25 @@ class LICENSE_CUSTOM(_LicenseBase):
licenses
"""
id = -1
name = _('Custom License')
name = _(u'Custom License')
url = None
shortname = None
class LICENSE_MPL(_LicenseBase):
id = 0
name = _('Mozilla Public License, version 1.1')
name = _(u'Mozilla Public License, version 1.1')
url = 'http://www.mozilla.org/MPL/MPL-1.1.html'
shortname = 'mpl'
class LICENSE_GPL2(_LicenseBase):
id = 1
name = _('GNU General Public License, version 2.0')
name = _(u'GNU General Public License, version 2.0')
url = 'http://www.gnu.org/licenses/gpl-2.0.html'
shortname = 'gpl2'
class LICENSE_GPL3(_LicenseBase):
id = 2
name = _('GNU General Public License, version 3.0')
name = _(u'GNU General Public License, version 3.0')
url = 'http://www.gnu.org/licenses/gpl-3.0.html'
shortname = 'gpl3'
@ -273,19 +273,19 @@ class LICENSE_LGPL21(_LicenseBase):
class LICENSE_LGPL3(_LicenseBase):
id = 4
name = _('GNU Lesser General Public License, version 3.0')
name = _(u'GNU Lesser General Public License, version 3.0')
url = 'http://www.gnu.org/licenses/lgpl-3.0.html'
shortname = 'lgpl3'
class LICENSE_MIT(_LicenseBase):
id = 5
name = _('MIT/X11 License')
name = _(u'MIT/X11 License')
url = 'http://www.opensource.org/licenses/mit-license.php'
shortname = 'mit'
class LICENSE_BSD(_LicenseBase):
id = 6
name = _('BSD License')
name = _(u'BSD License')
url = 'http://www.opensource.org/licenses/bsd-license.php'
shortname = 'bsd'

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

@ -7,7 +7,7 @@ import datetime
from django.http import HttpResponse, HttpResponsePermanentRedirect
from django.utils import translation
from l10n import ugettext as _
from l10n import ugettext as _, ugettext_lazy
import jingo
@ -17,8 +17,9 @@ from addons.models import Addon
from search.client import Client as SearchClient, SearchError
ERROR = 'error'
OUT_OF_DATE = _("The API version, {0:.1f}, you are using is not valid. "
"Please upgrade to the current version {1:.1f} API.")
OUT_OF_DATE = ugettext_lazy(
u"The API version, {0:.1f}, you are using is not valid. "
u"Please upgrade to the current version {1:.1f} API.")
def validate_api_version(version):

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

@ -1,7 +1,7 @@
import collections
import itertools
from l10n import ugettext as _
from l10n import ugettext as _, ugettext_lazy as _lazy
import jingo
import product_details
@ -85,10 +85,10 @@ class AddonSorter(object):
self.opts: all the sort options
self.qs: the sorted queryset
"""
opts = (('name', _('Name')),
('date', _('Date')),
('downloads', _('Downloads')),
('rating', _('Rating')))
opts = (('name', _lazy(u'Name')),
('date', _lazy(u'Date')),
('downloads', _lazy(u'Downloads')),
('rating', _lazy(u'Rating')))
def __init__(self, request, queryset, default):
self.sorting = self.options(request, default)

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

@ -3,7 +3,7 @@ import itertools
from django import forms
from l10n import ugettext as _
from l10n import ugettext as _, ugettext_lazy as _lazy
import amo
from amo import helpers
@ -17,21 +17,22 @@ platforms = (amo.PLATFORM_ANY, amo.PLATFORM_BSD, amo.PLATFORM_LINUX,
amo.PLATFORM_MAC, amo.PLATFORM_SUN, amo.PLATFORM_WIN)
updated = (
('', _('Any time')),
('1 day ago', _('Past Day')),
('1 week ago', _('Past Week')),
('1 month ago', _('Past Month')),
('3 months ago', _('Past 3 Months')),
('6 months ago', _('Past 6 Months')),
('1 year ago', _('Past Year')),
('', _lazy(u'Any time')),
('1 day ago', _lazy(u'Past Day')),
('1 week ago', _lazy(u'Past Week')),
('1 month ago', _lazy(u'Past Month')),
('3 months ago', _lazy(u'Past 3 Months')),
('6 months ago', _lazy(u'Past 6 Months')),
('1 year ago', _lazy(u'Past Year')),
)
sort_by = (
('', _('Keyword Match')),
('newest', _('Newest', 'advanced_search_form_newest')),
('name', _('Name', 'advanced_search_form_name')),
('averagerating', _('Rating', 'advanced_search_form_rating')),
('weeklydownloads', _('Popularity', 'advanced_search_form_popularity')),
('', _lazy(u'Keyword Match')),
('newest', _lazy(u'Newest', 'advanced_search_form_newest')),
('name', _lazy(u'Name', 'advanced_search_form_name')),
('averagerating', _lazy(u'Rating', 'advanced_search_form_rating')),
('weeklydownloads', _lazy(u'Popularity',
'advanced_search_form_popularity')),
)
per_page = (20, 50, 100)
@ -65,6 +66,7 @@ def get_app_versions():
# Fake categories to slip some add-on types into the search groups.
_Cat = collections.namedtuple('Cat', 'id name weight type_id')
def get_search_groups(app):
sub = []
for type_ in (amo.ADDON_DICT, amo.ADDON_SEARCH, amo.ADDON_THEME):