mike-fabian / ibus-typing-booster

ibus-typing-booster is a completion input method for faster typing
https://mike-fabian.github.io/ibus-typing-booster/
Other
226 stars 15 forks source link

[ENHANCEMENT] improve handling of punctuation marks when writing (non-Canadian) French #480

Closed mike-fabian closed 7 months ago

mike-fabian commented 7 months ago

https://lingoculture.com/blog/grammar/french-punctuation-marks/

French punctuation marks and the mysterious extra spaces

The most noticeable difference between French and English punctuation is the mysterious French space before two-part punctuation marks. This rule does not apply to Canadian French.

All punctuation marks composed of two or more parts require a space before and after in French: question mark, exclamation mark, semicolon, colon, French quotation marks, percentage mark, hash mark, and currency symbols:

? ! ; : % # « » € $ ¢ £ ¥ ฿

All of these symbols have multiple parts to them and can be referred to as double punctuation marks.

Comment ça va ?  – How are you?

« Ce n’est pas possible ! » – “That’s impossible!”

In old-school French grammar, the space between the two-part punctuation marks is called une éspace insécable, or a non-breaking space. It is a space character that prevents an automatic line break at its position. It is there to avoid an isolated word or punctuation mark on the next line which could impact the fluidity of reading.

A likely reason for French punctuation requiring an extra space dates to the use of typewriters. The punctuation symbols that require extra spaces in French were typed by superimposing two to three symbols on top of each other. A comma on top of a colon created a semi-colon and would require the typewriter carriage to create a space before and after. This theory has holes in it, as English and French-Canadian punctuation dropped the extra spaces after the use of the typewriter became effectively obsolete, but the rule still exists in the French language.

mike-fabian commented 7 months ago

Current handling of punctuation makes this difficult, for example when typing test ! ibus-typing-booster “fixes” this to test! (if surrounding text is supported). That is nice when writing English or German but makes it more difficult to achieve the correct use of spaces and two-part punctuation marks when writing (French)-French.

This should be improved.

An idea would be to change the handling of these punctuation marks depending on which dictionary has highest priority, if the fr_FR dictionary has highest priority, then try to help achieving the French way of writing this by not removing the space between test and ! but replacing it with U+00A0 NO-BREAK SPACE.

mike-fabian commented 7 months ago

In the context of French punctuation, both can be used, but U+00A0 is more common and widely accepted. However, some modern style guides may recommend using U+202F for a more subtle and aesthetically pleasing space.

mike-fabian commented 7 months ago

Although this French way of doing punctuation is not used in Canada, it is probably used in

But probably not in Switzerland.

mike-fabian commented 7 months ago

I improved this to use the (French) French way of putting a space between a word and a two piece punctuation mark like ! or ? if:

  ((At least one of the dictionaries 'fr_FR', 'fr_MC', 'fr_BE', 'fr_LU' is used)
    and
    ((one of these 4 variants of French dictionaries has highest priority)
     or
     (all of the last 3 words can be found in one single of these 4 variants of French dictionaries))

If that condition is met, do not remove the whitespace between ! and the last word but replace it with a   U+202F NARROW NO-BREAK SPACE.

https://github.com/mike-fabian/ibus-typing-booster/assets/2330175/09085581-5396-41c6-9994-dcfe9e1e9ce1