How to use l18n - 2 common examples

To help you get started, we’ve selected a few l18n examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github wagtail / wagtail / wagtail / admin / auth.py View on Github external
def decorated_view(request, *args, **kwargs):
        user = request.user

        if user.is_anonymous:
            return reject_request(request)

        if user.has_perms(['wagtailadmin.access_admin']):
            preferred_language = None
            if hasattr(user, 'wagtail_userprofile'):
                preferred_language = user.wagtail_userprofile.get_preferred_language()
                l18n.set_language(preferred_language)
                time_zone = user.wagtail_userprofile.get_current_time_zone()
                activate_tz(time_zone)
            if preferred_language:
                with override(preferred_language):
                    return view_func(request, *args, **kwargs)
            else:
                return view_func(request, *args, **kwargs)

        if not request.is_ajax():
            messages.error(request, _('You do not have permission to access the admin'))

        return reject_request(request)
github wagtail / wagtail / wagtail / users / forms.py View on Github external
def _get_time_zone_choices():
    time_zones = [(tz, str(l18n.tz_fullnames.get(tz, tz)))
                  for tz in get_available_admin_time_zones()]
    time_zones.sort(key=itemgetter(1))
    return BLANK_CHOICE_DASH + time_zones

l18n

Internationalization for pytz timezones and territories

MIT
Latest version published 3 years ago

Package Health Score

49 / 100
Full package analysis

Popular l18n functions