Add translation for rating level names

This commit is contained in:
Quantum 2021-10-03 02:27:32 -04:00 committed by Guanzhong Chen
parent 48798cfc4a
commit 218993fd3e
2 changed files with 13 additions and 2 deletions

View File

@ -1,3 +1,5 @@
from django.utils.translation import gettext_lazy as _
from judge.ratings import rating_class, rating_name, rating_progress
from . import registry
@ -19,7 +21,7 @@ def get_rating_class(obj):
@registry.function(name='rating_name')
def get_name(obj):
return _get_rating_value(rating_name, obj) or 'Unrated'
return _get_rating_value(rating_name, obj) or _('Unrated')
@registry.function(name='rating_progress')

View File

@ -6,6 +6,7 @@ from django.db import transaction
from django.db.models import Count, OuterRef, Subquery
from django.db.models.functions import Coalesce
from django.utils import timezone
from django.utils.translation import gettext_lazy
BETA2 = 328.33 ** 2
@ -189,7 +190,15 @@ def rate_contest(contest):
.order_by('-contest__end_time').values('rating')[:1]))
RATING_LEVELS = ['Newbie', 'Amateur', 'Expert', 'Candidate Master', 'Master', 'Grandmaster', 'Target']
RATING_LEVELS = [
gettext_lazy('Newbie'),
gettext_lazy('Amateur'),
gettext_lazy('Expert'),
gettext_lazy('Candidate Master'),
gettext_lazy('Master'),
gettext_lazy('Grandmaster'),
gettext_lazy('Target'),
]
RATING_VALUES = [1000, 1300, 1600, 1900, 2400, 3000]
RATING_CLASS = ['rate-newbie', 'rate-amateur', 'rate-expert', 'rate-candidate-master',
'rate-master', 'rate-grandmaster', 'rate-target']