Install via yarn add locutus and import:
import { i18n_loc_get_default } from 'locutus/php/i18n/i18n_loc_get_default'.
Or with CommonJS: const { i18n_loc_get_default } = require('locutus/php/i18n/i18n_loc_get_default')
Use a bundler that supports tree-shaking so you only ship the functions you actually use.
Vite,
webpack,
Rollup, and
Parcel
all handle this. For server-side use this is less of a concern.
Examples
These examples are extracted from test cases that automatically verify our functions against their native counterparts.
exportfunctioni18n_loc_get_default(): string { // discuss at: https://locutus.io/php/i18n_loc_get_default/ // original by: Brett Zamir (https://brett-zamir.me) // note 1: Renamed in PHP6 from locale_get_default(). Not listed yet at php.net. // note 1: List of locales at <https://demo.icu-project.org/icu-bin/locexp> // note 1: To be usable with sort() if it is passed the `SORT_LOCALE_STRING` // note 1: sorting flag: https://php.net/manual/en/function.sort.php // example 1: i18n_loc_get_default() // returns 1: 'en_US_POSIX' // example 2: i18n_loc_set_default('pt_PT') // example 2: i18n_loc_get_default() // returns 2: 'pt_PT'
exportfunctioni18n_loc_get_default() { // discuss at: https://locutus.io/php/i18n_loc_get_default/ // original by: Brett Zamir (https://brett-zamir.me) // note 1: Renamed in PHP6 from locale_get_default(). Not listed yet at php.net. // note 1: List of locales at <https://demo.icu-project.org/icu-bin/locexp> // note 1: To be usable with sort() if it is passed the `SORT_LOCALE_STRING` // note 1: sorting flag: https://php.net/manual/en/function.sort.php // example 1: i18n_loc_get_default() // returns 1: 'en_US_POSIX' // example 2: i18n_loc_set_default('pt_PT') // example 2: i18n_loc_get_default() // returns 2: 'pt_PT'
return { ini, locales, localeCategories, pointers, locale_default: localeDefault, } }
// php/i18n/i18n_loc_get_default (target function module) functioni18n_loc_get_default(): string { // discuss at: https://locutus.io/php/i18n_loc_get_default/ // original by: Brett Zamir (https://brett-zamir.me) // note 1: Renamed in PHP6 from locale_get_default(). Not listed yet at php.net. // note 1: List of locales at <https://demo.icu-project.org/icu-bin/locexp> // note 1: To be usable with sort() if it is passed the `SORT_LOCALE_STRING` // note 1: sorting flag: https://php.net/manual/en/function.sort.php // example 1: i18n_loc_get_default() // returns 1: 'en_US_POSIX' // example 2: i18n_loc_set_default('pt_PT') // example 2: i18n_loc_get_default() // returns 2: 'pt_PT'
return { ini, locales, localeCategories, pointers, locale_default: localeDefault, } }
// php/i18n/i18n_loc_get_default (target function module) functioni18n_loc_get_default() { // discuss at: https://locutus.io/php/i18n_loc_get_default/ // original by: Brett Zamir (https://brett-zamir.me) // note 1: Renamed in PHP6 from locale_get_default(). Not listed yet at php.net. // note 1: List of locales at <https://demo.icu-project.org/icu-bin/locexp> // note 1: To be usable with sort() if it is passed the `SORT_LOCALE_STRING` // note 1: sorting flag: https://php.net/manual/en/function.sort.php // example 1: i18n_loc_get_default() // returns 1: 'en_US_POSIX' // example 2: i18n_loc_set_default('pt_PT') // example 2: i18n_loc_get_default() // returns 2: 'pt_PT'
Locutus is a community effort following
The McDonald's Theory:
we ship first iterations, hoping others will improve them.
If you see something that could be better, we'd love your contribution.