# locale-utils **Repository Path**: mirrors_mapbox/locale-utils ## Basic Information - **Project Name**: locale-utils - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-08-09 - **Last Updated**: 2025-11-29 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ## Locale Utils A helper library for finding an appropriate locale from a list of available locales given an input locale. [![Build Status](https://travis-ci.org/mapbox/locale-utils.svg?branch=master)](https://travis-ci.org/mapbox/locale-utils) ### Installation ``` npm install @mapbox/locale-utils --save ``` ### Usage ```js var locale = require('@mapbox/locale-utils'); var availableLocales = [ 'en-US', 'en-GB', 'es-ES', 'pt-PT', 'tr', 'zh-Hans' ]; // Find the best fitting locale given an input locale var newLocale = locale.bestMatchingLocale('es-MX', availableLocales); // Returns `es-ES` since `es-MX` is not an available locale. // Parse a locale into smaller, easier to understand pieces. var codedLocale = locale.parseLocaleIntoCodes('es-MX'); // Returns: // { // locale: 'es-MX', // language: 'es', // script: undefined, // region: 'MX' // } ```