Add examples/templates dialog entries to po files.

This commit is contained in:
Juergen Spitzmueller 2019-03-19 09:08:44 +01:00
parent f7ec0de2eb
commit c8930f6342
2 changed files with 41 additions and 3 deletions

View File

@ -16,7 +16,7 @@ ${srcdir}/POTFILES.in: $(POTFILE_IN_DEPS)
sort | uniq ) > $@-t \ sort | uniq ) > $@-t \
&& mv $@-t $@ && mv $@-t $@
l10n_pots: qt4_l10n.pot layouts_l10n.pot languages_l10n.pot latexfonts_l10n.pot encodings_l10n.pot ui_l10n.pot external_l10n.pot formats_l10n.pot l10n_pots: qt4_l10n.pot layouts_l10n.pot languages_l10n.pot latexfonts_l10n.pot encodings_l10n.pot ui_l10n.pot external_l10n.pot formats_l10n.pot examples_templates_l10n.pot
cat $^ | msguniq -o $(DOMAIN).po cat $^ | msguniq -o $(DOMAIN).po
rm $^ rm $^
@ -56,6 +56,10 @@ external_l10n.pot: $(top_srcdir)/lib/xtemplates/*.xtemplate
formats_l10n.pot: $(top_srcdir)/lib/configure.py formats_l10n.pot: $(top_srcdir)/lib/configure.py
$(LYX_POT) -o $@ -t formats $^ $(LYX_POT) -o $@ -t formats $^
examples_templates_l10n.pot: $(top_srcdir)/lib/examples/* \
$(top_srcdir)/lib/templates/*
$(LYX_POT) -o $@ -t examples_templates '$^'
# LyX specific code to generate l10n statistics for the web site # LyX specific code to generate l10n statistics for the web site
i18n.inc: $(POFILES) postats.py i18n.inc: $(POFILES) postats.py
$(PYTHON) $(srcdir)/postats.py "$(VERSION)" $(POFILES) >$@ $(PYTHON) $(srcdir)/postats.py "$(VERSION)" $(POFILES) >$@

View File

@ -18,7 +18,7 @@
# #
from __future__ import print_function from __future__ import print_function
import sys, os, re, getopt import glob, sys, os, re, getopt
import io import io
def relativePath(path, base): def relativePath(path, base):
@ -623,6 +623,37 @@ def encodings_l10n(input_files, output, base):
output.close() output.close()
def examples_templates_l10n(input_files, output, base):
'''Generate pot file from lib/templates and lib/examples'''
output = io.open(output, 'w', encoding='utf_8', newline='\n')
# only record each item once
seen = []
inputfs = input_files[0].split()
for src in inputfs:
parseExamplesTemplates(src, seen, output)
output.close()
def parseExamplesTemplates(file, seen, output):
# Recursively iterate over subdirectories
if os.path.isdir(file):
for sfile in glob.glob( os.path.join(file, '*') ):
parseExamplesTemplates(sfile, seen, output)
filename = file.split(os.sep)[-1]
if os.path.isfile(file):
if filename[-4:] != ".lyx":
return
filename = filename[:-4]
if seen.count(filename) or filename[0].islower():
return
seen.append(filename)
if filename != "":
print(u'#: %s:%d\nmsgid "%s"\nmsgstr ""\n' % \
(relativePath(input_files[0], base), 0, filename.replace('_', ' ')), file=output)
Usage = ''' Usage = '''
lyx_pot.py [-b|--base top_src_dir] [-o|--output output_file] [-h|--help] [-s|src_file filename] -t|--type input_type input_files lyx_pot.py [-b|--base top_src_dir] [-o|--output output_file] [-h|--help] [-s|src_file filename] -t|--type input_type input_files
@ -644,6 +675,7 @@ where
encodings: file lib/encodings encodings: file lib/encodings
external: external templates files external: external templates files
formats: formats predefined in lib/configure.py formats: formats predefined in lib/configure.py
examples_templates: example and template files
''' '''
if __name__ == '__main__': if __name__ == '__main__':
@ -667,7 +699,7 @@ if __name__ == '__main__':
elif opt in ['-s', '--src_file']: elif opt in ['-s', '--src_file']:
input_files = [f.strip() for f in io.open(value, encoding='utf_8')] input_files = [f.strip() for f in io.open(value, encoding='utf_8')]
if input_type not in ['ui', 'layouts', 'layouttranslations', 'qt4', 'languages', 'latexfonts', 'encodings', 'external', 'formats'] or output is None: if input_type not in ['ui', 'layouts', 'layouttranslations', 'qt4', 'languages', 'latexfonts', 'encodings', 'external', 'formats', 'examples_templates'] or output is None:
print('Wrong input type or output filename.') print('Wrong input type or output filename.')
sys.exit(1) sys.exit(1)
@ -696,5 +728,7 @@ if __name__ == '__main__':
formats_l10n(input_files, output, base) formats_l10n(input_files, output, base)
elif input_type == 'encodings': elif input_type == 'encodings':
encodings_l10n(input_files, output, base) encodings_l10n(input_files, output, base)
elif input_type == 'examples_templates':
examples_templates_l10n(input_files, output, base)
else: else:
languages_l10n(input_files, output, base) languages_l10n(input_files, output, base)