# localeSelect

## Purpose

Creates a select to select from a list of available locales

## Examples

    // create a locale select
    <g:localeSelect name="myLocale" value="${locale}" />

## Description

Attributes

- `name` - The name to be used for the select box
- `value` (optional) - The set locale, defaults to the current request locale if not specified

## Source

Show Source

    def localeSelect = { attrs ->
            attrs.from = Locale.getAvailableLocales()
            attrs.value = (attrs.value ?: RCU.getLocale(request))?.toString()
            // set the key as a closure that formats the locale
            attrs.optionKey = { it.country ? "${it.language}_${it.country}" : it.language }
            // set the option value as a closure that formats the locale for display
            attrs.optionValue = {it.country ? "${it.language}, ${it.country},  ${it.displayName}" : "${it.language}, ${it.displayName}" }        // use generic select
            out << select(attrs)
        }