Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Spurious spaces in English when French is the main language #66

Closed
dflipo opened this issue Dec 13, 2013 · 13 comments
Closed

Spurious spaces in English when French is the main language #66

dflipo opened this issue Dec 13, 2013 · 13 comments

Comments

@dflipo
Copy link

dflipo commented Dec 13, 2013

Switching locally to English with \textenglish doesn't stop polyglossia to add spaces in front of ':' ';' '!' and '?' as shown in the following example:

%%%%%%%%%%%%%%%%%
\documentclass[12pt]{article}
\usepackage{fontspec}
\usepackage{polyglossia}
\setmainlanguage{french}
\setotherlanguage{english}
\begin{document}
\showoutput
Texte en français: ça marche? oui! \textenglish{english: ok? no!}
\end{document}
%%%%%%%%%%%%%%%%%%%%

@eg9
Copy link
Contributor

eg9 commented Dec 26, 2013

\textenglish uses \foreignlanguage, which is equivalent to using otherlanguage*, that doesn't change the “orthographic” conventions. It's mostly for single words or phrases, without punctuation. For bigger chunks use the otherlanguage environment.

@hugoroy
Copy link
Contributor

hugoroy commented Nov 13, 2015

According to the manual, \textenglish should be used for short insertions of text. So why shouldn't this work?

I can reproduce the problem.

@jspitz
Copy link
Collaborator

jspitz commented Aug 20, 2019

The cause is the same as for #169: \french@punctuation remains in effect if another language is nested into french (as main language or secondary language).

Probably the only solution is to define \nofrench@punctuation in the style file and issue it at the very beginning of any language switch. But then, other languages might have similar hooks that need to be taken care of.

@jspitz
Copy link
Collaborator

jspitz commented Aug 20, 2019

Having written this, a better solution seems to me to add a hook that is inserted at the beginning of a language switch (say, \AtBeginOtherLanguage), and then do in gloss-french: \AtBeginOtherLanguage{\nofrench@punctuation}

This seems to be a fairly generalizable solution for similar cases.

PS. I saw that there is already a hook \xpg@hook@setlanguage, but it seems to be reserved for external packages, and it also needs to be always redefined, so if external packages redefine this, we're lost. I'd suggest something along the line of:

\newcommand*{\xpg@hookii@setlanguage}{}
\newcommand\AtBeginOtherLanguage{\g@addto@macro\xpg@hookii@setlanguage}

@wehro
Copy link
Contributor

wehro commented Aug 20, 2019

As an alternative, the following way could be chosen:
The French language module of polyglossia could check every time when a relevant punctuation mark or guillemet occurs, whether the current language is French or not. The space would only be inserted, if the language is French. For XeLaTeX, this would be easy as the current language is stored in \languagename.
For LuaLaTeX, the Lua variable polyglossia.current_language might be used, but #234 needs a fix first.

@jspitz
Copy link
Collaborator

jspitz commented Aug 20, 2019

The alternative does not fix the general issue though: temporarily disable all language specific settings when a nested language is entered.

@jspitz
Copy link
Collaborator

jspitz commented Aug 22, 2019

The fix seems easier than I thought. I'll di a PR in a minute.

@reutenauer
Copy link
Owner

Fixed by #235.

@ivankokan
Copy link
Contributor

ivankokan commented Aug 22, 2019

Hi everyone, I would like to ask few questions about the general principles when switching languages:

  • Should \text<lang> and \begin{<lang>} be equivalent or not?
  • Assuming that \text<lang> activates some local language-specific rules, how can one ensure those rules are reverted afterwards? I guess various extras are to be used for this purpose.
  • Can someone document these extras: init@extras@<lang>, init@noextras@<lang>, noextras@<lang>, inlineextras@<lang>, blockextras@<lang>?

Kind regards, Ivan

@jspitz
Copy link
Collaborator

jspitz commented Aug 22, 2019 via email

@jspitz
Copy link
Collaborator

jspitz commented Aug 22, 2019

* Should `\text<lang>` and `\begin{<lang>}` be equivalent or not?

The (rather sparse) documentation indicates so. But it isn't:

  • \text<lang> does not change the captions, but it does change \today
  • \begin{<lang>} changes the captions and \today

As to the babel commands:

  • \foreignlanguage and the starred otherlanguage* environment behave like \text<lang>, but in babel, \today is not changed!
  • \selectlanguage and the unstarred otherlanguage environment behave like \begin{<lang>}, which is OK.

The change of \extras in all commands is in line with babel.

I think at least the behavior of \foreignlanguage and the starred otherlanguage environment should be fixed, and the documentation elaborated. But this should go to a separate ticket.

@bastien-roucaries
Copy link
Collaborator

bastien-roucaries commented Aug 22, 2019 via email

@jspitz
Copy link
Collaborator

jspitz commented Aug 22, 2019

The issue discussed as of #66 (comment) is now #239.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants