l10n: Switch from pygettext to xgettext
Also add pisi.xml mimetype file. Remove scripts/update-po.sh file.
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<mime-info xmlns="http://www.freedesktop.org/standards/shared-mime-info">
|
||||||
|
<mime-type type="application/x-pisi">
|
||||||
|
<_comment>PiSi package</_comment>
|
||||||
|
<glob pattern="*.pisi"/>
|
||||||
|
</mime-type>
|
||||||
|
</mime-info>
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
PYTHON_VER=`python -c "import sys; print '%d.%d' % sys.version_info[:2]"`
|
|
||||||
OPTPARSE_PY=/usr/lib/python$PYTHON_VER/optparse.py
|
|
||||||
|
|
||||||
find pisi -iname '*.py' | grep -v pisi/cli/commands.py > exclude
|
|
||||||
echo "$OPTPARSE_PY" >> exclude
|
|
||||||
python scripts/pygettext.py -D -X exclude -o po/pisi.pot pisi pisi-cli $OPTPARSE_PY
|
|
||||||
for lang in po/*.po
|
|
||||||
do
|
|
||||||
msgmerge --update --no-wrap --sort-by-file $lang po/pisi.pot
|
|
||||||
done
|
|
||||||
rm exclude
|
|
||||||
@@ -16,12 +16,81 @@ import shutil
|
|||||||
import glob
|
import glob
|
||||||
import sys
|
import sys
|
||||||
import inspect
|
import inspect
|
||||||
|
import tempfile
|
||||||
from distutils.core import setup
|
from distutils.core import setup
|
||||||
|
from distutils.command.build import build
|
||||||
from distutils.command.install import install
|
from distutils.command.install import install
|
||||||
|
|
||||||
sys.path.insert(0, '.')
|
sys.path.insert(0, '.')
|
||||||
import pisi
|
import pisi
|
||||||
|
|
||||||
|
IN_FILES = ("pisi.xml.in",)
|
||||||
|
PROJECT = "pisi"
|
||||||
|
MIMEFILE_DIR = "usr/share/mime/packages"
|
||||||
|
|
||||||
|
|
||||||
|
class Build(build):
|
||||||
|
def run(self):
|
||||||
|
build.run(self)
|
||||||
|
|
||||||
|
self.mkpath(self.build_base)
|
||||||
|
|
||||||
|
for in_file in IN_FILES:
|
||||||
|
name, ext = os.path.splitext(in_file)
|
||||||
|
self.spawn(["intltool-merge", "-x", "po", in_file, os.path.join(self.build_base, name)])
|
||||||
|
|
||||||
|
|
||||||
|
class BuildPo(build):
|
||||||
|
def run(self):
|
||||||
|
build.run(self)
|
||||||
|
self.build_po()
|
||||||
|
|
||||||
|
def build_po(self):
|
||||||
|
import optparse
|
||||||
|
files = tempfile.mkstemp()[1]
|
||||||
|
filelist = []
|
||||||
|
|
||||||
|
# Include optparse module path to translate
|
||||||
|
optparse_path = os.path.abspath(optparse.__file__).rstrip("co")
|
||||||
|
|
||||||
|
# Collect headers for mimetype files
|
||||||
|
for filename in IN_FILES:
|
||||||
|
os.system("intltool-extract --type=gettext/xml %s" % filename)
|
||||||
|
|
||||||
|
for root,dirs,filenames in os.walk("pisi"):
|
||||||
|
for filename in filenames:
|
||||||
|
if filename.endswith(".py"):
|
||||||
|
filelist.append(os.path.join(root, filename))
|
||||||
|
|
||||||
|
filelist.extend(["pisi-cli", "pisi.xml.in.h", optparse_path])
|
||||||
|
filelist.sort()
|
||||||
|
with open(files, "w") as _files:
|
||||||
|
_files.write("\n".join(filelist))
|
||||||
|
|
||||||
|
# Generate POT file
|
||||||
|
os.system("xgettext -L Python \
|
||||||
|
--default-domain=%s \
|
||||||
|
--keyword=_ \
|
||||||
|
--keyword=N_ \
|
||||||
|
--files-from=%s \
|
||||||
|
-o po/%s.pot" % (PROJECT, files, PROJECT))
|
||||||
|
|
||||||
|
# Update PO files
|
||||||
|
for item in glob.glob1("po", "*.po"):
|
||||||
|
print "Updating .. ", item
|
||||||
|
os.system("msgmerge --update --no-wrap --sort-by-file po/%s po/%s.pot" % (item, PROJECT))
|
||||||
|
|
||||||
|
# Cleanup
|
||||||
|
os.unlink(files)
|
||||||
|
for f in filelist:
|
||||||
|
if not f.endswith(".h"):
|
||||||
|
continue
|
||||||
|
try:
|
||||||
|
os.unlink(f)
|
||||||
|
except OSError:
|
||||||
|
pass
|
||||||
|
|
||||||
|
|
||||||
class Install(install):
|
class Install(install):
|
||||||
def run(self):
|
def run(self):
|
||||||
install.run(self)
|
install.run(self)
|
||||||
@@ -84,6 +153,7 @@ class Install(install):
|
|||||||
pisiconf.write('\n')
|
pisiconf.write('\n')
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
setup(name="pisi",
|
setup(name="pisi",
|
||||||
version= pisi.__version__,
|
version= pisi.__version__,
|
||||||
description="PiSi (Packages Installed Successfully as Intended)",
|
description="PiSi (Packages Installed Successfully as Intended)",
|
||||||
@@ -95,7 +165,9 @@ setup(name="pisi",
|
|||||||
package_dir = {'': ''},
|
package_dir = {'': ''},
|
||||||
packages = ['pisi', 'pisi.cli', 'pisi.operations', 'pisi.actionsapi', 'pisi.pxml', 'pisi.scenarioapi', 'pisi.db'],
|
packages = ['pisi', 'pisi.cli', 'pisi.operations', 'pisi.actionsapi', 'pisi.pxml', 'pisi.scenarioapi', 'pisi.db'],
|
||||||
scripts = ['pisi-cli', 'scripts/lspisi', 'scripts/unpisi', 'scripts/check-newconfigs.py', 'scripts/revdep-rebuild'],
|
scripts = ['pisi-cli', 'scripts/lspisi', 'scripts/unpisi', 'scripts/check-newconfigs.py', 'scripts/revdep-rebuild'],
|
||||||
cmdclass = {'install' : Install}
|
cmdclass = {'build' : Build,
|
||||||
|
'build_po' : BuildPo,
|
||||||
|
'install' : Install}
|
||||||
)
|
)
|
||||||
|
|
||||||
# the below stuff is really nice but we already have a version
|
# the below stuff is really nice but we already have a version
|
||||||
|
|||||||
Reference in New Issue
Block a user