Skip to content

Commit

Permalink
Complete Norwegian translation (kill me now)
Browse files Browse the repository at this point in the history
  • Loading branch information
TheBB committed Mar 10, 2014
1 parent e81824f commit 276f286
Show file tree
Hide file tree
Showing 11 changed files with 1,593 additions and 362 deletions.
149 changes: 85 additions & 64 deletions aligulac/aligulac/tools.py
Expand Up @@ -24,6 +24,7 @@
)
from ratings.tools import get_latest_period
from ratings.templatetags.ratings_extras import urlfilter
from django.utils.translation import ugettext as _
# }}}

# {{{ Message
Expand Down Expand Up @@ -77,20 +78,40 @@ def __init__(self, search, players, update=None, updateline=None, type='error'):

num = 5
if len(lst) < num:
s = 'Possible matches: ' + ', '.join(lst[:-1]) + ' and ' + lst[-1] + '.'
s = (
# Translators: matches as in search matches, not SC2 matches
_('Possible matches:') + ' ' +
# Translators: E.g. "John, Lisa, Darren and Mike"
_('%(commalist)s and %(final)s') % {
'commalist': ', '.join(lst[:-1]),
'final': lst[-1]
} +
'.'
)
else:
rand = ''.join(random.choice(string.ascii_lowercase) for _ in range(10))

# Yes, I know this is ugly as seven hells. -- TheBB
s = (
'Possible matches: <span id="%s-a">' % rand + ', '.join(lst[:num-1]) +
' and <a href="#" onclick="togvis(\'%s-a\',\'none\'); ' % rand +
'togvis(\'%s-b\',\'inline\'); return false;">' % rand +
'%i more</a></span>' % (len(lst) - num + 1) +
'<span id="%s-b" style="display: none;">%s</span>' %
(rand, ', '.join(lst[:-1]) + ' and ' + lst[-1]) +
'.'
_('Possible matches:') + ' ' +
# Translators: E.g. "John, Lisa, Darren, Mike and 5 more"
_('%(commalist)s and %(number)s more') % {
'commalist': '<span id="%s-a">' % rand + ', '.join(lst[:num-1]),
'number':
' <a href="#" onclick="togvis(\'%s-a\',\'none\'); ' % rand +
'togvis(\'%s-b\',\'inline\'); return false;">' % rand +
'%i' % (len(lst) - num + 1)
} +
'</a></span><span id="%s-b" style="display: none;">%s</span>' % (
rand,
_('%(commalist)s and %(final)s') % {
'commalist': ', '.join(lst[:-1]),
'final': lst[-1]
}
) + '.'
)

Message.__init__(self, s, '\'%s\' not unique' % search, type)
Message.__init__(self, s, _('\'%s\' not unique') % search, type)
self.id = id
# }}}

Expand All @@ -102,12 +123,14 @@ def generate_messages(obj):
# {{{ login_message: Generates a message notifying about login status.
def login_message(base, extra=''):
if not base['adm']:
text = ' '.join(['You are not logged in.', extra, '(<a href="/login/">login</a>)'])
text = ' '.join([_('You are not logged in.'), extra, '(<a href="/login/">login</a>)'])
else:
text = ' '.join([
'You are logged in as',
base['user'],
'(<a href="/logout/">logout</a>, <a href="/changepwd/">change password</a>)'
_('You are logged in as %s') % base['user'],
'(<a href="/logout/">%s</a>, <a href="/changepwd/">%s</a>)' % (
_('logout'),
_('change password')
)
])
base['messages'].append(Message(text, type=Message.INFO))
# }}}
Expand All @@ -119,7 +142,7 @@ def clean(self, value):
if value is not None:
value = value.strip()
if self.required and value == '':
raise ValidationError('This field is required.')
raise ValidationError(_('This field is required.'))
elif value == '':
return None
return value
Expand Down Expand Up @@ -183,82 +206,80 @@ def post_param(request, param, default):
def base_ctx(section=None, subpage=None, request=None, context=None):
curp = get_latest_period()

menu = [
('Ranking', '/periods/latest/'),
('Teams', '/teams/'),
('Records', '/records/history'),
('Results', '/results/'),
('Reports', '/reports/'),
('Inference', '/inference/'),
('About', '/faq/'),
('Submit', '/add/'),
]

