# info > LOCALE

---
type: CommandReference
command: locale
mode: man
section: 1,3perl,5,7
source: man-pages
---

## Quick Reference
- `locale` — display current locale settings
- `locale -a` — list all available locales
- `locale -m` — list available charmaps
- `locale -k keyword` — display keyword value with name
- `locale -c category` — show category name before values
- `locale -v` — verbose output
- `locale -?` — help
- `locale -V` — version

## Name
locale - get locale-specific information, locale definition file format, and multilanguage support

## Synopsis
shell
locale [option]
locale [option] -a
locale [option] -m
locale [option] name...
## Options
- `-a, --all-locales` — display list of available locales; with `-v` includes LC_IDENTIFICATION metadata
- `-m, --charmaps` — display available charmaps (character set description files)
- `-c, --category-name` — for a category argument, write category name on separate line; for a keyword, write category name before keyword value
- `-k, --keyword-name` — include keyword name in output format `keyword="value"`
- `-v, --verbose` — additional information for some options
- `-?, --help` — display summary and exit
- `--usage` — short usage message and exit
- `-V, --version` — display program version and exit

## Locale Categories
A locale defines language and cultural rules. The following categories are available:

- `LC_ADDRESS` — formats for addresses and geography (GNU extension)
- `LC_COLLATE` — collation rules for sorting and regular expressions
- `LC_CTYPE` — character classification, case conversion, multibyte handling
- `LC_IDENTIFICATION` — metadata about the locale (GNU extension)
- `LC_MEASUREMENT` — measurement system (metric/US customary) (GNU extension)
- `LC_MESSAGES` — language for messages, yes/no expressions
- `LC_MONETARY` — formatting of monetary values
- `LC_NAME` — name formats and salutations (GNU extension)
- `LC_NUMERIC` — formatting of nonmonetary numeric values
- `LC_PAPER` — standard paper size (GNU extension)
- `LC_TELEPHONE` — telephone number formats (GNU extension)
- `LC_TIME` — date and time formatting
- `LC_ALL` — all categories

The locale is determined by the first non-null environment variable among `LC_ALL`, the specific category variable, and `LANG`. The `LOCPATH` variable can specify alternate paths for locale data.

## Locale Definition File (locale(5))
The locale definition file (used by `localedef(1)`) consists of sections for each category. Key syntax elements:

- `escape_char` — default `\` (backslash)
- `comment_char` — default `#` (number sign)
- `copy "locale"` — copy an existing locale definition

Category-specific keywords (partial list):

- **LC_CTYPE**: `upper`, `lower`, `alpha`, `digit`, `space`, `cntrl`, `punct`, `graph`, `print`, `xdigit`, `blank`, `charclass`, `toupper`, `tolower`, `map totitle`, `outdigit`, `translit_start`/`translit_end`
- **LC_COLLATE**: `coll_weight_max`, `collating-element`, `collating-symbol`, `order_start`/`order_end`, `reorder-after`/`reorder-end`, `reorder-sections-after`/`reorder-sections-end`, `script`
- **LC_MESSAGES**: `yesexpr`, `noexpr`, `yesstr`, `nostr`
- **LC_MONETARY**: `int_curr_symbol`, `currency_symbol`, `mon_decimal_point`, `mon_thousands_sep`, `mon_grouping`, `positive_sign`, `negative_sign`, `int_frac_digits`, `frac_digits`, `p_cs_precedes`, `p_sep_by_space`, `n_cs_precedes`, `n_sep_by_space`, `p_sign_posn`, `n_sign_posn`, and international variants
- **LC_NUMERIC**: `decimal_point`, `thousands_sep`, `grouping`
- **LC_TIME**: `abday`, `day`, `abmon`, `mon`, `d_t_fmt`, `d_fmt`, `t_fmt`, `am_pm`, `t_fmt_ampm`, `era`, `era_d_fmt`, `era_t_fmt`, `era_d_t_fmt`, `alt_digits`, `week`, `first_weekday`, `first_workday`, `cal_direction`, `date_fmt`
- **LC_ADDRESS**: `postal_fmt`, `country_name`, `country_post`, `country_ab2`, `country_ab3`, `country_num`, `country_car`, `country_isbn`, `lang_name`, `lang_ab`, `lang_term`, `lang_lib`
- **LC_IDENTIFICATION**: `title`, `source`, `address`, `contact`, `email`, `language`, `territory`, `audience`, `application`, `abbreviation`, `revision`, `date`, `category`
- **LC_MEASUREMENT**: `measurement` (1 = metric, 2 = US customary)
- **LC_NAME**: `name_fmt`, `name_gen`, `name_mr`, `name_mrs`, `name_miss`, `name_ms`
- **LC_PAPER**: `height`, `width`
- **LC_TELEPHONE**: `tel_int_fmt`, `tel_dom_fmt`, `int_select`, `int_prefix`

## Examples
shell
# Display current locale settings
locale

# Display a specific keyword value
locale date_fmt

# Display keyword with name
locale -k date_fmt

# Display category and keyword
locale -ck date_fmt

# Display all values for a category
locale LC_TELEPHONE

# Display all keywords in a category
locale -k LC_TELEPHONE

# List all available locales
locale -a

# List available charmaps
locale -m

# Compile a custom locale and test
mkdir -p $HOME/.locale
I18NPATH=./wrk/ localedef -f UTF-8 -i fi_SE $HOME/.locale/fi_SE.UTF-8
LOCPATH=$HOME/.locale LC_ALL=fi_SE.UTF-8 date
echo "export LOCPATH=\$HOME/.locale" >> $HOME/.bashrc
echo "export LANG=fi_SE.UTF-8" >> $HOME/.bashrc
## Perl Locale Pragmatics (locale(3perl))
The `use locale` pragma enables POSIX locale support for built-in operations (regular expressions, string comparison, number formatting). Use within a block to scope the effect.

perl
use locale;
@x = sort @y;  # Locale-defined sort order
no locale;
**WARNING**: Do not use in multithreaded scripts; locales are not thread-safe.

## See Also
- [localedef(1)](https://www.chedong.com/phpMan.php/man/localedef/1/markdown)
- [charmap(5)](https://www.chedong.com/phpMan.php/man/charmap/5/markdown)
- [localeconv(3)](https://www.chedong.com/phpMan.php/man/localeconv/3/markdown)
- [newlocale(3)](https://www.chedong.com/phpMan.php/man/newlocale/3/markdown)
- [setlocale(3)](https://www.chedong.com/phpMan.php/man/setlocale/3/markdown)
- [strftime(3)](https://www.chedong.com/phpMan.php/man/strftime/3/markdown)
- [strptime(3)](https://www.chedong.com/phpMan.php/man/strptime/3/markdown)
- [uselocale(3)](https://www.chedong.com/phpMan.php/man/uselocale/3/markdown)
- [locale(7)](https://www.chedong.com/phpMan.php/man/locale/7/markdown)
- [charsets(7)](https://www.chedong.com/phpMan.php/man/charsets/7/markdown)
- [unicode(7)](https://www.chedong.com/phpMan.php/man/unicode/7/markdown)
- [utf-8(7)](https://www.chedong.com/phpMan.php/man/utf-8/7/markdown)