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

Add locale option #75

Merged
merged 16 commits into from Oct 10, 2020
Merged

Add locale option #75

merged 16 commits into from Oct 10, 2020

Conversation

rasgele
Copy link
Contributor

@rasgele rasgele commented Jul 18, 2020

Fixes #72
Added locale property to option parameter along with tests and doc.

@Qix-
Copy link
Contributor

Qix- commented Jul 19, 2020

Very much 👍. This is the proper solution here. @sindresorhus I know your stance on adding options, but I think this is a valid exception to that rule.

@rasgele Could you potentially add tests for cases where the output differs between locales?

@rasgele
Copy link
Contributor Author

rasgele commented Jul 19, 2020

@Qix- there are such tests in test.js. Also samples in readme.md and index.d.ts.

test.js Outdated Show resolved Hide resolved
readme.md Outdated
Type: `string | string[]`\
Default: `undefined`

Locale to be used with lowercase or uppercase conversions.
Copy link
Owner

Choose a reason for hiding this comment

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

This needs to explicitly say what the expected string locale format it. (for example, what en-US refers to).

Copy link
Owner

Choose a reason for hiding this comment

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

It's also unclear why one would want to specify multiple locales and how that works.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I updated with an explicit reference to String.prototype.toLocaleUpperCase() and excerpt from that page. It explains format and usage with multiple locale.
Details (like expected format being BCP 47 etc.) seemed too much in this context, but it is up to you.

Copy link
Owner

Choose a reason for hiding this comment

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

One example in Usage and all in the API docs for locale.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

readme.md Outdated Show resolved Hide resolved
index.d.ts Outdated
//=> 'loremİpsum'

camelCase('lorem-ipsum', {locale: ['en-US', 'en-GB]});
//=> 'loremIpsum'
Copy link
Owner

Choose a reason for hiding this comment

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

The readme and index.d.ts should be fully in sync.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am a little confused about this. I interpreted your next comment as "Keep a single example in index.d.ts and move others to readme.md file", which breaks sync.

index.d.ts Show resolved Hide resolved
@sindresorhus sindresorhus changed the title Add locale option Add locale option Jul 19, 2020
@sindresorhus
Copy link
Owner

The readme and index.d.ts should be fully in sync.

The locale option description differs between the readme and index.d.ts

@rasgele
Copy link
Contributor Author

rasgele commented Aug 8, 2020

The readme and index.d.ts should be fully in sync.

The locale option description differs between the readme and index.d.ts

Fixed.


camelCase('lorem-ipsum', {locale: ['tr', 'TR', 'tr-TR']});
//=> 'loremİpsum'
```
Copy link
Owner

Choose a reason for hiding this comment

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

The readme and index.d.ts should be fully in sync.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

readme contains 4 examples and index.d.ts contains one example due to your previous comment: #75 (comment)
Do you means smth else?

Copy link
Owner

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh, ok. thanks. Done.

index.d.ts Outdated
/**
From `String.prototype.toLocaleUpperCase()`: The locale parameter indicates the locale to be used to convert to upper/lower case according to any locale-specific case mappings. If multiple locales are given in an Array, the best available locale is used. The default locale is the host environment’s current locale.

@default The host environment’s current locale
Copy link
Owner

Choose a reason for hiding this comment

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

This is incorrect syntax. @default only works with a JS value.

Copy link
Contributor Author

@rasgele rasgele Sep 24, 2020

Choose a reason for hiding this comment

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

Then I'll remove @default and append following to the description of locale parameter:
"If not provided, host environment's current locale is used".

Do you have other suggestion for such a case?

Copy link
Owner

Choose a reason for hiding this comment

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

You can just write Default: The host environment’s current locale.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

index.d.ts Outdated Show resolved Hide resolved
- Removed duplicate specification for default.
@gorkemyontem
Copy link

Hi @sindresorhus, @rasgele any progress on this PR? I'm also having problems with Jest.
Thanks!

@sindresorhus
Copy link
Owner

There's still feedback that needs to be addressed.

@rasgele
Copy link
Contributor Author

rasgele commented Sep 24, 2020

Sorry, I missed latest comments.
Now I replied and based on @sindresorhus's responses I will try to push changes quickly.

@rasgele
Copy link
Contributor Author

rasgele commented Oct 6, 2020

@sindresorhus Employed 'request a review' as a 'ping'... sounded appropriate :)

@sindresorhus sindresorhus merged commit a06c4d1 into sindresorhus:master Oct 10, 2020
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.

Case conversion with specific locale
4 participants