>>>>> "Uwe" == Uwe Stöhr <[EMAIL PROTECTED]> writes:
Uwe> You have to clear lang_pack in this case. otherwise you will
Uwe> return "\\usepackage{babel}" although babel shouldn't be called.
I'd be interested if you could test the latest patch I posted. With
it, you will see that since we return an empty string when lang_opts
is empty, there is no need to clear anything.
Uwe> lang_opts is the full list of languages to pass to babel but it
Uwe> has NOT to contain the document language. That is the point. If
Uwe> you have a Chinses document, the document language doesn't appear
Uwe> in the lang_opts list as Chinese defined an empty babel language
Uwe> in lib/languages. That is new since Georgs support for the
Uwe> CJK-languages.
I know that. But the full logic of the code is that we do not want to
call babel when there are no languages to pass to babel, right?
>>> + lang_pack.clear();
>> or directly "return string()", since you know nothing is going to
>> happen.
Uwe> Now I'm confused as Abdel stated two days ago I should better use
Uwe> the .clear() method and not string().
I think Abdel referred to something like
tmp = string();
this is a bit different. I think there is no need to modify the
lang_pack variable (actually, there is no need for this variable,
but I did not remove it in my patch because I do not care much about it).
>>> + if (!lyxrc.language_global_options && !lang_opts.empty())
>> we know that !lang_opts.empty() (because of the change above)
Uwe> No we don't: For a Chinese document you would then get
Uwe> "\usepackage[]{babel}" and this is wrong.
No, because when lang_opts is empty, we already exited the function
and returned string(). The whole idea of my code is to test this (we
do not want to output \usepackage[]{babel}, indeed), instead of the
possible reasons that may lead to this condition.
>>> + if (lyxrc.language_global_options)
>> or just a "else" instead.
Uwe> Not possible because of the needed !lang_opts.empty() check in
Uwe> the if case before.
No (again :), because if we are here lang_opts is not empty.
>> The logic of your above code is really weird. I think it works, but
>> it is somewhat by chance.
Uwe> I hope I could explain that it is not weird. And hey, it doesn't
Uwe> work by chance, I hardly tested this before I committed it! I
Uwe> have 8 different testcases with mixed languages to cover all
Uwe> cases.
I know that, I do not want to hurt your feelings. What I mean is that
the code paths are a bit weird, like for example in this case:
1418 if (!lyxrc.language_global_options &&
!lang_opts.empty())
1419 lang_pack = string("\\usepackage[") + lang_opts
+ "]{babel}";
1420 if (lyxrc.language_global_options)
1421 return lang_pack;
1422 }
1423 return lang_pack;
The if() of line 1418 leads to change lang_pack, and the value is
returned in line 1423. On the contrary, the if() of line 1420 directly
returns a value. That is what I mean by weird.
So I would be very pleased if you could test my lang2.diff patch and
tell me what does not work.
Uwe> As you know know the problematic, do you perhaps have an idea how
Uwe> to fix bug 3571?: When the document language uses an empty babel
Uwe> language, \selectlanguage may not be used.
I depends: what is the latex output you'd like to have? The best is to
ask a CJK user what we want to obtain, and then see how to implement
it.
JMarc