base = {
'curp': curp,
'menu': menu,
'debug': DEBUG,
'cur_path': request.get_full_path(),
'messages': [],
'lang': request.LANGUAGE_CODE,
'menu': [{
'name': 'Ranking',
'id': 'Ranking',
'name': _('Ranking'),
'url': '/periods/latest/',
'submenu': [
('Current', '/periods/latest/'),
('History', '/periods/'),
('Earnings', '/earnings/'),
('Current', _('Current'), '/periods/latest/'),
('History', _('History'), '/periods/'),
('Earnings', _('Earnings'), '/earnings/'),
]}, {
'name': 'Teams',
'id': 'Teams',
'name': _('Teams'),
'url': '/teams/',
'submenu': [
('Ranking', '/teams/'),
('Transfers', '/transfers/'),
('Ranking', _('Ranking'), '/teams/'),
('Transfers', _('Transfers'), '/transfers/'),
]}, {
'name': 'Records',
'id': 'Records',
'name': _('Records'),
'url': '/records/history/',
'submenu': [
('History', '/records/history/'),
('HoF', '/records/hof/'),
('All', '/records/race/?race=all'),
('Protoss', '/records/race/?race=P'),
('Terran', '/records/race/?race=T'),
('Zerg', '/records/race/?race=Z'),
('History', _('History'), '/records/history/'),
# Translators: Hall of fame
('HoF', _('HoF'), '/records/hof/'),
('All', _('All'), '/records/race/?race=all'),
('Protoss', _('Protoss'), '/records/race/?race=P'),
('Terran', _('Terran'), '/records/race/?race=T'),
('Zerg', _('Zerg'), '/records/race/?race=Z'),
]}, {
'name': 'Results',
'id': 'Results',
'name': _('Results'),
'url': '/results/',
'submenu': [
('By Date', '/results/'),
('By Event', '/results/events/'),
('Search', '/results/search/'),
('By Date', _('By Date'), '/results/'),
('By Event', _('By Event'), '/results/events/'),
('Search', _('Search'), '/results/search/'),
]}, {
'name': 'Inference',
'id': 'Inference',
'name': _('Inference'),
'url': '/inference/',
'submenu': [
('Predict', '/inference/'),
('Predict', _('Predict'), '/inference/'),
]}, {
'name': 'Misc',
'id': 'Misc',
'name': _('Misc'),
'url': '/misc/',
'submenu': [
('Balance Report', '/misc/balance/'),
('Days Since...', '/misc/days/'),
('Balance Report', _('Balance Report'), '/misc/balance/'),
('Days Since…', _('Days Since…'), '/misc/days/'),
]}, {
'name': 'About',
'id': 'About',
'name': _('About'),
'url': '/about/faq/',
'submenu': [
('FAQ', '/about/faq/'),
('Blog', '/about/blog/'),
('Database', '/about/db/'),
('API', '/about/api/'),
('FAQ', _('FAQ'), '/about/faq/'),
('Blog', _('Blog'), '/about/blog/'),
('Database', _('Database'), '/about/db/'),
('API', _('API'), '/about/api/'),
]}, {
'name': 'Submit',
'id': 'Submit',
'name': _('Submit'),
'url': '/add/',
'submenu': [
('Matches', '/add/'),
('Review', '/add/review/'),
('Events', '/add/events/'),
('Open events', '/add/open_events/'),
('Misc', '/add/misc/'),
# Translators: Matches as in SC2-matches, not search matches.
('Matches', _('Matches'), '/add/'),
('Review', _('Review'), '/add/review/'),
('Events', _('Events'), '/add/events/'),
('Open events', _('Open events'), '/add/open_events/'),
('Misc', _('Misc'), '/add/misc/'),
]}]
}
base.update({"subnav": None})
Expand Down Expand Up @@ -299,15 +320,15 @@ def add_subnav(title, url):
add_subnav('Summary', base_url)

if rating is not None:
add_subnav('Rating history', base_url + 'historical/')
add_subnav(_('Rating history'), base_url + 'historical/')

add_subnav('Match history', base_url + 'results/')
add_subnav(_('Match history'), base_url + 'results/')

if context.has_earnings():
add_subnav('Earnings', base_url + 'earnings/')
add_subnav(_('Earnings'), base_url + 'earnings/')

if rating is not None:
add_subnav('Adjustments', base_url + 'period/%i/' % rating.period.id)
add_subnav(_('Adjustments'), base_url + 'period/%i/' % rating.period.id)

return base
# }}}
Expand Down
15 changes: 7 additions & 8 deletions aligulac/aligulac/views.py
Expand Up @@ -61,6 +61,12 @@
def home(request):
base = base_ctx(request=request)

if request.LANGUAGE_CODE != 'en':
base['messages'].append(Message(
_('The blog/news section is only in English, sorry.'),
type=Message.INFO,
))

entries = filter_active(Rating.objects.filter(period=base['curp']))\
.order_by('-rating')\
.select_related('player')[0:10]
Expand Down Expand Up @@ -189,13 +195,6 @@ def add_key(self):
def api(request):
base = base_ctx('About', 'API', request)

#base['messages'].append(Message(
#'The API is currently in beta. Do not rely on it in production yet! We may disable features without '
#'prior warning until the release of version 1. When this happens, the root URL will be changed to '
#'<code>/api/v1/</code> and the beta URL will be removed.',
#type=Message.WARNING,
#))

if request.method == 'POST':
form = APIKeyForm(request)
base['messages'] += form.add_key()
Expand Down Expand Up @@ -249,7 +248,7 @@ def search(request):
'query': query,
})

base.update({"title": _("Search results")})
base.update({'title': _('Search results')})

return render_to_response('search.html', base)
# }}}
Expand Down
13 changes: 12 additions & 1 deletion aligulac/blog/views.py
@@ -1,12 +1,23 @@
from django.shortcuts import render_to_response
from django.utils.translation import ugettext as _

from aligulac.cache import cache_page
from aligulac.tools import base_ctx
from aligulac.tools import (
base_ctx,
Message,
)

from blog.models import Post

@cache_page
def blog(request):
base = base_ctx('About', 'Blog', request)

if request.LANGUAGE_CODE != 'en':
base['messages'].append(Message(
_('The blog/news section is only in English, sorry.'),
type=Message.INFO,
))

base['blogposts'] = Post.objects.all()[:10]
return render_to_response('blog.html', base)

0 comments on commit 276f286

Please sign in to comment.