Beispiel #1
0
from nose import with_setup
from nose.tools import eq_

import l10n
from l10n.tests.helpers import fake_extract_from_dir
from l10n import ugettext as _, ungettext as n_
from l10n import ugettext_lazy as _lazy, ungettext_lazy as n_lazy
from l10n.management.commands.extract import create_pofile_from_babel

LOCALEDIR = os.path.join('locale', 'xx')
MOFILE = os.path.join(LOCALEDIR, 'LC_MESSAGES', 'messages.mo')

# Used for the _lazy() tests
_lazy_strings = {}
_lazy_strings['nocontext'] = _lazy('this is a test')
_lazy_strings['context'] = _lazy('What time is it?', 'context_one')

n_lazy_strings = {}
n_lazy_strings['s_nocontext'] = n_lazy('one light !', 'many lights !', 1)
n_lazy_strings['p_nocontext'] = n_lazy('one light !', 'many lights !', 3)
n_lazy_strings['s_context'] = n_lazy('%d poodle please', '%d poodles please',
                                     1, 'context_one')
n_lazy_strings['p_context'] = n_lazy('%d poodle please', '%d poodles please',
                                     3, 'context_one')


# Stolen from jingo's test_helpers
def render(s, context={}):
    t = jingo.env.from_string(s)
    return t.render(**context)
Beispiel #2
0
from l10n import ugettext as _, ugettext_lazy as _lazy

import amo
from amo import helpers
from applications.models import AppVersion


types = (amo.ADDON_ANY, amo.ADDON_EXTENSION, amo.ADDON_THEME,
         amo.ADDON_DICT, amo.ADDON_SEARCH, amo.ADDON_LPAPP)

platforms = [platform.id for platform in
             amo.PLATFORMS.values() if platform.id != 0]

updated = (
    ('', _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 = (
    ('', _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')),