Download wp-calypso/client/state/selectors/get-current-intl-collator.js from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 601 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/selectors/get-current-intl-collator.js
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset/wp-calypso/client/state/selectors/get-current-intl-collator.js
-
curl -L -o get-current-intl-collator.js https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/main/wp-calypso/client/state/selectors/get-current-intl-collator.js
601 Bytes
| import getCurrentLocaleSlug from 'calypso/state/selectors/get-current-locale-slug'; | |
| /** | |
| * Get an Intl.Collator() for the current locale to enable localized sorting. | |
| * @param {Object} state Redux state | |
| * @returns {Object} Intl.Collator | |
| */ | |
| const getCurrentIntlCollator = ( state ) => { | |
| const currentLocaleSlug = getCurrentLocaleSlug( state ); | |
| // Backup locale in case the user's locale isn't supported | |
| const sortLocales = [ 'en' ]; | |
| if ( currentLocaleSlug ) { | |
| sortLocales.unshift( currentLocaleSlug ); | |
| } | |
| return new Intl.Collator( sortLocales ); | |
| }; | |
| export default getCurrentIntlCollator; | |