Closed igorsimb closed 4 months ago
Also, should probably remove {scrape_interval_task.name}
from request.session["scrape_interval_task"]
Maybe in future we'll give user the ability to name the interval tasks when we have the ability to create more than one.
Code reponsible for the format is the __str__
method of IntervalSchedule
class
def __str__(self):
readable_period = None
if self.every == 1:
for period, _readable_period in SINGULAR_PERIODS:
if period == self.period:
readable_period = _readable_period.lower()
break
return _('every {}').format(readable_period)
for period, _readable_period in PERIOD_CHOICES:
if period == self.period:
readable_period = _readable_period.lower()
break
return _('every {} {}').format(self.every, readable_period)
IntervalSchedule
class that is inherited from the original__str__
methodget_russian_translation
function and include it into the __str__
method
from django.utils.translation import ugettext_lazy as _
from django_celery_beat.models import IntervalSchedule
class CustomIntervalSchedule(IntervalSchedule): def str(self):
# You can access self.every and self.period for customization
readable_period = self.get_russian_translation() # Your translation function
if self.every == 1:
return _('every {}').format(readable_period.lower())
return _('every {} {}').format(self.every, readable_period.lower())
As an example, see https://github.com/celery/django-celery-beat/pull/272/files Also check how django.contrib.humanize did their .po file for Russian
Related to https://github.com/igorsimb/mp-monitor/issues/115
Currently we have this in
create_scrape_interval_task
viewscrape_interval_task.interval
displays the translated version, but case (падеж) is incorrect.We can change it to this:
This will show as the fullowing: "scrape_interval_task_admin - каждые 34 seconds", i.e.
scrape_interval_task.interval.every
is the number that user put into the formscrape_interval_task.interval.period
- the period type (seconds, minutes, days, etc) that user picked NOT TRANSLATEDA potential solution could be a util function with
if-then
statements to make sure everything is displayed in accordance with Russian grammar.