str.title() fails with words containing apostrophes

Steve D'Aprano steve+python at pearwood.info
Mon Mar 6 18:33:21 EST 2017


On Tue, 7 Mar 2017 01:03 am, Marko Rauhamaa wrote:

> Chris Angelico <rosuav at gmail.com>:
> 
>> Right. If you want true title casing, it has to be *extremely*
>> linguistically-aware.
> 
> For instance, title case has no meaning in the context of Finnish. In
> other words, your internationalized program shouldn't even think of
> title case when localized in Finnish.

If you read "title case" as *literally* as being only for titles (of books,
for instance) then of course you are right. Finnish book titles are
normally written in sentence case (initial capital, followed by all
lowercase).

But if you consider title case more widely, Finnish includes it too. Names
are written in title case ("Marko Rauhamaa" rather than "Marko rauhamaa").
I imagine countries get the same treatment when needed. How do you write
Saudi Arabia, United Kingdom, and North Korea?

I came across this book title:

Täällä Pohjantähden alla (‘Here beneath the North Star’)

http://www.booksfromfinland.fi/1980/12/the-strike/

which is partly title case, but I'm not sure what rule is being applied
there. My guess is that "Täällä Pohjantähden" means "North Star" and it
counts as a proper noun, like countries and people's names, and so takes
initial caps for each word. Am I close?



-- 
Steve
“Cheer up,” they said, “things could be worse.” So I cheered up, and sure
enough, things got worse.



More information about the Python-list mailing list