Warn user, if input encodings of master and child document differ.

This commit is contained in:
Günter Milde 2019-03-18 12:49:10 +01:00
parent 9e825d5035
commit dae90c6161
4 changed files with 30 additions and 1 deletions

View File

@ -142,7 +142,7 @@ the parent loads the child document with wrong input encoding.
\begin_layout Standard
Example: This document uses
\family typewriter
latin9
iso8859-15
\family default
, the included child
\family typewriter

View File

@ -793,6 +793,17 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
from_utf8(master_tf));
Alert::warning(_("Different use-non-TeX-fonts settings"), text, true);
}
else if (tmp->params().inputenc != masterBuffer->params().inputenc) {
docstring text = bformat(_("Included file `%1$s'\n"
"uses input encoding \"%2$s\" [%3$s]\n"
"while parent file uses input encoding \"%4$s\" [%5$s]."),
included_file.displayName(),
_(tmp->params().inputenc),
from_utf8(tmp->params().encoding().guiName()),
_(masterBuffer->params().inputenc),
from_utf8(masterBuffer->params().encoding().guiName()));
Alert::warning(_("Different LaTeX input encodings"), text, true);
}
// Make sure modules used in child are all included in master
// FIXME It might be worth loading the children's modules into the master

View File

@ -1575,5 +1575,22 @@ docstring bformat(docstring const & fmt,
return subst(str, from_ascii("%%"), from_ascii("%"));
}
docstring bformat(docstring const & fmt, docstring const & arg1,
docstring const & arg2, docstring const & arg3,
docstring const & arg4, docstring const & arg5)
{
LATTEST(contains(fmt, from_ascii("%1$s")));
LATTEST(contains(fmt, from_ascii("%2$s")));
LATTEST(contains(fmt, from_ascii("%3$s")));
LATTEST(contains(fmt, from_ascii("%4$s")));
LATTEST(contains(fmt, from_ascii("%5$s")));
docstring str = subst(fmt, from_ascii("%1$s"), arg1);
str = subst(str, from_ascii("%2$s"), arg2);
str = subst(str, from_ascii("%3$s"), arg3);
str = subst(str, from_ascii("%4$s"), arg4);
str = subst(str, from_ascii("%5$s"), arg5);
return subst(str, from_ascii("%%"), from_ascii("%"));
}
} // namespace support
} // namespace lyx

View File

@ -372,6 +372,7 @@ docstring bformat(docstring const & fmt, char const * arg1, docstring const & ar
docstring bformat(docstring const & fmt, int arg1, int arg2);
docstring bformat(docstring const & fmt, docstring const & arg1, docstring const & arg2, docstring const & arg3);
docstring bformat(docstring const & fmt, docstring const & arg1, docstring const & arg2, docstring const & arg3, docstring const & arg4);
docstring bformat(docstring const & fmt, docstring const & arg1, docstring const & arg2, docstring const & arg3, docstring const & arg4, docstring const & arg5);
} // namespace support