aboutsummaryrefslogtreecommitdiffstats
path: root/www
diff options
context:
space:
mode:
authorpgollucci <pgollucci@FreeBSD.org>2010-10-12 14:20:30 +0800
committerpgollucci <pgollucci@FreeBSD.org>2010-10-12 14:20:30 +0800
commit773bcd205ac2ab9e2d22d8069ae7b9e8b6e50783 (patch)
tree369ddb011c4f5369dd9f47340cc0b02796bc2b35 /www
parent5ce8285308b119b76e5358845991860f423e6792 (diff)
downloadfreebsd-ports-gnome-773bcd205ac2ab9e2d22d8069ae7b9e8b6e50783.tar.gz
freebsd-ports-gnome-773bcd205ac2ab9e2d22d8069ae7b9e8b6e50783.tar.zst
freebsd-ports-gnome-773bcd205ac2ab9e2d22d8069ae7b9e8b6e50783.zip
- Fix http://trac.edgewall.org/ticket/9439, http://trac.edgewall.org/wiki/TracL10N
- Bump PORTREVISION Current Trac port requires no Babel (devel/py-babel), but it behaves differently when Babel is present and when it is not present in the system. Most notably, when one installs Trac 0.12 without installed Babel and installs Babel later, Trac will refuse to work with the error "KeyError: trac/locale". PR: ports/150483 Submitted by: Eygene Ryabinkin <rea-fbsd@codelabs.ru> Approved by: maintainer timeout (clsung ; 30 days)
Diffstat (limited to 'www')
-rw-r--r--www/trac/Makefile4
-rw-r--r--www/trac/files/patch-trac__util__translation.py35
-rw-r--r--www/trac/files/patch-trac__web__main.py58
3 files changed, 96 insertions, 1 deletions
diff --git a/www/trac/Makefile b/www/trac/Makefile
index 9c7656200891..e244cb5e64fb 100644
--- a/www/trac/Makefile
+++ b/www/trac/Makefile
@@ -7,6 +7,7 @@
PORTNAME= trac
PORTVERSION= 0.12
+PORTREVISION= 1
CATEGORIES= www devel python
MASTER_SITES= http://ftp.edgewall.com/pub/trac/ \
ftp://ftp.edgewall.com/pub/trac/
@@ -15,7 +16,8 @@ DISTNAME= Trac-${PORTVERSION}
MAINTAINER= clsung@FreeBSD.org
COMMENT= An enhanced wiki and issue tracking system for software projects
-BUILD_DEPENDS= ${PYTHON_PKGNAMEPREFIX}Genshi>=0.5:${PORTSDIR}/textproc/py-genshi
+BUILD_DEPENDS= ${PYTHON_PKGNAMEPREFIX}Genshi>=0.5:${PORTSDIR}/textproc/py-genshi \
+ ${PYTHON_PKGNAMEPREFIX}Babel>=0.9:${PORTSDIR}/devel/py-babel
RUN_DEPENDS= ${BUILD_DEPENDS}
OPTIONS= SILVERCITY "Use Silvercity for syntax highlighting" On \
diff --git a/www/trac/files/patch-trac__util__translation.py b/www/trac/files/patch-trac__util__translation.py
new file mode 100644
index 000000000000..70d974b3eef7
--- /dev/null
+++ b/www/trac/files/patch-trac__util__translation.py
@@ -0,0 +1,35 @@
+--- ./trac/util/translation.py.orig 2010-06-13 20:36:24.000000000 +0000
++++ ./trac/util/translation.py 2010-10-12 06:14:47.021523796 +0000
+@@ -101,8 +101,10 @@
+ def dungettext(self, domain, singular, plural, num):
+ return self.ungettext(singular, plural, num)
+
++has_babel = False
+
+ try:
++ from babel import Locale
+ from babel.support import LazyProxy, Translations
+
+ class TranslationsProxy(object):
+@@ -329,6 +331,14 @@
+ in pkg_resources.resource_listdir('trac', 'locale')
+ if '.' not in dirname]
+
++ def get_negotiated_locale(preferred_locales):
++ def normalize(locale_ids):
++ return [id.replace('_', '-') for id in locale_ids if id]
++ return Locale.negotiate(normalize(preferred_locales),
++ normalize(get_available_locales()), sep='-')
++
++ has_babel = True
++
+ except ImportError: # fall back on 0.11 behavior, i18n functions are no-ops
+ gettext = _ = gettext_noop
+ dgettext = dgettext_noop
+@@ -358,3 +368,6 @@
+
+ def get_available_locales():
+ return []
++
++ def get_negotiated_locale(preferred=None, default=None):
++ return None
diff --git a/www/trac/files/patch-trac__web__main.py b/www/trac/files/patch-trac__web__main.py
new file mode 100644
index 000000000000..c04bbed3e58d
--- /dev/null
+++ b/www/trac/files/patch-trac__web__main.py
@@ -0,0 +1,58 @@
+--- ./trac/web/main.py.orig 2010-06-13 20:36:24.000000000 +0000
++++ ./trac/web/main.py 2010-10-12 06:14:47.022524485 +0000
+@@ -26,10 +26,6 @@
+ from pprint import pformat, pprint
+ import sys
+
+-try:
+- from babel import Locale
+-except ImportError:
+- Locale = None
+ from genshi.core import Markup
+ from genshi.builder import Fragment, tag
+ from genshi.output import DocType
+@@ -48,7 +44,8 @@
+ from trac.util.concurrency import threading
+ from trac.util.datefmt import format_datetime, http_date, localtz, timezone
+ from trac.util.text import exception_to_unicode, shorten_line, to_unicode
+-from trac.util.translation import safefmt, tag_, _
++from trac.util.translation import _, get_negotiated_locale, has_babel, \
++ safefmt, tag_
+ from trac.web.api import *
+ from trac.web.chrome import Chrome
+ from trac.web.clearsilver import HDFWrapper
+@@ -150,6 +147,11 @@
+ default_timezone = Option('trac', 'default_timezone', '',
+ """The default timezone to use""")
+
++ default_language = Option('trac', 'default_language', '',
++ """The preferred language to use if no user preference has been set.
++ (''since 0.12.1'')
++ """)
++
+ # Public API
+
+ def authenticate(self, req):
+@@ -302,16 +304,12 @@
+ return FakeSession()
+
+ def _get_locale(self, req):
+- if Locale:
+- available = [locale_id.replace('_', '-') for locale_id in
+- translation.get_available_locales()]
+-
+- preferred = req.session.get('language', req.languages)
+- if not isinstance(preferred, list):
+- preferred = [preferred]
+- negotiated = Locale.negotiate(preferred, available, sep='-')
+- self.log.debug("Negotiated locale: %s -> %s",
+- preferred, negotiated)
++ if has_babel:
++ preferred = req.session.get('language')
++ default = self.env.config.get('trac', 'default_language', '')
++ negotiated = get_negotiated_locale([preferred, default] +
++ req.languages)
++ self.log.debug("Negotiated locale: %s -> %s", preferred, negotiated)
+ return negotiated
+
+ def _get_timezone(self, req):