3 ms·
> you can convert to title case or ... for display purposes. I am skeptical if someone thinks they need to do this and how they will get it done. Eg. Looping
by asveikau 6y ago
> you can convert to title case or ... for display purposes.
I am skeptical if someone thinks they need to do this and how they will get it done.
Eg. Looping through and capitalizing the first gylph after breaking whitespace regardless of locale is not the way to go, but I guarantee you a nontrivial amount of people reading this would write exactly that if asked to solve the high level problem.
I find it annoying when software or even in some cases human typists try to enforce English language title case. Some other languages have different rules for titles and capitalization and seeing the English rules enforced out of context can be jarring.
- crazygringo 6y agoI find it amusing you are skeptical... why so distrustful? But believe me, it's quite necessary. I use the citation manager Zotero a lot. It's necessary to store all the titles of journal articles and books in sentence case (e.g. "Issues regarding the economy of France") because some publications require citations to use sentence style (remains unchanged) while others require title style ("Issues Regarding the Economy of France"). And obviously the solution cannot be naive, but is language-dependent, so that in English words like "the" or "in" don't get capitalized. And as the rules for titles are obviously language-dependent, so it goes without saying that the algorithm would have to be localized. (Note that while it's relatively trivial to convert from sentence case to title case in English, it's impossible to automate in the opposite direction, because you never know if a capitalized term in the title is a proper noun or not.)
- a1369209993 6y ago> (Note that while it's relatively trivial to convert from sentence case to title case in English[...]) Strictly speaking you can't do that either: "Latine et videtur".totitle = "Latine et Videtur" "I et some food".totitle = "I Et Some Food" I suspect that fails less often though.
- Groxx 6y agoWhile I agree it's almost always a bad idea: effectively every design team I've encountered has requested stuff like this. So yes, it's extremely common. It's done on tons of websites, for tons of mail addresses (ever receive an all-uppercase address on a delivery? same issue.), and tons and tons and tons of emails and legal documents (woe to those with last names like McCormick).
- layer8 6y ago> I am skeptical if someone thinks they need to do this and how they will get it done I most often use title case mappings in the context of replacements of names into diagnostic messages. I.e. you have n types of objects and m messages like “${foo} not found” or “More than one ${foo} required”, and perform title case mapping on ${foo} depending on whether it is at the start of the message (sentence) or not.
- dragonwriter 6y ago> I am skeptical if someone thinks they need to do this and how they will get it done. It's not an uncommon requirement, though probably not often in a locale sensitive way, so you can often get away with just doing the right thing for one locale. To do it generally, you probably need to research appropriate handling per locale (likely, what your client wants done in the particular locale, since I'm not sure there is usually just one way; I know there are multiple variations in en-US), and then have a master function that takes the text and target locale and applies the correct locale-specific title casing rules.