<!--!  Copyright (C) 2006-2014 Edgewall Software

  This software is licensed as described in the file COPYING, which
  you should have received as part of this distribution. The terms
  are also available at http://trac.edgewall.com/license.html.

  This software consists of voluntary contributions made by many
  individuals. For the exact contribution history, see the revision
  history and logs, available at http://trac.edgewall.org/.
-->
<!DOCTYPE html
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:py="http://genshi.edgewall.org/"
      xmlns:i18n="http://genshi.edgewall.org/i18n"
      xmlns:xi="http://www.w3.org/2001/XInclude">
  <xi:include href="prefs.html" />
  <head>
    <title>Localization</title>
  </head>
  <body>

    <table py:with="session_tzname = session.get('tz');
                    selected_tz = timezone(session_tzname) or utc">

      <tr class="field">
        <th><label for="language">Language:</label></th>
        <td>
          <select py:with="session_language = session.get('language', '').replace('-', '_')"
                  id="language" name="language" disabled="${'disabled' if not languages else None}"
                  title="${_('Translations are currently unavailable') if not languages else None}">
            <option value="">Default language</option>
            <option py:for="locale, language in languages"
                    selected="${session_language == locale or None}"
                    value="$locale">$language</option>
          </select>
          <py:if test="'TRAC_ADMIN' in req.perm">
            <span py:if="not has_babel" class="hint">
              Install Babel for extended language support.
            </span>
            <span py:if="has_babel and not languages" class="hint">
              Message catalogs have not been compiled.
            </span>
          </py:if>
        </td>
      </tr>
      <tr>
        <th></th>
        <td py:if="languages">
          <p class="hint" i18n:msg="">Configuring your language will result <!--!
          -->in all text displayed on this site to use your language instead <!--!
          -->of that of the server.</p>
          <p class="hint" i18n:msg="">The <strong>Default language</strong> <!--!
          -->option uses the browser's language negotiation feature to select <!--!
          -->the appropriate language.</p>
        </td>
        <td py:if="not languages">
          <p class="hint" xml:lang="en">
            <py:choose>
              <py:when test="'TRAC_ADMIN' in req.perm">
                Trac has been localized to more than a dozen of languages but in order
                to be able to use them, the <a href="http://babel.edgewall.org">Babel</a>
                package needs to be present when installing Trac. See
                <a href="${href.wiki('TracInstall')}">TracInstall</a> for details.
              </py:when>
              <py:otherwise>
                Please contact your
                <a py:strip="not project.admin" href="mailto:${project.admin}">Trac administrator</a>
                to enable existing translations.
              </py:otherwise>
            </py:choose>
          </p>
        </td>
      </tr>

      <tr class="field">
        <th><label for="tz">Time zone:</label></th>
        <td><select id="tz" name="tz">
          <option value="">Default time zone</option>
          <option py:for="tzname in timezones" value="$tzname"
                  selected="${session_tzname is not None and
                              session_tzname.startswith('Etc/') and
                              selected_tz == timezone(tzname) or
                              session_tzname == tzname or None}">$tzname</option>
        </select></td>
      </tr>
      <tr>
        <th></th>
        <td>
          <p class="hint" i18n:msg="">Configuring your time zone will <!--!
          -->result in all dates and times displayed on this site to <!--!
          -->use your time zone instead of that of the server.</p>
          <!-- This currently crashes Genshi's extractor if you add i18n:msg -->
          <p class="hint" py:with="now = datetime.now(utc);
                                   nowtz = selected_tz.normalize(now.astimezone(selected_tz));
                                   formatted = format_time(now, 'iso8601', tzinfo=req.tz)"
                          py:choose="">
            <i18n:msg params="time">
              Example: The current time is <strong>${format_time(now, 'iso8601', tzinfo=utc)}</strong> (UTC).
            </i18n:msg>
            <br />
            <py:when test="session_tzname">
              <i18n:msg params="tz, formatted">
                In your time zone ${nowtz.tzname()}, this would be displayed as <!--!
                --><strong>$formatted</strong>.
              </i18n:msg>
            </py:when>
            <py:otherwise>
              <i18n:msg params="formatted">
                In the default time zone, this would be displayed as <strong>$formatted</strong>.
              </i18n:msg>
            </py:otherwise>
          </p>
          <p class="hint" i18n:msg="">
            Note: Universal Co-ordinated Time (UTC) is also known as <!--!
            -->Greenwich Mean Time (GMT).<br />A positive offset is <!--!
            -->used to indicate a timezone at the east of Greenwich, <!--!
            -->i.e. ahead of Universal Time.
          </p>
        </td>
      </tr>

      <tr class="field" py:with="session_lc_time = session.get('lc_time')">
        <th><label for="lc_time">Date format:</label></th>
        <td><select id="lc_time" name="lc_time">
          <option value="">Default date format</option>
          <option value="locale" py:if="locales and languages"
                  selected="${session_lc_time == 'locale' or None}">Your language setting</option>
          <option value="iso8601"
                  selected="${session_lc_time == 'iso8601' or None}">ISO 8601 format</option>
        </select></td>
      </tr>
      <tr>
        <th></th>
        <td><p class="hint" i18n:msg="">Configuring your date format will <!--!
            -->result in formatting and parsing datetime displayed on this <!--!
            -->site to use your date format instead of that of the server.</p>
        </td>
      </tr>

      <tr class="field" py:with="session_dateinfo = session.get('dateinfo')">
        <th><label for="dateinfo">Time format:</label></th>
        <td><select id="dateinfo" name="dateinfo">
            <option value="">Default format</option>
            <option value="relative"
                    selected="${session_dateinfo == 'relative' or None}">Relative format</option>
            <option value="absolute"
                    selected="${session_dateinfo == 'absolute' or None}">Absolute format</option>
        </select></td>
      </tr>
      <tr>
        <th></th>
        <td><p class="hint" i18n:msg="">Configuring your relative/absolute <!--!
            -->format will result in formatting datetime displayed on this <!--!
            -->site to use your format instead of that of the server.</p>
        </td>
      </tr>
    </table>

  </body>
</html>
