Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/Pootle-2.0.0/local_apps/pootle_app/views/pagelayout.py
blob: 8532a15132a57e3e14198843a549e3d93acd7e6d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# Copyright 2004-2009 Zuza Software Foundation
#
# This file is part of Virtaal.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, see <http://www.gnu.org/licenses/>.

from django.conf import settings
from django.utils.html import escape
from django.utils.translation import ugettext as _

def get_title():
    return _(settings.TITLE)

def get_description():
    return _(settings.DESCRIPTION)

def getdoclang(language):
    """Get the language code that the docs should be displayed in."""

    # TODO: Determine the available languages programmatically.
    available_languages = ['en']
    if language in available_languages:
        return language
    else:
        return 'en'

def weblanguage(language):
    """Reformats the language code from locale style (pt_BR) to web
    style (pt-br)"""

    return language.replace('_', '-')


def completetemplatevars(templatevars, request):
    """fill out default values for template variables"""

    if not 'instancetitle' in templatevars:
        templatevars['instancetitle'] = get_title()
    templatevars['request'] = request
    if not 'mediaurl' in templatevars:
        templatevars['mediaurl'] = settings.MEDIA_URL
    if not 'enablealtsrc' in templatevars:
        templatevars['enablealtsrc'] = settings.ENABLE_ALT_SRC
    templatevars['uilanguage'] = weblanguage(request.LANGUAGE_CODE)
    try:
        templatevars['username'] = templatevars['username']
    except:
        templatevars['username'] = ''
    templatevars['canregister'] = settings.CAN_REGISTER
    templatevars['current_url'] = request.path_info
    if 'user' not in templatevars:
        templatevars['user'] = request.user
    if 'search' not in templatevars:
        templatevars['search'] = None
    templatevars['message'] = escape(request.GET.get('message', ''))