The built in .Net method TextInfo.ToTitleCase handles French sentences ok, but there are some samples which cause issues, see remarks (copied below):
Generally, title casing converts the first character of a word to uppercase and the rest of the characters to lowercase. However, this method does not currently provide proper casing to convert a word that is entirely uppercase, such as an acronym. The following table shows the way the method renders several strings.
Input Language Expected result Actual result war and peace English War and Peace War And Peace Per anhalter durch die Galaxis German Per Anhalter durch die Galaxis Per Anhalter Durch Die Galaxis les naufragés d'ythaq French Les Naufragés d'Ythaq Les Naufragés D'ythaq As illustrated above, the TextInfo.ToTitleCase method provides an arbitrary casing behavior which is not necessarily linguistically correct. A linguistically correct solution would require additional rules, and the current algorithm is somewhat simpler and faster. We reserve the right to make this API slower in the future.
The current implementation of the TextInfo.ToTitleCase method yields an output string that is the same length as the input string. However, this behavior is not guaranteed and could change in a future implementation.
Is there an option within the Humanizer library to Titleize with a given culture?
It would feel like a good addition to the Humanizer library but currently it's not supported.
If I were to implement title casing for French, I'd look at the javascript titlecase-french library and rewrite it in C#, following the good set of rules it defines:
The sample in
TextInfo.ToTitleCase
remarks (les naufragés d'ythaq) works as expected withtitlecase-french
: