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

Transform with Culture via ICulturedStringTransformer #1063

Merged
merged 2 commits into from
May 5, 2021

Conversation

dahlbyk
Copy link
Contributor

@dahlbyk dahlbyk commented May 3, 2021

As proposed in #1061 (comment):

  1. Adds support for input.Transform(culture, transformers)
  2. Adds ICulturedStringTransformer : IStringTransformer
    string Transform(string input, CultureInfo culture);
    • New interface avoids a breaking change, but I think it's worth considering just updating IStringTransformer.Transform() to accept culture. Trivial for custom implementations to be updated with the new parameter, since they can just ignore culture if they don't care.
  3. Updates To.LowerCase and such to return ICulturedStringTransformer (shouldn't be a breaking change, since it's assignable to IStringTransformer, with internal classes updated to implement the new overload.

Checklist

Here is a checklist you should tick through before submitting a pull request:

  • Implementation is clean
  • Code adheres to the existing coding standards; e.g. no curlies for one-line blocks, no redundant empty lines between methods or code blocks, spaces rather than tabs, etc.
  • No Code Analysis warnings
  • There is proper unit test coverage
    • Haven't figured out how to test, as I don't know a language with upper/lower rules different from English.
  • If the code is copied from StackOverflow (or a blog or OSS) full disclosure is included. That includes required license files and/or file headers explaining where the code came from with proper attribution
  • There are very few or no comments (because comments shouldn't be needed if you write clean code)
  • Xml documentation is added/updated for the addition/change
  • Your PR is (re)based on top of the latest commits from the dev branch (more info below)
  • Link to the issue(s) you're fixing from your PR description. Use fixes #<the issue number>
  • Readme is updated if you change an existing feature or add a new one
  • Run either build.cmd or build.ps1 and ensure there are no test failures

@dahlbyk
Copy link
Contributor Author

dahlbyk commented May 3, 2021

Just noticed ApplyCase(LetterCasing) and Humanize(LetterCasing). Could reasonably update any/all to provide overloads that accept CultureInfo, too.

@dahlbyk dahlbyk force-pushed the ICulturedStringTransformer branch from 3e23bb4 to f8e2df8 Compare May 5, 2021 19:19
@dahlbyk dahlbyk marked this pull request as ready for review May 5, 2021 19:21
@dahlbyk
Copy link
Contributor Author

dahlbyk commented May 5, 2021

Rebased onto main. Thoughts?

@clairernovotny clairernovotny merged commit d602902 into Humanizr:main May 5, 2021
@dahlbyk dahlbyk deleted the ICulturedStringTransformer branch May 5, 2021 20:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants