diff --git a/trac/prefs/templates/prefs_language.html b/trac/prefs/templates/prefs_language.html
|
a
|
b
|
|
| 3 | 3 | "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> |
| 4 | 4 | <html xmlns="http://www.w3.org/1999/xhtml" |
| 5 | 5 | xmlns:py="http://genshi.edgewall.org/" |
| 6 | | xmlns:xi="http://www.w3.org/2001/XInclude"> |
| | 6 | xmlns:xi="http://www.w3.org/2001/XInclude" |
| | 7 | xmlns:i18n="http://genshi.edgewall.org/i18n"> |
| 7 | 8 | <xi:include href="prefs.html" /> |
| 8 | 9 | <head> |
| 9 | 10 | <title>Language</title> |
| … |
… |
|
| 12 | 13 | |
| 13 | 14 | <div class="field" py:with="session_language = settings.session.get('language')"> |
| 14 | 15 | <label>Language: |
| 15 | | <select name="language"> |
| 16 | | <option value="">default language</option> |
| 17 | | <option py:for="locale, language in languages" |
| 18 | | selected="${session_language == locale or None}" |
| 19 | | value="$locale">$language</option> |
| 20 | | </select></label> |
| | 16 | <select name="language"> |
| | 17 | <option value="">default language</option> |
| | 18 | <option py:for="locale, language in languages" |
| | 19 | selected="${session_language == locale or None}" |
| | 20 | value="$locale">$language</option> |
| | 21 | </select> |
| | 22 | </label> |
| 21 | 23 | <p class="hint">Configuring your language will result in all text |
| 22 | 24 | displayed on this site to use your language instead of that of the |
| 23 | 25 | server.</p> |
| 24 | 26 | |
| 25 | 27 | <p class="hint">The 'default language' option uses the browser's |
| 26 | 28 | language negotiation feature to select the appropriate language.</p> |
| | 29 | |
| | 30 | <p py:if="not languages" class="hint"> |
| | 31 | <strong>Note:</strong> Translations are currently unavailable. |
| | 32 | <py:choose> |
| | 33 | <py:when test="'TRAC_ADMIN' in req.perm"><i18n:msg> |
| | 34 | Trac has been localized to more than a dozen of languages but in order |
| | 35 | to be able to use them, the <a href="http://babel.edgewall.org">Babel</a> |
| | 36 | package needs to be present when installing Trac. See |
| | 37 | <a href="${href.wiki('TracInstall')}">TracInstall</a> for details. |
| | 38 | </i18n:msg></py:when> |
| | 39 | <py:otherwise><i18n:msg> |
| | 40 | Please contact your |
| | 41 | <a py:strip="not project.admin" href="mailto:${project.admin}">Trac administrator</a> |
| | 42 | to enable existing translations. |
| | 43 | </i18n:msg></py:otherwise> |
| | 44 | </py:choose> |
| | 45 | </p> |
| 27 | 46 | </div> |
| 28 | 47 | |
| 29 | 48 | </body> |
diff --git a/trac/util/translation.py b/trac/util/translation.py
|
a
|
b
|
try: |
| 141 | 141 | def activate(self, locale, env_path=None): |
| 142 | 142 | try: |
| 143 | 143 | locale_dir = pkg_resources.resource_filename('trac', 'locale') |
| 144 | | except pkg_resources.ExtractionError: |
| 145 | | return # delay extraction |
| 146 | | except KeyError: |
| 147 | | return # No locale data in egg |
| | 144 | except Exception: |
| | 145 | return |
| 148 | 146 | t = Translations.load(locale_dir, locale or 'en_US') |
| 149 | 147 | if not t or t.__class__ is NullTranslations: |
| 150 | 148 | t = self._null_translations |
| … |
… |
try: |
| 329 | 327 | """Return a list of locale identifiers of the locales for which |
| 330 | 328 | translations are available. |
| 331 | 329 | """ |
| 332 | | return [dirname for dirname |
| 333 | | in pkg_resources.resource_listdir('trac', 'locale') |
| 334 | | if '.' not in dirname] |
| | 330 | try: |
| | 331 | return [dirname for dirname |
| | 332 | in pkg_resources.resource_listdir('trac', 'locale') |
| | 333 | if '.' not in dirname] |
| | 334 | except Exception: |
| | 335 | return [] |
| 335 | 336 | |
| 336 | 337 | def get_negotiated_locale(preferred_locales): |
| 337 | 338 | def normalize(locale_ids): |
diff --git a/trac/web/chrome.py b/trac/web/chrome.py
|
a
|
b
|
from trac.util.text import pretty_size, |
| 47 | 47 | javascript_quote, exception_to_unicode |
| 48 | 48 | from trac.util.datefmt import pretty_timedelta, format_datetime, format_date, \ |
| 49 | 49 | format_time, from_utimestamp, http_date, utc |
| 50 | | from trac.util.translation import _ |
| | 50 | from trac.util.translation import _, get_available_locales |
| 51 | 51 | from trac.web.api import IRequestHandler, ITemplateStreamFilter, HTTPNotFound |
| 52 | 52 | from trac.web.href import Href |
| 53 | 53 | from trac.wiki import IWikiSyntaxProvider |
| … |
… |
class Chrome(Component): |
| 379 | 379 | except ImportError: |
| 380 | 380 | babel = None |
| 381 | 381 | if babel is not None: |
| 382 | | yield 'Babel', get_pkginfo(babel).get('version') |
| | 382 | info = get_pkginfo(babel).get('version') |
| | 383 | if not get_available_locales(): |
| | 384 | info += " (translations unavailable)" # No i18n on purpose |
| | 385 | yield 'Babel', info |
| 383 | 386 | |
| 384 | 387 | # IEnvironmentSetupParticipant methods |
| 385 | 388 | |