]> git.lyx.org Git - features.git/commitdiff
Warn user, if input encodings of master and child document differ.
authorGünter Milde <milde@lyx.org>
Mon, 18 Mar 2019 11:49:10 +0000 (12:49 +0100)
committerJean-Marc Lasgouttes <lasgouttes@lyx.org>
Thu, 18 Jun 2020 13:48:17 +0000 (15:48 +0200)
autotests/export/latex/parent-with-other-inputenc.lyx
src/insets/InsetInclude.cpp
src/support/lstrings.cpp
src/support/lstrings.h

index d630a7f18bce560232e95a9652802e6dba448b0f..b347d0344ac3da5eba392b36872743887afa99f1 100644 (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
index 988a051a7862fdedc6865c53f826dccd5adbc9f5..87a817337bae5210abb59510f95728aa652494e1 100755 (executable)
@@ -792,6 +792,17 @@ void InsetInclude::latex(otexstream & os, OutputParams const & runparams) const
                                        from_utf8(child_tf),
                                        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
index 21fe05aa09389fb1e04b7518529d64793fe395ab..e69fc8837b494f5db8e5723d46b9bede91233405 100644 (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
index 7d2fc6dd77d9d23a12a08c562e8dae23408cf69c..fcf1cbb6feeb49bf6f4ca5e43e8fefc74b93083a 100644 (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