From: Michael Tremer Date: Sat, 4 Aug 2012 09:53:57 +0000 (+0000) Subject: Create an i18n submodule. X-Git-Tag: 0.0.2~38 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=05a55b561989408a1f2198ef84f077f36d36672f;p=collecty.git Create an i18n submodule. --- diff --git a/Makefile b/Makefile index dbd35ab..c4ae700 100644 --- a/Makefile +++ b/Makefile @@ -34,7 +34,7 @@ dist: install: -mkdir -pv $(PYTHON_DIR) cp -rvf collecty $(PYTHON_DIR) - install -v -m 755 colletyd $(DESTDIR)/usr/sbin + install -v -m 755 collectyd $(DESTDIR)/usr/sbin -mkdir -pv $(DESTDIR)/var/rrd diff --git a/collecty/i18n.py b/collecty/i18n.py new file mode 100644 index 0000000..75c78fe --- /dev/null +++ b/collecty/i18n.py @@ -0,0 +1,38 @@ +#!/usr/bin/python +############################################################################### +# # +# collecty - A system statistics collection daemon for IPFire # +# Copyright (C) 2012 IPFire development team # +# # +# This program is free software: you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation, either version 3 of the License, or # +# (at your option) any later version. # +# # +# This program is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with this program. If not, see . # +# # +############################################################################### + +import gettext + +TEXTDOMAIN = "collecty" + +N_ = lambda x: x + +def _(singular, plural=None, n=None): + """ + A function that returnes the translation of a string if available. + + The language is taken from the system environment. + """ + if not plural is None: + assert n is not None + return gettext.dngettext(TEXTDOMAIN, singular, plural, n) + + return gettext.dgettext(TEXTDOMAIN, singular) diff --git a/collecty/plugins/__init__.py b/collecty/plugins/__init__.py index c926ca7..fd83711 100644 --- a/collecty/plugins/__init__.py +++ b/collecty/plugins/__init__.py @@ -26,8 +26,7 @@ import time from threading import Thread -import gettext -_ = lambda x: gettext.ldgettext("collecty", x) +from ..i18n import _ registered_plugins = []