Skip to content

Add option to disable the platform locale#92

Merged
sindresorhus merged 3 commits into
sindresorhus:mainfrom
jhnns:disable-locale-option
Jan 1, 2022
Merged

Add option to disable the platform locale#92
sindresorhus merged 3 commits into
sindresorhus:mainfrom
jhnns:disable-locale-option

Conversation

@jhnns
Copy link
Copy Markdown
Contributor

@jhnns jhnns commented Dec 19, 2021

Comment thread index.js
input = preserveConsecutiveUppercase(input, toLowerCase);
} else {
input = input.toLocaleLowerCase();
input = toLowerCase(input);
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I think this fixes a bug "by accident" where the locale hasn't been applied previously.

Comment thread test.js
Object.defineProperty(String.prototype, 'toLocaleLowerCase', toLocaleLowerCase);
}
};
/* eslint-enable no-extend-native */
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I tried to separate this mocking setup from the rest of the test. I'm not sure if you agree with this style of mocking String.prototype functions. Another solution would be to spin up a separate Node process with tr-TR as locale but I thought that would be a bigger change.

Comment thread readme.md Outdated
//=> 'loremİpsum'

camelCase('lorem-ipsum', {locale: false}); // ignore platform locale
//=> 'loremIpsum'
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

I don't think these additions are needed. It's enough to document it at the API docs for the option.

@sindresorhus
Copy link
Copy Markdown
Owner

You also need to update index.d.ts

@jhnns
Copy link
Copy Markdown
Contributor Author

jhnns commented Dec 20, 2021

I've updated the PR, ready to be reviewed again :)

@sindresorhus sindresorhus merged commit 65ccea6 into sindresorhus:main Jan 1, 2022
@jhnns jhnns deleted the disable-locale-option branch January 10, 2022 10:11
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