mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-06 14:13:28 -06:00
meson: add po files
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
3247dab74c
commit
01acaa3836
@ -1,5 +1,9 @@
|
||||
fs = import('fs')
|
||||
|
||||
desktop_file = files('virt-manager.desktop.in')
|
||||
|
||||
appdata_file = files('virt-manager.appdata.xml.in')
|
||||
|
||||
install_data(
|
||||
'org.virt-manager.virt-manager.gschema.xml',
|
||||
install_dir: datadir / 'glib-2.0' / 'schemas',
|
||||
|
@ -19,6 +19,7 @@ subdir('data')
|
||||
subdir('ui')
|
||||
subdir('virtinst')
|
||||
subdir('virtManager')
|
||||
subdir('po')
|
||||
|
||||
if git
|
||||
spec_conf = configuration_data({
|
||||
|
174
po/POTFILES
Normal file
174
po/POTFILES
Normal file
@ -0,0 +1,174 @@
|
||||
data/virt-manager.appdata.xml.in
|
||||
data/virt-manager.desktop.in
|
||||
ui/about.ui
|
||||
ui/addhardware.ui
|
||||
ui/addstorage.ui
|
||||
ui/asyncjob.ui
|
||||
ui/clone.ui
|
||||
ui/connectauth.ui
|
||||
ui/console.ui
|
||||
ui/createconn.ui
|
||||
ui/createnet.ui
|
||||
ui/createpool.ui
|
||||
ui/createvm.ui
|
||||
ui/createvol.ui
|
||||
ui/delete.ui
|
||||
ui/details.ui
|
||||
ui/fsdetails.ui
|
||||
ui/gfxdetails.ui
|
||||
ui/hostnets.ui
|
||||
ui/hoststorage.ui
|
||||
ui/host.ui
|
||||
ui/manager.ui
|
||||
ui/migrate.ui
|
||||
ui/netlist.ui
|
||||
ui/oslist.ui
|
||||
ui/preferences.ui
|
||||
ui/snapshotsnew.ui
|
||||
ui/snapshots.ui
|
||||
ui/storagebrowse.ui
|
||||
ui/tpmdetails.ui
|
||||
ui/vmwindow.ui
|
||||
ui/vsockdetails.ui
|
||||
ui/xmleditor.ui
|
||||
virtinst/buildconfig.py
|
||||
virtinst/capabilities.py
|
||||
virtinst/cli.py
|
||||
virtinst/cloner.py
|
||||
virtinst/connection.py
|
||||
virtinst/devices/audio.py
|
||||
virtinst/devices/char.py
|
||||
virtinst/devices/controller.py
|
||||
virtinst/devices/device.py
|
||||
virtinst/devices/disk.py
|
||||
virtinst/devices/filesystem.py
|
||||
virtinst/devices/graphics.py
|
||||
virtinst/devices/hostdev.py
|
||||
virtinst/devices/__init__.py
|
||||
virtinst/devices/input.py
|
||||
virtinst/devices/interface.py
|
||||
virtinst/devices/iommu.py
|
||||
virtinst/devices/memballoon.py
|
||||
virtinst/devices/memory.py
|
||||
virtinst/devices/panic.py
|
||||
virtinst/devices/redirdev.py
|
||||
virtinst/devices/rng.py
|
||||
virtinst/devices/shmem.py
|
||||
virtinst/devices/smartcard.py
|
||||
virtinst/devices/sound.py
|
||||
virtinst/devices/tpm.py
|
||||
virtinst/devices/video.py
|
||||
virtinst/devices/vsock.py
|
||||
virtinst/devices/watchdog.py
|
||||
virtinst/diskbackend.py
|
||||
virtinst/domain/blkiotune.py
|
||||
virtinst/domain/clock.py
|
||||
virtinst/domain/cpu.py
|
||||
virtinst/domain/cputune.py
|
||||
virtinst/domain/features.py
|
||||
virtinst/domain/idmap.py
|
||||
virtinst/domain/__init__.py
|
||||
virtinst/domain/keywrap.py
|
||||
virtinst/domain/launch_security.py
|
||||
virtinst/domain/memorybacking.py
|
||||
virtinst/domain/memtune.py
|
||||
virtinst/domain/metadata.py
|
||||
virtinst/domain/numatune.py
|
||||
virtinst/domain/os.py
|
||||
virtinst/domain/pm.py
|
||||
virtinst/domain/resource.py
|
||||
virtinst/domain/seclabel.py
|
||||
virtinst/domain/sysinfo.py
|
||||
virtinst/domain/vcpus.py
|
||||
virtinst/domain/xmlnsqemu.py
|
||||
virtinst/domcapabilities.py
|
||||
virtinst/generatename.py
|
||||
virtinst/guest.py
|
||||
virtinst/__init__.py
|
||||
virtinst/install/cloudinit.py
|
||||
virtinst/install/__init__.py
|
||||
virtinst/install/installerinject.py
|
||||
virtinst/install/installer.py
|
||||
virtinst/install/installertreemedia.py
|
||||
virtinst/install/unattended.py
|
||||
virtinst/install/urldetect.py
|
||||
virtinst/install/urlfetcher.py
|
||||
virtinst/install/volumeupload.py
|
||||
virtinst/logger.py
|
||||
virtinst/network.py
|
||||
virtinst/nodedev.py
|
||||
virtinst/osdict.py
|
||||
virtinst/pollhelpers.py
|
||||
virtinst/_progresspriv.py
|
||||
virtinst/progress.py
|
||||
virtinst/snapshot.py
|
||||
virtinst/storage.py
|
||||
virtinst/support.py
|
||||
virtinst/uri.py
|
||||
virtinst/virtclone.py
|
||||
virtinst/virtinstall.py
|
||||
virtinst/virtxml.py
|
||||
virtinst/xmlapi.py
|
||||
virtinst/xmlbuilder.py
|
||||
virtinst/xmlutil.py
|
||||
virtManager/about.py
|
||||
virtManager/addhardware.py
|
||||
virtManager/asyncjob.py
|
||||
virtManager/baseclass.py
|
||||
virtManager/clone.py
|
||||
virtManager/config.py
|
||||
virtManager/connection.py
|
||||
virtManager/connmanager.py
|
||||
virtManager/createconn.py
|
||||
virtManager/createnet.py
|
||||
virtManager/createpool.py
|
||||
virtManager/createvm.py
|
||||
virtManager/createvol.py
|
||||
virtManager/delete.py
|
||||
virtManager/details/console.py
|
||||
virtManager/details/details.py
|
||||
virtManager/details/__init__.py
|
||||
virtManager/details/serialcon.py
|
||||
virtManager/details/snapshots.py
|
||||
virtManager/details/sshtunnels.py
|
||||
virtManager/details/viewers.py
|
||||
virtManager/device/addstorage.py
|
||||
virtManager/device/fsdetails.py
|
||||
virtManager/device/gfxdetails.py
|
||||
virtManager/device/__init__.py
|
||||
virtManager/device/mediacombo.py
|
||||
virtManager/device/netlist.py
|
||||
virtManager/device/tpmdetails.py
|
||||
virtManager/device/vsockdetails.py
|
||||
virtManager/engine.py
|
||||
virtManager/error.py
|
||||
virtManager/hostnets.py
|
||||
virtManager/host.py
|
||||
virtManager/hoststorage.py
|
||||
virtManager/__init__.py
|
||||
virtManager/lib/connectauth.py
|
||||
virtManager/lib/graphwidgets.py
|
||||
virtManager/lib/__init__.py
|
||||
virtManager/lib/inspection.py
|
||||
virtManager/lib/keyring.py
|
||||
virtManager/lib/libvirtenummap.py
|
||||
virtManager/lib/module_trace.py
|
||||
virtManager/lib/statsmanager.py
|
||||
virtManager/lib/testmock.py
|
||||
virtManager/lib/uiutil.py
|
||||
virtManager/manager.py
|
||||
virtManager/migrate.py
|
||||
virtManager/object/domain.py
|
||||
virtManager/object/__init__.py
|
||||
virtManager/object/libvirtobject.py
|
||||
virtManager/object/network.py
|
||||
virtManager/object/nodedev.py
|
||||
virtManager/object/storagepool.py
|
||||
virtManager/oslist.py
|
||||
virtManager/preferences.py
|
||||
virtManager/storagebrowse.py
|
||||
virtManager/systray.py
|
||||
virtManager/virtmanager.py
|
||||
virtManager/vmmenu.py
|
||||
virtManager/vmwindow.py
|
||||
virtManager/xmleditor.py
|
34
po/meson.build
Normal file
34
po/meson.build
Normal file
@ -0,0 +1,34 @@
|
||||
i18n = import('i18n')
|
||||
|
||||
i18n.merge_file(
|
||||
input: desktop_file,
|
||||
output: '@BASENAME@',
|
||||
type: 'desktop',
|
||||
po_dir: meson.current_source_dir(),
|
||||
install: true,
|
||||
install_dir: datadir / 'applications',
|
||||
)
|
||||
|
||||
i18n.merge_file(
|
||||
input: appdata_file,
|
||||
output: '@BASENAME@',
|
||||
type: 'xml',
|
||||
po_dir: meson.current_source_dir(),
|
||||
install: true,
|
||||
install_dir: datadir / 'metainfo',
|
||||
)
|
||||
|
||||
i18n.gettext(
|
||||
meson.project_name(),
|
||||
args: [
|
||||
'--from-code=UTF-8',
|
||||
'--keyword=_',
|
||||
'--add-comments=translators',
|
||||
'--directory=@0@'.format(meson.project_source_root()),
|
||||
'--files-from=@0@'.format(meson.current_source_dir() / 'POTFILES'),
|
||||
'--msgid-bugs-address=https://github.com/virt-manager/virt-manager/issues',
|
||||
'--package-version=@0@'.format(meson.project_version()),
|
||||
'--sort-by-file',
|
||||
'--join-existing',
|
||||
],
|
||||
)
|
135
setup.py
135
setup.py
@ -49,85 +49,6 @@ def _import_buildconfig():
|
||||
BuildConfig = _import_buildconfig()
|
||||
|
||||
|
||||
# pylint: disable=attribute-defined-outside-init
|
||||
|
||||
_desktop_files = [
|
||||
("share/applications", ["data/virt-manager.desktop.in"]),
|
||||
]
|
||||
_appdata_files = [
|
||||
("share/metainfo", ["data/virt-manager.appdata.xml.in"]),
|
||||
]
|
||||
|
||||
|
||||
class my_build_i18n(setuptools.Command):
|
||||
"""
|
||||
Add our desktop files to the list, saves us having to track setup.cfg
|
||||
"""
|
||||
user_options = [
|
||||
('merge-po', 'm', 'merge po files against template'),
|
||||
]
|
||||
|
||||
def initialize_options(self):
|
||||
self.merge_po = False
|
||||
def finalize_options(self):
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
po_dir = "po"
|
||||
if self.merge_po:
|
||||
pot_file = os.path.join("po", "virt-manager.pot")
|
||||
for po_file in glob.glob("%s/*.po" % po_dir):
|
||||
cmd = ["msgmerge", "--previous", "-o", po_file, po_file, pot_file]
|
||||
self.spawn(cmd)
|
||||
|
||||
max_po_mtime = 0
|
||||
for po_file in glob.glob("%s/*.po" % po_dir):
|
||||
lang = os.path.basename(po_file[:-3])
|
||||
mo_dir = os.path.join("build", "mo", lang, "LC_MESSAGES")
|
||||
mo_file = os.path.join(mo_dir, "virt-manager.mo")
|
||||
if not os.path.exists(mo_dir):
|
||||
os.makedirs(mo_dir)
|
||||
|
||||
cmd = ["msgfmt", po_file, "-o", mo_file]
|
||||
po_mtime = os.path.getmtime(po_file)
|
||||
mo_mtime = (os.path.exists(mo_file) and
|
||||
os.path.getmtime(mo_file)) or 0
|
||||
max_po_mtime = max(max_po_mtime, po_mtime)
|
||||
if po_mtime > mo_mtime:
|
||||
self.spawn(cmd)
|
||||
|
||||
targetpath = os.path.join("share/locale", lang, "LC_MESSAGES")
|
||||
self.distribution.data_files.append((targetpath, (mo_file,)))
|
||||
|
||||
# Merge .in with translations using gettext
|
||||
for (file_set, switch) in [(_appdata_files, "--xml"),
|
||||
(_desktop_files, "--desktop")]:
|
||||
for (target, files) in file_set:
|
||||
build_target = os.path.join("build", target)
|
||||
if not os.path.exists(build_target):
|
||||
os.makedirs(build_target)
|
||||
|
||||
files_merged = []
|
||||
for f in files:
|
||||
if f.endswith(".in"):
|
||||
file_merged = os.path.basename(f[:-3])
|
||||
else:
|
||||
file_merged = os.path.basename(f)
|
||||
|
||||
file_merged = os.path.join(build_target, file_merged)
|
||||
cmd = ["msgfmt", switch, "--template", f, "-d", po_dir,
|
||||
"-o", file_merged]
|
||||
mtime_merged = (os.path.exists(file_merged) and
|
||||
os.path.getmtime(file_merged)) or 0
|
||||
mtime_file = os.path.getmtime(f)
|
||||
if (mtime_merged < max_po_mtime or
|
||||
mtime_merged < mtime_file):
|
||||
# Only build if output is older than input (.po,.in)
|
||||
self.spawn(cmd)
|
||||
files_merged.append(file_merged)
|
||||
self.distribution.data_files.append((target, files_merged))
|
||||
|
||||
|
||||
class my_build(BUILD_COMMAND_CLASS):
|
||||
def _make_bin_wrappers(self):
|
||||
template = """#!/usr/bin/env python3
|
||||
@ -163,7 +84,6 @@ from %(pkgname)s import %(filename)s
|
||||
def run(self):
|
||||
self._make_bin_wrappers()
|
||||
|
||||
self.run_command("build_i18n")
|
||||
super().run()
|
||||
|
||||
|
||||
@ -367,58 +287,6 @@ class VMMDistribution(setuptools.dist.Distribution):
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
||||
class ExtractMessages(setuptools.Command):
|
||||
user_options = [
|
||||
]
|
||||
description = "Extract the translation messages"
|
||||
|
||||
def initialize_options(self):
|
||||
pass
|
||||
|
||||
def finalize_options(self):
|
||||
pass
|
||||
|
||||
def run(self):
|
||||
bug_address = "https://github.com/virt-manager/virt-manager/issues"
|
||||
potfile = "po/virt-manager.pot"
|
||||
xgettext_args = [
|
||||
"xgettext",
|
||||
"--add-comments=translators",
|
||||
"--msgid-bugs-address=" + bug_address,
|
||||
"--package-name=virt-manager",
|
||||
"--output=" + potfile,
|
||||
"--sort-by-file",
|
||||
"--join-existing",
|
||||
]
|
||||
|
||||
# Truncate .pot file to ensure it exists
|
||||
open(potfile, "w").write("")
|
||||
|
||||
# First extract the messages from the AppStream sources,
|
||||
# creating the template
|
||||
appdata_files = [f for sublist in _appdata_files for f in sublist[1]]
|
||||
cmd = xgettext_args + appdata_files
|
||||
self.spawn(cmd)
|
||||
|
||||
# Extract the messages from the desktop files
|
||||
desktop_files = [f for sublist in _desktop_files for f in sublist[1]]
|
||||
cmd = xgettext_args + ["--language=Desktop"] + desktop_files
|
||||
self.spawn(cmd)
|
||||
|
||||
# Extract the messages from the Python sources
|
||||
py_sources = list(Path("virtManager").rglob("*.py"))
|
||||
py_sources += list(Path("virtinst").rglob("*.py"))
|
||||
py_sources = [str(src) for src in py_sources]
|
||||
cmd = xgettext_args + ["--language=Python"] + py_sources
|
||||
self.spawn(cmd)
|
||||
|
||||
# Extract the messages from the Glade UI files
|
||||
ui_files = list(Path(".").rglob("*.ui"))
|
||||
ui_files = [str(src) for src in ui_files]
|
||||
cmd = xgettext_args + ["--language=Glade"] + ui_files
|
||||
self.spawn(cmd)
|
||||
|
||||
|
||||
setuptools.setup(
|
||||
name="virt-manager",
|
||||
version=BuildConfig.version,
|
||||
@ -442,7 +310,6 @@ setuptools.setup(
|
||||
|
||||
cmdclass={
|
||||
'build': my_build,
|
||||
'build_i18n': my_build_i18n,
|
||||
|
||||
'install': my_install,
|
||||
'install_egg_info': my_egg_info,
|
||||
@ -452,8 +319,6 @@ setuptools.setup(
|
||||
'pylint': CheckPylint,
|
||||
'rpm': my_rpm,
|
||||
'test': TestCommand,
|
||||
|
||||
'extract_messages': ExtractMessages,
|
||||
},
|
||||
|
||||
distclass=VMMDistribution,
|
||||
|
Loading…
Reference in New Issue
Block a user