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

MC-1583:"Fix Title” for English titles not capitalizing first word after single quote or colon #1223

Merged
merged 3 commits into from
Nov 5, 2024

Conversation

katerinachinnappan
Copy link
Contributor

@katerinachinnappan katerinachinnappan commented Nov 2, 2024

Goal

Fix the capitalization rules for english titles:

  • Capitalize the word "so" (remove as a stop word)
  • Capitalize the first word (regardless if it is a stop word) after a quote: 'the day' -> 'The Day'
  • Ensure there is a difference between a quote and apostrophe: 'the day' day'S -> 'The Day' Day's
  • Capitalize word after a colon (:): 'the day' day's: day -> 'The Day' Day's: Day

Final result: Amorim aims to 'prove something' at Manchester United after agreeing deal: read the day's 'news' -> Amorim Aims to ‘Prove Something’ at Manchester United After Agreeing Deal: Read the Day’s ‘News’

Todos

  • deploy to dev

Reference

Tickets:

@katerinachinnappan katerinachinnappan requested a review from a team as a code owner November 2, 2024 12:06
Copy link
Collaborator

@jpetto jpetto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

functionally this looks great - hoping we can add some comments and targeted unit tests 😄

src/_shared/utils/applyApTitleCase.ts Show resolved Hide resolved
src/_shared/utils/applyApTitleCase.ts Show resolved Hide resolved
src/_shared/utils/applyApTitleCase.ts Show resolved Hide resolved
src/_shared/utils/applyApTitleCase.ts Outdated Show resolved Hide resolved
// Boolean here acts as a callback, evaluates each word:
// If it's a non-empty string, keep the word in the array;
// If it's an empty string (or falsy), remove from array.
const allWords = value.split(SEPARATORS).filter(Boolean); // Split and filter empty strings
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

just out of curiosity, what is the filter(Boolean) guarding against?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

filter(Boolean) removes any false values like NaN, undefined, etc

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but could those values ever appear in a split string? doesn't hurt to have it in, just wondering if you came across a case where something falsy ended up in the array. 😅

Copy link
Collaborator

@jpetto jpetto left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great work, and love the comments and tests!

@katerinachinnappan katerinachinnappan merged commit 7d4c610 into main Nov 5, 2024
6 checks passed
@katerinachinnappan katerinachinnappan deleted the katerina/MC-1583-fix-title-english branch November 5, 2024 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants