### Installing locale-codes package Source: https://github.com/tiagodanin/locale-codes/blob/master/README.md Install the locale-codes library from the npm registry using either Yarn (recommended) or npm package managers to add it as a project dependency. ```sh yarn add locale-codes ``` ```sh npm install locale-codes --save ``` -------------------------------- ### Getting All Locales - JavaScript Source: https://github.com/tiagodanin/locale-codes/blob/master/documentation.md Accesses the `locale.all` property or method to retrieve a collection containing information for all supported locales. ```JavaScript locale.all ``` -------------------------------- ### Running Project Tests Shell Source: https://github.com/tiagodanin/locale-codes/blob/master/README.md This snippet provides the command to execute the project's test suite. It requires Yarn to be installed as a dependency. Running this command will execute all tests defined for the project. ```sh yarn test ``` -------------------------------- ### Getting Locale by ISO 639-1 - JavaScript Source: https://github.com/tiagodanin/locale-codes/blob/master/documentation.md Provides a shortcut function `getByISO6391` to retrieve locale information by its ISO 639-1 code. This internally calls `locale.where` using the 'iso639-1' key. ```JavaScript getByISO6391(text) = where('iso639-1', text) ``` -------------------------------- ### Getting Locale by Name - JavaScript Source: https://github.com/tiagodanin/locale-codes/blob/master/documentation.md Provides a shortcut function `getByName` to retrieve locale information by its primary name. This internally calls `locale.where` using the 'name' key. ```JavaScript getByName(text) = where('name', text) ``` -------------------------------- ### Getting Locale by Local Name - JavaScript Source: https://github.com/tiagodanin/locale-codes/blob/master/documentation.md Provides a shortcut function `getByNameLocal` to retrieve locale information by its local name. This internally calls `locale.where` using the 'local' key. ```JavaScript getByNameLocal(text) = where('local', text) ``` -------------------------------- ### Getting Locale by ISO 639-2 - JavaScript Source: https://github.com/tiagodanin/locale-codes/blob/master/documentation.md Provides a shortcut function `getByISO6392` to retrieve locale information by its ISO 639-2 code. This internally calls `locale.where` using the 'iso639-2' key. ```JavaScript getByISO6392(text) = where('iso639-2', text) ``` -------------------------------- ### Getting Locale by Location - JavaScript Source: https://github.com/tiagodanin/locale-codes/blob/master/documentation.md Provides a shortcut function `getByLocation` to retrieve locale information by its associated country or location. This internally calls `locale.where` using the 'location' key. ```JavaScript getByLocation(text) = where('location', text) ``` -------------------------------- ### Getting Locale by LCID Tag - JavaScript Source: https://github.com/tiagodanin/locale-codes/blob/master/documentation.md Provides a shortcut function `getByTag` to retrieve locale information by its LCID tag string. This internally calls `locale.where` using the 'tag' key. ```JavaScript getByTag(text) = where('tag', text) ``` -------------------------------- ### Getting Locale by LCID ID - JavaScript Source: https://github.com/tiagodanin/locale-codes/blob/master/documentation.md Provides a shortcut function `getByLCID` to retrieve locale information by its numeric LCID. This internally calls `locale.where` using the 'lcid' key and the provided id. ```JavaScript getByLCID(lcid) = where('lcid', id) ``` -------------------------------- ### Using locale-codes in JavaScript Source: https://github.com/tiagodanin/locale-codes/blob/master/README.md Demonstrates how to import the locale-codes library using `require` and perform basic operations like accessing all available locales and querying specific locales by tag or using the generic `where` method. ```javascript /* eslint-disable no-unused-expressions */ const locale = require('locale-codes') locale.all // [language: '...'] locale.getByTag('pt-br').name // 'Portuguese' locale.where('tag', 'pt-br').name // 'Portuguese' ``` -------------------------------- ### Using locale-codes in TypeScript Source: https://github.com/tiagodanin/locale-codes/blob/master/README.md Illustrates how to import the locale-codes library using `import * as` and use its functionalities, including accessing all locales and querying by tag or with the `where` method. Shows type annotation for locale objects. ```typescript /* eslint-disable @typescript-eslint/no-unused-expressions, @typescript-eslint/no-unused-vars */ import * as locale from 'locale-codes' import {ILocale} from '.' locale.all // [language: '...'] const localeSelect: ILocale = locale.all[0] locale.getByTag('pt-br').name // 'Portuguese' locale.where('tag', 'pt-br').name // 'Portuguese' ``` -------------------------------- ### Querying Locales with where - JavaScript Source: https://github.com/tiagodanin/locale-codes/blob/master/documentation.md Uses the `locale.where` method to find locale entries by matching a specified `key` (e.g., 'name', 'tag') against a `text` or `id` value. Requires the key and the value to search for. ```JavaScript locale.where(key, text) ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.