Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added i18n support, starting with french catalog.

  • Loading branch information...
commit 1669cefa806614e62bd9ce5573750e30fa060408 1 parent 0410673
@cboos authored
View
1  .gitignore
@@ -3,3 +3,4 @@ HudsonTrac.egg-info
.svn
*~
*.bak
+*.mo
View
37 HudsonTrac/HudsonTracPlugin.py
@@ -16,6 +16,8 @@
from xml.dom import minidom
from datetime import datetime
+from pkg_resources import resource_filename
+
from genshi.builder import tag
from trac.core import *
@@ -23,12 +25,15 @@
from trac.perm import IPermissionRequestor
from trac.util.datefmt import format_datetime, pretty_timedelta, to_timestamp
from trac.util.text import unicode_quote
+from trac.util.translation import domain_functions
from trac.web.chrome import INavigationContributor, ITemplateProvider, add_stylesheet
from trac.timeline.api import ITimelineEventProvider
+add_domain, _, tag_ = domain_functions('hudsontrac', 'add_domain', '_', 'tag_')
class HudsonTracPlugin(Component):
- """Display Hudson results in the timeline and an entry in the main navigation bar.
+ """Display Hudson results in the timeline and an entry in the main
+ navigation bar.
"""
implements(INavigationContributor, ITimelineEventProvider,
@@ -63,6 +68,12 @@ class HudsonTracPlugin(Component):
messages.""")
def __init__(self):
+ # i18n
+ add_domain(self.env.path, resource_filename(__name__, 'locale'))
+ self.log.info("Added domain 'hudsontrac' -> %s",
+ resource_filename(__name__, 'locale'))
+
+ # prepare self.info_url
api_url = unicode_quote(self.job_url, '/%:@')
if api_url and api_url[-1] != '/':
api_url += '/'
@@ -113,7 +124,7 @@ def get_active_navigation_item(self, req):
def get_navigation_items(self, req):
if self.nav_url and req.perm.has_permission('BUILD_VIEW'):
- yield 'mainnav', 'builds', tag.a("Build", href=self.nav_url,
+ yield 'mainnav', 'builds', tag.a(_("Build"), href=self.nav_url,
target=self.disp_tab and "hudson" or None)
# ITemplateProvider methods
@@ -124,14 +135,13 @@ def get_templates_dirs(self):
self.config.get('trac', 'templates_dir')]
def get_htdocs_dirs(self):
- from pkg_resources import resource_filename
return [('HudsonTrac', resource_filename(__name__, 'htdocs'))]
# ITimelineEventProvider methods
def get_timeline_filters(self, req):
if 'BUILD_VIEW' in req.perm:
- yield ('build', 'Hudson Builds')
+ yield ('build', _('Hudson Builds'))
def get_timeline_events(self, req, start, stop, filters):
if 'build' not in filters or 'BUILD_VIEW' not in req.perm:
@@ -194,21 +204,22 @@ def get_number(parent, child):
result = get_string(entry, 'result')
message, kind = {
- 'SUCCESS': ('Build finished successfully',
+ 'SUCCESS': (_('Build finished successfully'),
('build-successful',
'build-successful-alt')[self.alt_succ]),
- 'UNSTABLE': ('Build unstable', 'build-unstable'),
- 'ABORTED': ('Build aborted', 'build-aborted'),
- }.get(result, ('Build failed', 'build-failed'))
+ 'UNSTABLE': (_('Build unstable'), 'build-unstable'),
+ 'ABORTED': (_('Build aborted'), 'build-aborted'),
+ }.get(result, (_('Build failed'), 'build-failed'))
if self.use_desc:
message = get_string(entry, 'description') or message
- comment = "%s at %s, duration %s" % (
- message, format_datetime(completed),
- pretty_timedelta(started, completed))
+ comment = _("%(message)s after %(elapsed)s",
+ message=message,
+ elapsed=pretty_timedelta(started, completed))
href = get_string(entry, 'url')
- title = 'Build "%s" (%s)' % (get_string(entry, 'fullDisplayName'),
- result.lower())
+ title = tag_('Build %(name)s (%(result)s)',
+ name=tag.em(get_string(entry, 'fullDisplayName')),
+ result=result.lower())
yield kind, href, title, completed, None, comment
View
53 HudsonTrac/locale/fr/LC_MESSAGES/hudsontrac.po
@@ -0,0 +1,53 @@
+# French translations for HudsonTrac.
+# This file is distributed under the same license as the HudsonTrac
+# project.
+# Christian Boos <cboos@neuf.fr>, 2010.
+#
+msgid ""
+msgstr ""
+"Project-Id-Version: HudsonTrac 0.12.0.4\n"
+"Report-Msgid-Bugs-To: cboos@neuf.fr\n"
+"POT-Creation-Date: 2010-04-27 11:35+0200\n"
+"PO-Revision-Date: 2010-04-27 11:42+0200\n"
+"Last-Translator: Christian Boos <cboos@neuf.fr>\n"
+"Language-Team: fr <trac-dev@googlegroups.com>\n"
+"Plural-Forms: nplurals=2; plural=(n > 1)\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: Babel 0.9.5\n"
+
+#: HudsonTrac/HudsonTracPlugin.py:125
+msgid "Build"
+msgstr ""
+
+#: HudsonTrac/HudsonTracPlugin.py:142
+msgid "Hudson Builds"
+msgstr ""
+
+#: HudsonTrac/HudsonTracPlugin.py:205
+msgid "Build finished successfully"
+msgstr "Le build a réussi"
+
+#: HudsonTrac/HudsonTracPlugin.py:208
+msgid "Build unstable"
+msgstr "Le build est instable"
+
+#: HudsonTrac/HudsonTracPlugin.py:209
+msgid "Build aborted"
+msgstr "Le build a été interrompu"
+
+#: HudsonTrac/HudsonTracPlugin.py:210
+msgid "Build failed"
+msgstr "Le build a échoué"
+
+#: HudsonTrac/HudsonTracPlugin.py:217
+#, python-format
+msgid "%(message)s after %(elapsed)s"
+msgstr "%(message)s au bout de %(elapsed)s"
+
+#: HudsonTrac/HudsonTracPlugin.py:221
+#, python-format
+msgid "Build %(name)s (%(result)s)"
+msgstr "Build « %(name)s » (%(result)s)"
+
View
54 HudsonTrac/locale/messages.pot
@@ -0,0 +1,54 @@
+# Translations template for HudsonTrac.
+# Copyright (C) 2010 ORGANIZATION
+# This file is distributed under the same license as the HudsonTrac
+# project.
+# FIRST AUTHOR <EMAIL@ADDRESS>, 2010.
+#
+#, fuzzy
+msgid ""
+msgstr ""
+"Project-Id-Version: HudsonTrac 0.12.0.4\n"
+"Report-Msgid-Bugs-To: cboos@neuf.fr\n"
+"POT-Creation-Date: 2010-04-27 11:35+0200\n"
+"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
+"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
+"Language-Team: LANGUAGE <LL@li.org>\n"
+"MIME-Version: 1.0\n"
+"Content-Type: text/plain; charset=utf-8\n"
+"Content-Transfer-Encoding: 8bit\n"
+"Generated-By: Babel 0.9.5\n"
+
+#: HudsonTrac/HudsonTracPlugin.py:125
+msgid "Build"
+msgstr ""
+
+#: HudsonTrac/HudsonTracPlugin.py:142
+msgid "Hudson Builds"
+msgstr ""
+
+#: HudsonTrac/HudsonTracPlugin.py:205
+msgid "Build finished successfully"
+msgstr ""
+
+#: HudsonTrac/HudsonTracPlugin.py:208
+msgid "Build unstable"
+msgstr ""
+
+#: HudsonTrac/HudsonTracPlugin.py:209
+msgid "Build aborted"
+msgstr ""
+
+#: HudsonTrac/HudsonTracPlugin.py:210
+msgid "Build failed"
+msgstr ""
+
+#: HudsonTrac/HudsonTracPlugin.py:217
+#, python-format
+msgid "%(message)s after %(elapsed)s"
+msgstr ""
+
+#: HudsonTrac/HudsonTracPlugin.py:221
+#, python-format
+msgid "Build %(name)s (%(result)s)"
+msgstr ""
+
View
24 setup.cfg
@@ -0,0 +1,24 @@
+[egg_info]
+tag_build = dev
+tag_svn_revision = true
+
+[extract_messages]
+add_comments = TRANSLATOR:
+msgid_bugs_address = cboos@neuf.fr
+output_file = HudsonTrac/locale/messages.pot
+keywords = _ ngettext:1,2 N_ tag_
+width = 72
+
+[init_catalog]
+input_file = HudsonTrac/locale/messages.pot
+output_dir = HudsonTrac/locale
+domain = hudsontrac
+
+[compile_catalog]
+directory = HudsonTrac/locale
+domain = hudsontrac
+
+[update_catalog]
+input_file = HudsonTrac/locale/messages.pot
+output_dir = HudsonTrac/locale
+domain = hudsontrac
View
22 setup.py
@@ -3,20 +3,34 @@
from setuptools import setup
+extra = {}
+
+try:
+ import babel
+ extra['message_extractors'] = {
+ 'HudsonTrac': [
+ ('*.py', 'python', None),
+ ],
+ }
+except ImportError:
+ pass
+
setup(
name = 'HudsonTrac',
- version = '0.11.0.3',
+ version = '0.12.0.4',
author = "Ronald Tschalär",
- description = "A trac plugin to add hudson build info to the trac timeline",
+ description = "Trac Plugin which adds Hudson build events to the timeline",
license = "BSD",
keywords = "trac builds hudson",
url = "http://trac-hacks.org/wiki/HudsonTracPlugin",
packages = ['HudsonTrac'],
package_data = {
- 'HudsonTrac' : ['htdocs/*.css', 'htdocs/*.gif']
+ 'HudsonTrac' : ['htdocs/*.css', 'htdocs/*.gif',
+ 'locale/*.*', 'locale/*/LC_MESSAGES/*.*'],
},
entry_points = {
'trac.plugins' : [ 'HudsonTrac = HudsonTrac.HudsonTracPlugin' ]
- }
+ },
+ **extra
)
Please sign in to comment.
Something went wrong with that request. Please try again.