i18n başlangıcı.
bu dosyaların başındaki import gettext ile başlayan üç satırlık kısım modüllere ekleniyor, stringler ise _( ... ) içine alınıyor. pygettext.py adlı programla .pot dosyası oluşturulup çevrilebiliyor. translation instance'ını globale almayı kalkmayın, zaten tüm çeviriler gettext modülü tarafından cache'leniyor.
This commit is contained in:
@@ -12,6 +12,10 @@
|
||||
|
||||
import sys
|
||||
|
||||
import gettext
|
||||
__trans = gettext.translation('pisi', fallback=True)
|
||||
_ = __trans.ugettext
|
||||
|
||||
from pisi.cli.pisicli import PisiCLI
|
||||
from pisi.ui import ui
|
||||
|
||||
@@ -22,20 +26,20 @@ def handle_exception(exception, value, tb):
|
||||
from pisi.ui import ui
|
||||
|
||||
if exception == exceptions.KeyboardInterrupt:
|
||||
ui.error("\nKeyboardInterrupt: Exiting...\n")
|
||||
ui.error(_("\nKeyboardInterrupt: Exiting...\n"))
|
||||
sys.exit(1)
|
||||
elif exception == XmlError:
|
||||
ui.error(str(value))
|
||||
sys.exit(1)
|
||||
|
||||
ui.error("""
|
||||
ui.error(_("""
|
||||
Internal PISI Error:
|
||||
Please file a bug report! (http://bugs.uludag.org.tr)
|
||||
|
||||
""")
|
||||
"""))
|
||||
|
||||
ui.error("%s\n" %value)
|
||||
ui.info("Traceback:\n")
|
||||
ui.info(_("Traceback:\n"))
|
||||
traceback.print_tb(tb)
|
||||
sys.exit(1)
|
||||
|
||||
|
||||
+25
-21
@@ -17,6 +17,10 @@
|
||||
import os
|
||||
import sys
|
||||
|
||||
import gettext
|
||||
__trans = gettext.translation('pisi', fallback=True)
|
||||
_ = __trans.ugettext
|
||||
|
||||
import pisi
|
||||
import pisi.util as util
|
||||
from pisi.ui import ui
|
||||
@@ -70,7 +74,7 @@ def check_path_collision(package, pkgList):
|
||||
# path.pathname: /usr/share/doc
|
||||
if util.subpath(pinfo.pathname, path.pathname):
|
||||
collisions.append(path.pathname)
|
||||
ui.error('Path %s belongs in multiple packages\n' %
|
||||
ui.error(_('Path %s belongs in multiple packages\n') %
|
||||
path.pathname)
|
||||
return collisions
|
||||
|
||||
@@ -102,8 +106,8 @@ class PisiBuild:
|
||||
def build(self):
|
||||
"""Build the package in one shot."""
|
||||
|
||||
ui.info("Building PISI source package: %s\n" % self.spec.source.name)
|
||||
util.xterm_title("Building PISI source package: %s\n" % self.spec.source.name)
|
||||
ui.info(_("Building PISI source package: %s\n") % self.spec.source.name)
|
||||
util.xterm_title(_("Building PISI source package: %s\n") % self.spec.source.name)
|
||||
|
||||
self.compile_action_script()
|
||||
|
||||
@@ -136,30 +140,30 @@ class PisiBuild:
|
||||
os.environ.update(evn)
|
||||
|
||||
def fetch_source_archive(self):
|
||||
ui.info("Fetching source from: %s\n" % self.spec.source.archiveUri)
|
||||
ui.info(_("Fetching source from: %s\n") % self.spec.source.archiveUri)
|
||||
self.sourceArchive.fetch()
|
||||
ui.info("Source archive is stored: %s/%s\n"
|
||||
ui.info(_("Source archive is stored: %s/%s\n")
|
||||
%(config.archives_dir(), self.spec.source.archiveName))
|
||||
|
||||
def unpack_source_archive(self):
|
||||
ui.info("Unpacking archive...")
|
||||
ui.info(_("Unpacking archive..."))
|
||||
self.sourceArchive.unpack()
|
||||
ui.info(" unpacked (%s)\n" % self.ctx.pkg_work_dir())
|
||||
ui.info(_(" unpacked (%s)\n") % self.ctx.pkg_work_dir())
|
||||
self.set_state("unpacked")
|
||||
|
||||
def run_setup_action(self):
|
||||
# Run configure, build and install phase
|
||||
ui.action("Setting up source...\n")
|
||||
ui.action(_("Setting up source...\n"))
|
||||
self.run_action_function(const.setup_func)
|
||||
self.set_state("setupaction")
|
||||
|
||||
def run_build_action(self):
|
||||
ui.action("Building source...\n")
|
||||
ui.action(_("Building source...\n"))
|
||||
self.run_action_function(const.build_func)
|
||||
self.set_state("buildaction")
|
||||
|
||||
def run_install_action(self):
|
||||
ui.action("Installing...\n")
|
||||
ui.action(_("Installing...\n"))
|
||||
|
||||
# Before install make sure install_dir is clean
|
||||
if os.path.exists(self.ctx.pkg_install_dir()):
|
||||
@@ -178,10 +182,10 @@ class PisiBuild:
|
||||
buf = open(scriptfile).read()
|
||||
exec compile(buf, "error", "exec") in localSymbols, globalSymbols
|
||||
except IOError, e:
|
||||
ui.error("Unable to read Action Script (%s): %s\n" %(scriptfile,e))
|
||||
ui.error(_("Unable to read Action Script (%s): %s\n") %(scriptfile,e))
|
||||
sys.exit(1)
|
||||
except SyntaxError, e:
|
||||
ui.error ("SyntaxError in Action Script (%s): %s\n" %(scriptfile,e))
|
||||
ui.error (_("SyntaxError in Action Script (%s): %s\n") %(scriptfile,e))
|
||||
sys.exit(1)
|
||||
|
||||
self.actionLocals = localSymbols
|
||||
@@ -212,7 +216,7 @@ class PisiBuild:
|
||||
self.actionLocals[func]()
|
||||
else:
|
||||
if mandatory:
|
||||
Error, "unable to call function from actions: %s" %func
|
||||
Error, _("unable to call function from actions: %s") %func
|
||||
|
||||
os.chdir(curDir)
|
||||
|
||||
@@ -232,7 +236,7 @@ class PisiBuild:
|
||||
compressType=patch.compressionType,
|
||||
targetDir=config.tmp_dir())
|
||||
|
||||
ui.action("* Applying patch: %s\n" % patch.filename)
|
||||
ui.action(_("* Applying patch: %s\n") % patch.filename)
|
||||
util.do_patch(self.srcDir, patchFile, level=patch.level, target=patch.target)
|
||||
|
||||
def gen_metadata_xml(self, package):
|
||||
@@ -273,7 +277,7 @@ class PisiBuild:
|
||||
collisions = check_path_collision(package,
|
||||
self.spec.packages)
|
||||
if collisions:
|
||||
raise Error('Path collisions detected')
|
||||
raise Error(_('Path collisions detected'))
|
||||
d = {}
|
||||
for pinfo in package.paths:
|
||||
path = install_dir + pinfo.pathname
|
||||
@@ -362,17 +366,17 @@ class PisiBuild:
|
||||
self.spec.source.release)
|
||||
|
||||
|
||||
ui.action("** Building package %s\n" % package.name);
|
||||
ui.action(_("** Building package %s\n") % package.name);
|
||||
|
||||
ui.action("Generating %s..." % const.files_xml)
|
||||
ui.action(_("Generating %s...") % const.files_xml)
|
||||
self.gen_files_xml(package)
|
||||
ui.info(" done.\n")
|
||||
ui.info(_(" done.\n"))
|
||||
|
||||
ui.action("Generating %s..." % const.metadata_xml)
|
||||
ui.action(_("Generating %s...") % const.metadata_xml)
|
||||
self.gen_metadata_xml(package)
|
||||
ui.info(" done.\n")
|
||||
ui.info(_(" done.\n"))
|
||||
|
||||
ui.action("Creating PISI package %s\n" % name)
|
||||
ui.action(_("Creating PISI package %s\n") % name)
|
||||
|
||||
pkg = Package(name, 'w')
|
||||
|
||||
|
||||
+29
-36
@@ -12,13 +12,21 @@
|
||||
import sys
|
||||
import os
|
||||
|
||||
import gettext
|
||||
__trans = gettext.translation('pisi', fallback=True)
|
||||
_ = __trans.ugettext
|
||||
|
||||
sys.path.append('.')
|
||||
import pisi.specfile
|
||||
import pisi.uri
|
||||
|
||||
def echo(string):
|
||||
print string.encode("utf8")
|
||||
|
||||
class Histogram:
|
||||
def __init__(self):
|
||||
def __init__(self, title):
|
||||
self.list = {}
|
||||
self.title = title
|
||||
|
||||
def add(self, name):
|
||||
if self.list.has_key(name):
|
||||
@@ -38,11 +46,14 @@ class Histogram:
|
||||
items = self.list.items()
|
||||
items.sort(self._sortfunc)
|
||||
return items
|
||||
|
||||
def html_out(self):
|
||||
echo("<h1>%s</h1><table>" % self.title)
|
||||
for name,cnt in self.get_list():
|
||||
echo("<tr><td>%s</td><td>%s</td></tr>" % (name, cnt))
|
||||
echo("</table>")
|
||||
|
||||
|
||||
def echo(string):
|
||||
print string.encode("utf8")
|
||||
|
||||
def scan_pspec(folder):
|
||||
paks = []
|
||||
for root, dirs, files in os.walk(folder):
|
||||
@@ -67,10 +78,12 @@ def add_deps(deps, spec):
|
||||
for p in a:
|
||||
deps.add(p)
|
||||
|
||||
hosts = Histogram()
|
||||
people = Histogram()
|
||||
licenses = Histogram()
|
||||
components = Histogram()
|
||||
hosts = Histogram(_("Source hosts"))
|
||||
people = Histogram(_("Packagers"))
|
||||
licenses = Histogram(_("Licenses"))
|
||||
components = Histogram(_("Components"))
|
||||
dependencies = Histogram(_("Dependencies"))
|
||||
types = Histogram(_("File types"))
|
||||
mostp_name = None
|
||||
mostp_count = 0
|
||||
nr_binpaks = 0
|
||||
@@ -78,8 +91,6 @@ nr_patches = 0
|
||||
maxpy_lines = 0
|
||||
maxpy_name = None
|
||||
paknames = {}
|
||||
dependencies = Histogram()
|
||||
types = Histogram()
|
||||
|
||||
errors = []
|
||||
|
||||
@@ -128,7 +139,7 @@ for pak in paks:
|
||||
|
||||
print "<html><head><title>%s İstatistikleri</title>" % (sys.argv[1])
|
||||
print '<meta http-equiv="Content-Type" content="text/html; charset=utf-8">'
|
||||
print "</head><body>"
|
||||
echo("</head><body>")
|
||||
|
||||
print "<p>Toplam %d kod paketi, ve bunlardan oluşturulacak %d ikili paket var.</p>" % (len(paks), nr_binpaks)
|
||||
echo(u"<p>Toplam peç sayısı %d</p>" % nr_patches)
|
||||
@@ -146,28 +157,13 @@ if errors != []:
|
||||
else:
|
||||
print "<p>Hata yok, tebrikler!</p>"
|
||||
|
||||
print "<h1>Komponentler</h1><table>"
|
||||
for name,cnt in components.get_list():
|
||||
print "<tr><td>%s</td><td>%s</td></tr>" % (name, cnt)
|
||||
print "</table>"
|
||||
components.html_out()
|
||||
people.html_out()
|
||||
licenses.html_out()
|
||||
types.html_out()
|
||||
|
||||
print "<h1>Paketleyiciler</h1><table>"
|
||||
for name,cnt in people.get_list():
|
||||
echo("<tr><td>%s</td><td>%s</td></tr>" % (name, cnt))
|
||||
print "</table>"
|
||||
|
||||
print "<h1>Lisanslar</h1><table>"
|
||||
for name,cnt in licenses.get_list():
|
||||
print "<tr><td>%s</td><td>%s</td></tr>" % (name, cnt)
|
||||
print "</table>"
|
||||
|
||||
print "<h1>Dosya tipleri</h1><table>"
|
||||
for name,cnt in types.get_list():
|
||||
print "<tr><td>%s</td><td>%s</td></tr>" % (name, cnt)
|
||||
print "</table>"
|
||||
|
||||
echo(u"<h1>Bağımlılıklar<br>")
|
||||
echo(u"<small>(italik olanlar depoda bulunmayanlar)</small></h1>")
|
||||
echo(_("<h1>Dependencies<br>"))
|
||||
echo(_("<small>package name with italics are not available in the repository</small></h1>"))
|
||||
print "<table>"
|
||||
for name,cnt in dependencies.get_list():
|
||||
if paknames.has_key(name):
|
||||
@@ -176,9 +172,6 @@ for name,cnt in dependencies.get_list():
|
||||
print "<tr><td><i>%s</i></td><td>%d</td></tr>" % (name, cnt)
|
||||
print "</table>"
|
||||
|
||||
echo(u"<h1>Kod kaynakları</h1><table>")
|
||||
for name,cnt in hosts.get_list():
|
||||
print "<tr><td>%s</td><td>%s</td></tr>" % (name, cnt)
|
||||
print "</table>"
|
||||
hosts.html_out()
|
||||
|
||||
print "</body>"
|
||||
|
||||
Reference in New Issue
Block a user