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

Title Case #299

Closed
grumpyTofu opened this issue Oct 21, 2021 · 6 comments
Closed

Title Case #299

grumpyTofu opened this issue Oct 21, 2021 · 6 comments
Labels
help wanted Extra attention is needed type addition

Comments

@grumpyTofu
Copy link

grumpyTofu commented Oct 21, 2021

Would you be open to a PR for Title Case?

Ex.

  • fooBar -> Foo Bar
  • foo-bar -> Foo Bar
  • bar_baz -> Bar Baz

Upvote & Fund

  • We're using Polar.sh so you can upvote and help fund this issue.
  • The funding will be given to active contributors.
  • Thank you in advance for helping prioritize & fund our backlog.
Fund with Polar
@sindresorhus
Copy link
Owner

What's the use-case? The other transformations makes sense for various API conventions, but no APIs use title case AFAIK.

@grumpyTofu
Copy link
Author

The use case transforming other formats into title case for data display. For example, Material-UI data grid requires formatting for the column definition:

interface CustomGridColDef extends GridColDef {
  field: CustomObjectProps;
  headerName: TitleCase<CustomObjectProps>;
}

const columns: CustomGridColDef[] = [
  { field: "id", headerName: "Id", flex: 1, minWidth: 150, hide: true },
  { field: "name", headerName: "Name", flex: 1, minWidth: 150 },
  { field: "customProperty", headerName: "Custom Property", flex: 1, minWidth: 150 }
];

Doing something like the above would force the display text to be equivalent to whatever your API returns, but in title case.

@sindresorhus
Copy link
Owner

sindresorhus commented Oct 27, 2021

The problem is that "title case" has many variations. It seems like you just want every word to be capitalized, correct? Because "title case" can also mean special rules, like head of animal => Head of Animal (note lowercase of).

https://apastyle.apa.org/style-grammar-guidelines/capitalization/title-case

So I think we can add this (just capitalize every word), but it probably needs a better name. (Suggestions welcome)

@sindresorhus sindresorhus added help wanted Extra attention is needed type addition labels Oct 27, 2021
@bisubus
Copy link

bisubus commented Oct 27, 2021

Always considered it "song case" because musicians don't care about publishing guidelines. But "title case" is consistent with https://github.com/sindresorhus/titleize

@sindresorhus
Copy link
Owner

sindresorhus commented Oct 27, 2021

But "title case" is consistent with sindresorhus/titleize

Nowhere there does it say "title case". Titleize is a different word.

@grumpyTofu
Copy link
Author

grumpyTofu commented Oct 28, 2021

I think many people call it many different things. If you would like to stick with APA guidelines we can go that route and provide a true "TitleCase" by splitting up the strings and then skipping capitalization on the strings that do not match the APA guidelines.

Just to add to the confusion Ruby on Rails calls it "Titleize", but then also aliased it with "TitleCase".

@sindresorhus: I wasn't initially sure how difficult it would be to build in the logic to account for english grammar... but I actually just got a working example together for it. However, I kind of like both and I was thinking I could just put both of them in the PR as "TitleCase" and "Titleize"; TitleCase matching the APA guidelines and Titleize being equivalent to capitalizing every letter. This way you could pick and choose which format you like for data display. If you agree, I can put a PR soon. If not, let me know how you would like for me to move forward!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed type addition
Projects
None yet
Development

No branches or pull requests

3 participants