Now can generate mo files from po files and install them.

pull/15/head
Jussi Pakkanen 12 years ago
parent b422afac9b
commit 0e19d90e97
  1. 31
      backends.py
  2. 1
      coredata.py
  3. 18
      meson_install.py
  4. 2
      test cases/frameworks/6 gettext/po/de.po
  5. 2
      test cases/frameworks/6 gettext/po/fi.po
  6. 2
      test cases/frameworks/6 gettext/src/meson.build

@ -339,6 +339,13 @@ class NinjaBackend(Backend):
elem.add_item('FILELIST', os.path.join(self.environment.get_source_dir(), input_file))
elem.add_item('OUTDIR', os.path.join(self.environment.get_source_dir(), subdir))
elem.write(outfile)
for l in languages:
infile = os.path.join(self.environment.get_source_dir(), subdir, l + '.po')
outfilename = os.path.join(subdir, l + '.gmo')
lelem = NinjaBuildElement(outfilename, 'GEN_GMO', infile)
lelem.add_item('INFILE', infile)
lelem.add_item('OUTFILE', outfilename)
lelem.write(outfile)
def generate_coverage_rules(self, outfile):
(gcovr_exe, lcov_exe, genhtml_exe) = environment.find_coverage_tools()
@ -382,15 +389,27 @@ class NinjaBackend(Backend):
elem.add_dep('all')
elem.add_item('DESC', 'Installing files.')
elem.add_item('COMMAND', [sys.executable, install_script, install_data_file])
elem.write(outfile)
self.generate_target_install(d)
self.generate_header_install(d)
self.generate_man_install(d)
self.generate_data_install(d)
self.generate_po_install(d, elem)
elem.write(outfile)
ofile = open(install_data_file, 'wb')
pickle.dump(d, ofile)
def generate_po_install(self, d, elem):
for p in self.build.pot:
(package_name, languages, subdir) = p
# FIXME: assumes only one po package per source
d.po_package_name = package_name
for lang in languages:
rel_src = os.path.join(subdir, lang + '.gmo')
src_file = os.path.join(self.environment.get_build_dir(), rel_src)
d.po.append((src_file, self.environment.coredata.localedir, lang))
elem.add_dep(rel_src)
def generate_target_install(self, d):
libdir = self.environment.get_libdir()
bindir = self.environment.get_bindir()
@ -530,6 +549,14 @@ class NinjaBackend(Backend):
outfile.write(rule)
outfile.write(command)
outfile.write(desc)
outfile.write('\n')
rule = 'rule GEN_GMO\n'
command = ' command = msgfmt $INFILE -o $OUTFILE\n'
desc = ' description = Generating gmo file $OUTFILE\n'
outfile.write(rule)
outfile.write(command)
outfile.write(desc)
outfile.write('\n')
def generate_static_link_rules(self, is_cross, outfile):
if is_cross:

@ -30,6 +30,7 @@ class CoreData():
self.includedir = options.includedir
self.datadir = options.datadir
self.mandir = options.mandir
self.localedir = options.localedir
self.backend = options.backend
self.buildtype = options.buildtype
self.strip = options.strip

@ -25,6 +25,8 @@ class InstallData():
self.headers = []
self.man = []
self.data = []
self.po_package_name = ''
self.po = []
def do_install(datafilename):
ifile = open(datafilename, 'rb')
@ -40,6 +42,20 @@ def do_install(datafilename):
install_headers(d)
install_man(d)
install_data(d)
install_po(d)
def install_po(d):
packagename = d.po_package_name
for f in d.po:
srcfile = f[0]
localedir = f[1]
languagename = f[2]
outfile = os.path.join(d.prefix, localedir, languagename, 'LC_MESSAGES',
packagename + '.mo')
os.makedirs(os.path.split(outfile)[0], exist_ok=True)
shutil.copyfile(srcfile, outfile)
shutil.copystat(srcfile, outfile)
print('Installing %s to %s.' % (srcfile, outfile))
def install_data(d):
for i in d.data:
@ -88,7 +104,7 @@ def install_targets(d):
fname = t[0]
outdir = os.path.join(d.prefix, t[1])
aliases = t[2]
outname = os.path.join(outdir, fname)
outname = os.path.join(outdir, os.path.split(fname)[-1])
should_strip = t[3]
print('Installing %s to %s' % (fname, outname))
os.makedirs(outdir, exist_ok=True)

@ -19,4 +19,4 @@ msgstr ""
#: src/intlmain.c:15
msgid "International greeting."
msgstr "Internationale Gruß."
msgstr "Internationale Gruss."

@ -19,4 +19,4 @@ msgstr ""
#: src/intlmain.c:15
msgid "International greeting."
msgstr "Kansainvälinen tervehdys."
msgstr "Maailman tervehdys."

@ -1 +1 @@
executable('intlprog', 'intlmain.c')
executable('intlprog', 'intlmain.c', install : true)

Loading…
Cancel
Save