Changeset ac3af33 in OpenWorkouts-current for ow/templates/dashboard.pt


Ignore:
Timestamp:
Feb 26, 2019, 11:54:11 PM (5 years ago)
Author:
Borja Lopez <borja@…>
Branches:
current, feature/docs, master
Children:
68d00f5
Parents:
e171dc2
Message:

(#69) Ensure month and weekday names are translated.

This is a dirty hack, which basically uses static strings marked for
translation within openworkouts, instead of relying on the python
locale and calendar translations.

We need this hack, as in some operating systems (OpenBSD), using
locale.setlocale() does not make any difference when using calendar.month_name
(names appear always in the system locale/LANG).

File:
1 edited

Legend:

Unmodified
Added
Removed
  • ow/templates/dashboard.pt

    re171dc2 rac3af33  
    2525      <section class="workout-list">
    2626
    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> -
    2930          <tal:n tal:content="len(workouts)"></tal:n>
    3031          <tal:t i18n:translate="">Workouts</tal:t>
     
    174175                              <tal:months tal:repeat="month sorted(tree[year].keys())">
    175176                                  <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>
    182184                                  </li>
    183185                              </tal:months>
Note: See TracChangeset for help on using the changeset viewer.