mirror of
https://git.lyx.org/repos/lyx.git
synced 2025-01-05 17:09:56 +00:00
*** fix bug 2488 (make dynamic formats in menus translatable) ***
* po/lyx_pot.py: - new method formats_l10n that parses configure.py for file formats and shortcuts * po/Makefile.in.in: * development/scons/SConstruct: - call formats_l10n on po update * src/MenuBackend.cpp: - handle translated formats * src/LyXFunc.cpp: - use translated string for file filter git-svn-id: svn://svn.lyx.org/lyx/lyx-devel/branches/BRANCH_1_5_X@24831 a592a061-630c-0410-9148-cb99ea01b6c8
This commit is contained in:
parent
a805a50fd9
commit
8896987c68
@ -2065,7 +2065,7 @@ if update_po:
|
|||||||
['$TOP_SRCDIR/src/tex2lyx/%s' % x for x in src_tex2lyx_header_files + src_tex2lyx_files ]
|
['$TOP_SRCDIR/src/tex2lyx/%s' % x for x in src_tex2lyx_header_files + src_tex2lyx_files ]
|
||||||
)
|
)
|
||||||
Alias('update_po', POTFILES_in)
|
Alias('update_po', POTFILES_in)
|
||||||
# build language_l10n.pot, ui_l10n.pot, layouts_l10n.pot, qt4_l10n.pot, external_l10n
|
# build language_l10n.pot, ui_l10n.pot, layouts_l10n.pot, qt4_l10n.pot, external_l10n, formats_l10n
|
||||||
# and combine them to lyx.po
|
# and combine them to lyx.po
|
||||||
env['LYX_POT'] = 'python $TOP_SRCDIR/po/lyx_pot.py'
|
env['LYX_POT'] = 'python $TOP_SRCDIR/po/lyx_pot.py'
|
||||||
lyx_po = env.Command('$BUILDDIR/po/lyx.po',
|
lyx_po = env.Command('$BUILDDIR/po/lyx.po',
|
||||||
@ -2083,6 +2083,8 @@ if update_po:
|
|||||||
'$LYX_POT -b $TOP_SRCDIR -t ui -o $TARGET $SOURCES'),
|
'$LYX_POT -b $TOP_SRCDIR -t ui -o $TARGET $SOURCES'),
|
||||||
env.Command('$BUILDDIR/po/external_l10n.pot', '$TOP_SRCDIR/lib/external_templates',
|
env.Command('$BUILDDIR/po/external_l10n.pot', '$TOP_SRCDIR/lib/external_templates',
|
||||||
'$LYX_POT -b $TOP_SRCDIR -t external -o $TARGET $SOURCES'),
|
'$LYX_POT -b $TOP_SRCDIR -t external -o $TARGET $SOURCES'),
|
||||||
|
env.Command('$BUILDDIR/po/formats_l10n.pot', '$TOP_SRCDIR/lib/configure.py',
|
||||||
|
'$LYX_POT -b $TOP_SRCDIR -t formats -o $TARGET $SOURCES'),
|
||||||
], utils.env_cat),
|
], utils.env_cat),
|
||||||
['$MSGUNIQ -o $TARGET $SOURCE',
|
['$MSGUNIQ -o $TARGET $SOURCE',
|
||||||
'''$XGETTEXT --default-domain=${TARGET.base} \
|
'''$XGETTEXT --default-domain=${TARGET.base} \
|
||||||
|
@ -393,7 +393,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 ui_l10n.pot external_l10n.pot
|
l10n_pots: qt4_l10n.pot layouts_l10n.pot languages_l10n.pot ui_l10n.pot external_l10n.pot formats_l10n.pot
|
||||||
cat $^ | \
|
cat $^ | \
|
||||||
msguniq -o $(DOMAIN).po && rm -f $^
|
msguniq -o $(DOMAIN).po && rm -f $^
|
||||||
|
|
||||||
@ -419,6 +419,9 @@ i18n.inc: $(POFILES) postats.py
|
|||||||
external_l10n.pot: $(top_srcdir)/lib/external_templates
|
external_l10n.pot: $(top_srcdir)/lib/external_templates
|
||||||
python $(srcdir)/lyx_pot.py -b $(top_srcdir) -o $@ -t external ${top_srcdir}/lib/external_templates
|
python $(srcdir)/lyx_pot.py -b $(top_srcdir) -o $@ -t external ${top_srcdir}/lib/external_templates
|
||||||
|
|
||||||
|
formats_l10n.pot: $(top_srcdir)/lib/configure.py
|
||||||
|
python $(srcdir)/lyx_pot.py -b $(top_srcdir) -o $@ -t formats ${top_srcdir}/lib/configure.py
|
||||||
|
|
||||||
force:
|
force:
|
||||||
|
|
||||||
# Tell versions [3.59,3.63) of GNU make not to export all variables.
|
# Tell versions [3.59,3.63) of GNU make not to export all variables.
|
||||||
|
@ -194,6 +194,36 @@ def external_l10n(input_files, output, base):
|
|||||||
output.close()
|
output.close()
|
||||||
|
|
||||||
|
|
||||||
|
def formats_l10n(input_files, output, base):
|
||||||
|
'''Generate pot file from configure.py'''
|
||||||
|
output = open(output, 'w')
|
||||||
|
GuiName = re.compile(r'.*\Format\s+\S+\s+\S+\s+"([^"]*)"\s+(\S*)\s+.*')
|
||||||
|
GuiName2 = re.compile(r'.*\Format\s+\S+\s+\S+\s+([^"]\S+)\s+(\S*)\s+.*')
|
||||||
|
input = open(input_files[0])
|
||||||
|
for lineno, line in enumerate(input.readlines()):
|
||||||
|
label = ""
|
||||||
|
labelsc = ""
|
||||||
|
if GuiName.match(line):
|
||||||
|
label = GuiName.match(line).group(1)
|
||||||
|
shortcut = GuiName.match(line).group(2).replace('"', '')
|
||||||
|
elif GuiName2.match(line):
|
||||||
|
label = GuiName2.match(line).group(1)
|
||||||
|
shortcut = GuiName2.match(line).group(2).replace('"', '')
|
||||||
|
else:
|
||||||
|
continue
|
||||||
|
label = label.replace('\\', '\\\\').replace('"', '')
|
||||||
|
if shortcut != "":
|
||||||
|
labelsc = label + "|" + shortcut
|
||||||
|
if label != "":
|
||||||
|
print >> output, '#: %s:%d\nmsgid "%s"\nmsgstr ""\n' % \
|
||||||
|
(relativePath(input_files[0], base), lineno+1, label)
|
||||||
|
if labelsc != "":
|
||||||
|
print >> output, '#: %s:%d\nmsgid "%s"\nmsgstr ""\n' % \
|
||||||
|
(relativePath(input_files[0], base), lineno+1, labelsc)
|
||||||
|
input.close()
|
||||||
|
output.close()
|
||||||
|
|
||||||
|
|
||||||
Usage = '''
|
Usage = '''
|
||||||
lyx_pot.py [-b|--base top_src_dir] [-o|--output output_file] [-h|--help] -t|--type input_type input_files
|
lyx_pot.py [-b|--base top_src_dir] [-o|--output output_file] [-h|--help] -t|--type input_type input_files
|
||||||
|
|
||||||
@ -208,6 +238,7 @@ where
|
|||||||
qt4: qt4 ui files
|
qt4: qt4 ui files
|
||||||
languages: file lib/languages
|
languages: file lib/languages
|
||||||
external: external templates file
|
external: external templates file
|
||||||
|
formats: formats predefined in lib/configure.py
|
||||||
'''
|
'''
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
@ -227,7 +258,7 @@ if __name__ == '__main__':
|
|||||||
base = value
|
base = value
|
||||||
elif opt in ['-t', '--type']:
|
elif opt in ['-t', '--type']:
|
||||||
input_type = value
|
input_type = value
|
||||||
if input_type not in ['ui', 'layouts', 'qt4', 'languages', 'external'] or output is None:
|
if input_type not in ['ui', 'layouts', 'qt4', 'languages', 'external', 'formats'] or output is None:
|
||||||
print 'Wrong input type or output filename.'
|
print 'Wrong input type or output filename.'
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
if input_type == 'ui':
|
if input_type == 'ui':
|
||||||
@ -238,6 +269,8 @@ if __name__ == '__main__':
|
|||||||
qt4_l10n(args, output, base)
|
qt4_l10n(args, output, base)
|
||||||
elif input_type == 'external':
|
elif input_type == 'external':
|
||||||
external_l10n(args, output, base)
|
external_l10n(args, output, base)
|
||||||
|
elif input_type == 'formats':
|
||||||
|
formats_l10n(args, output, base)
|
||||||
else:
|
else:
|
||||||
languages_l10n(args, output, base)
|
languages_l10n(args, output, base)
|
||||||
|
|
||||||
|
@ -2117,7 +2117,7 @@ void LyXFunc::doImport(string const & argument)
|
|||||||
make_pair(_("Examples|#E#e"),
|
make_pair(_("Examples|#E#e"),
|
||||||
from_utf8(addPath(package().system_support().absFilename(), "examples"))));
|
from_utf8(addPath(package().system_support().absFilename(), "examples"))));
|
||||||
|
|
||||||
docstring filter = formats.prettyName(format);
|
docstring filter = translateIfPossible(formats.prettyName(format));
|
||||||
filter += " (*.";
|
filter += " (*.";
|
||||||
// FIXME UNICODE
|
// FIXME UNICODE
|
||||||
filter += from_utf8(formats.extension(format));
|
filter += from_utf8(formats.extension(format));
|
||||||
|
@ -53,6 +53,7 @@ namespace lyx {
|
|||||||
using support::compare_ascii_no_case;
|
using support::compare_ascii_no_case;
|
||||||
using support::contains;
|
using support::contains;
|
||||||
using support::makeDisplayPath;
|
using support::makeDisplayPath;
|
||||||
|
using support::split;
|
||||||
using support::token;
|
using support::token;
|
||||||
|
|
||||||
using boost::bind;
|
using boost::bind;
|
||||||
@ -534,16 +535,20 @@ void expandFormats(MenuItem::Kind kind, Menu & tomenu, Buffer const * buf)
|
|||||||
if ((*fit)->dummy())
|
if ((*fit)->dummy())
|
||||||
continue;
|
continue;
|
||||||
docstring label = from_utf8((*fit)->prettyname());
|
docstring label = from_utf8((*fit)->prettyname());
|
||||||
docstring const shortcut = from_utf8((*fit)->shortcut());
|
docstring shortcut = from_utf8((*fit)->shortcut());
|
||||||
|
|
||||||
|
if (!shortcut.empty())
|
||||||
|
label += char_type('|') + shortcut;
|
||||||
|
docstring label_i18n = translateIfPossible(label);
|
||||||
|
bool const untranslated = (label == label_i18n);
|
||||||
|
shortcut = split(label_i18n, label, '|');
|
||||||
|
if (untranslated)
|
||||||
|
// this might happen if the shortcut
|
||||||
|
// has been redefined
|
||||||
|
label = translateIfPossible(label);
|
||||||
|
|
||||||
switch (kind) {
|
switch (kind) {
|
||||||
case MenuItem::ImportFormats:
|
case MenuItem::ImportFormats:
|
||||||
// FIXME: This is a hack, we should rather solve
|
|
||||||
// FIXME: bug 2488 instead.
|
|
||||||
if ((*fit)->name() == "text")
|
|
||||||
label = _("Plain Text");
|
|
||||||
else if ((*fit)->name() == "textparagraph")
|
|
||||||
label = _("Plain Text, Join Lines");
|
|
||||||
label += "...";
|
label += "...";
|
||||||
break;
|
break;
|
||||||
case MenuItem::ViewFormats:
|
case MenuItem::ViewFormats:
|
||||||
@ -556,12 +561,7 @@ void expandFormats(MenuItem::Kind kind, Menu & tomenu, Buffer const * buf)
|
|||||||
BOOST_ASSERT(false);
|
BOOST_ASSERT(false);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// FIXME: if we had proper support for translating the
|
if (!shortcut.empty())
|
||||||
// format names defined in configure.py, there would
|
|
||||||
// not be a need to check whether the shortcut is
|
|
||||||
// correct. If we add it uncondiitonally, it would
|
|
||||||
// create useless warnings on bad shortcuts
|
|
||||||
if (!shortcut.empty() && contains(label, shortcut))
|
|
||||||
label += char_type('|') + shortcut;
|
label += char_type('|') + shortcut;
|
||||||
|
|
||||||
if (buf)
|
if (buf)
|
||||||
|
15
status.15x
15
status.15x
@ -46,12 +46,12 @@ What's new
|
|||||||
importing LaTeX files (bug 4867).
|
importing LaTeX files (bug 4867).
|
||||||
|
|
||||||
|
|
||||||
* WINDOWS INSTALLER:
|
* WINDOWS INSTALLER
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
* BUILD:
|
* BUILD
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -64,16 +64,17 @@ What's new
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
* USER INTERFACE:
|
* USER INTERFACE
|
||||||
|
|
||||||
- Fix display of filters such as "LaTeX (plain)" in the file dialog.
|
- Fix display of filters such as "LaTeX (plain)" in the file dialog.
|
||||||
|
|
||||||
|
|
||||||
* DOCUMENTATION
|
* DOCUMENTATION AND LOCALIZATION
|
||||||
|
|
||||||
|
- The dynamically generated file formats in the menus are now translatable
|
||||||
|
(bug 2488).
|
||||||
|
|
||||||
|
|
||||||
|
* BUILD/INSTALLATION
|
||||||
|
|
||||||
* BUILD/INSTALLATION:
|
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user