Add translation support to cards template tags.

This commit is contained in:
Christopher C. Wells 2019-04-16 19:38:31 -07:00
parent 9114a2d911
commit 46846ace4f
1 changed files with 8 additions and 7 deletions

View File

@ -3,6 +3,7 @@ from django import template
from django.db.models import Avg, Count, Sum from django.db.models import Avg, Count, Sum
from django.db.models.functions import TruncDate from django.db.models.functions import TruncDate
from django.utils import timezone from django.utils import timezone
from django.utils.translation import gettext as _
from core import models from core import models
@ -163,39 +164,39 @@ def card_statistics(child):
stats.append({ stats.append({
'type': 'duration', 'type': 'duration',
'stat': changes['btwn_average'], 'stat': changes['btwn_average'],
'title': 'Diaper change frequency'}) 'title': _('Diaper change frequency')})
feedings = _feeding_statistics(child) feedings = _feeding_statistics(child)
stats.append({ stats.append({
'type': 'duration', 'type': 'duration',
'stat': feedings['btwn_average'], 'stat': feedings['btwn_average'],
'title': 'Feeding frequency'}) 'title': _('Feeding frequency')})
naps = _nap_statistics(child) naps = _nap_statistics(child)
stats.append({ stats.append({
'type': 'duration', 'type': 'duration',
'stat': naps['average'], 'stat': naps['average'],
'title': 'Average nap duration'}) 'title': _('Average nap duration')})
stats.append({ stats.append({
'type': 'float', 'type': 'float',
'stat': naps['avg_per_day'], 'stat': naps['avg_per_day'],
'title': 'Average naps per day'}) 'title': _('Average naps per day')})
sleep = _sleep_statistics(child) sleep = _sleep_statistics(child)
stats.append({ stats.append({
'type': 'duration', 'type': 'duration',
'stat': sleep['average'], 'stat': sleep['average'],
'title': 'Average sleep duration'}) 'title': _('Average sleep duration')})
stats.append({ stats.append({
'type': 'duration', 'type': 'duration',
'stat': sleep['btwn_average'], 'stat': sleep['btwn_average'],
'title': 'Average awake duration'}) 'title': _('Average awake duration')})
weight = _weight_statistics(child) weight = _weight_statistics(child)
stats.append({ stats.append({
'type': 'float', 'type': 'float',
'stat': weight['change_weekly'], 'stat': weight['change_weekly'],
'title': 'Weight change per week'}) 'title': _('Weight change per week')})
return {'stats': stats} return {'stats': stats}