- Timestamp:
- Feb 26, 2019, 11:54:11 PM (5 years ago)
- Branches:
- current, feature/docs, master
- Children:
- 68d00f5
- Parents:
- e171dc2
- Location:
- ow
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
ow/templates/dashboard.pt
re171dc2 rac3af33 25 25 <section class="workout-list"> 26 26 27 <h3 tal:condition="viewing_month is not None"> 28 <tal:d tal:content="month_name[viewing_month] + ' ' + str(viewing_year)"></tal:d> - 27 <h3 tal:condition="viewing_month is not None" 28 tal:define="localizer get_localizer(request)"> 29 <tal:d tal:content="localizer.translate(month_name[viewing_month]) + ' ' + str(viewing_year)"></tal:d> - 29 30 <tal:n tal:content="len(workouts)"></tal:n> 30 31 <tal:t i18n:translate="">Workouts</tal:t> … … 174 175 <tal:months tal:repeat="month sorted(tree[year].keys())"> 175 176 <li tal:define="is_viewing_month is_viewing_year and month == viewing_month"> 176 <a href="" 177 tal:attributes="href request.resource_url(context, query={'year': year, 'month': month}); 178 class 'viewing-month' if is_viewing_month else ''"> 179 <span tal:content="month_name[month]"></span> 180 <span tal:content="sum([tree[year][month][sport] for sport in tree[year][month]])"></span> 181 </a> 177 <a href="" 178 tal:attributes="href request.resource_url(context, query={'year': year, 'month': month}); 179 class 'viewing-month' if is_viewing_month else ''" 180 tal:define="localizer get_localizer(request)"> 181 <span tal:content="localizer.translate(month_name[month])"></span> 182 <span tal:content="sum([tree[year][month][sport] for sport in tree[year][month]])"></span> 183 </a> 182 184 </li> 183 185 </tal:months> -
ow/utilities.py
re171dc2 rac3af33 282 282 283 283 284 def get_month_names(): 285 """ 286 Return a list with the names of the months, marked for translation. 287 288 This should be done automatically by the calendar module: 289 290 >>> import calendar 291 >>> calendar.month_name[1] 292 'January' 293 >>> 294 295 But even trying setting the proper locale (using locale.setlocale()), 296 in some operating systems the names are not translated (OpenBSD). 297 298 So, for now, we use this dirty trick 299 """ 300 return [ 301 '', 302 _('January'), 303 _('February'), 304 _('March'), 305 _('April'), 306 _('May'), 307 _('June'), 308 _('July'), 309 _('August'), 310 _('September'), 311 _('October'), 312 _('November'), 313 _('December') 314 ] 315 316 317 def get_week_day_names(): 318 """ 319 Return a list with the names of the week days, marked for translation. 320 321 As with get_month_names(), this is a dirty workaround for some locale 322 problem in some operating systems 323 """ 324 return [ 325 _('Monday'), 326 _('Tuesday'), 327 _('Wednesday'), 328 _('Thursday'), 329 _('Friday'), 330 _('Saturday'), 331 _('Sunday'), 332 ] 333 334 284 335 def part_of_day(dt): 285 336 """ -
ow/views/user.py
re171dc2 rac3af33 1 1 import json 2 from calendar import month_name3 2 from datetime import datetime, timezone, timedelta 4 3 from decimal import Decimal … … 25 24 timedelta_to_hms, 26 25 get_verification_token, 27 get_available_locale_names 26 get_gender_names, 27 get_available_locale_names, 28 get_month_names, 29 get_week_day_names 28 30 ) 29 31 from ..mail import send_verification_email 30 32 31 33 _ = TranslationStringFactory('OpenWorkouts') 34 month_name = get_month_names() 35 weekday_name = get_week_day_names() 32 36 33 37 … … 411 415 name='week') 412 416 def week_stats(context, request): 417 localizer = get_localizer(request) 413 418 stats = context.week_stats 414 419 json_stats = [] 415 420 for day in stats: 416 421 hms = timedelta_to_hms(stats[day]['time']) 422 name = localizer.translate(weekday_name[day.weekday()])[:3] 417 423 day_stats = { 418 'name': day.strftime('%a'),424 'name': name, 419 425 'time': str(hms[0]).zfill(2), 420 426 'distance': int(round(stats[day]['distance'])), … … 436 442 Return a json-encoded stream with statistics for the last 12 months 437 443 """ 444 localizer = get_localizer(request) 438 445 stats = context.yearly_stats 439 446 # this sets which month is 2 times in the stats, once this year, once … … 444 451 for month in stats: 445 452 hms = timedelta_to_hms(stats[month]['time']) 446 name = month_name[month[1]][:3]453 name = localizer.translate(month_name[month[1]])[:3] 447 454 if month[1] == repeated_month: 448 455 name += ' ' + str(month[0]) … … 473 480 in a per-week basis 474 481 """ 482 localizer = get_localizer(request) 475 483 stats = context.weekly_year_stats 476 484 # this sets which month is 2 times in the stats, once this year, once … … 481 489 for week in stats: 482 490 hms = timedelta_to_hms(stats[week]['time']) 483 name = month_name[week[1]][:3]491 name = localizer.translate(month_name[week[1]])[:3] 484 492 if week[1] == repeated_month: 485 493 name += ' ' + str(week[0])
Note: See TracChangeset
for help on using the changeset viewer.