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

Case conversion with specific locale #72

Closed
vozzen opened this issue Jul 18, 2020 · 3 comments · Fixed by #75
Closed

Case conversion with specific locale #72

vozzen opened this issue Jul 18, 2020 · 3 comments · Fixed by #75

Comments

@vozzen
Copy link
Contributor

vozzen commented Jul 18, 2020

Case conversion are done with String.prototype.toLocaleLowerCase() and String.prototype.toLocaleUpperCase() without explicit locale parameter and this causes host dependent output.
Example:

camelCase('lorem-ipsum')
//=> 'loremIpsum' if host locale is en-US
//=> 'loremİpsum' if host locale is tr-TR

This causes unexpected results int hosts with non en-US environment.

I'd suggest to extend options parameter to have a locale property to be passed to aforementioned methods.

camelCase('lorem-ipsum', {locale: 'en-US'});
//=> 'loremIpsum' if host locale is en-US
//=> 'loremIpsum' if host locale is tr-TR
@selimrecep
Copy link

selimrecep commented Jul 18, 2020

I am experiencing same issue too. Just because of this error, I couldn't get Jest work without workarounds.

i => İ
ı => I
(Lower => Upper s in Turkish)

selimrecep added a commit to selimrecep/camelcase that referenced this issue Jul 18, 2020
I have added optional 'locale' option to `options`
@selimrecep
Copy link

selimrecep commented Jul 18, 2020

I have created PR. I think that will fix it.

@vozzen
Copy link
Contributor Author

vozzen commented Jul 18, 2020

@selimrecep Sorry, in parallel I've also submitted a PR. Any of them is fine :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants