# `Localize.Collation.Tailoring`
[🔗](https://github.com/elixir-localize/localize/blob/v0.39.0/lib/localize/collation/tailoring.ex#L1)

CLDR locale-specific collation tailoring.

Parses and applies CLDR tailoring rules that modify the root collation order
for specific locales. Rules use the ICU/CLDR syntax defined in UTS #35:

* `&X` - reset position to after character X.

* `&[before N]X` - reset to just before X at level N.

* `<` - primary difference (new letter).

* `<<` - secondary difference (accent variant).

* `<<<` - tertiary difference (case variant).

* `[caseFirst upper]` - option overrides.

Tailoring data is embedded directly from CLDR XML sources, covering common
European and Asian locales.

# `get_tailoring`

```elixir
@spec get_tailoring(String.t(), atom()) :: {map(), keyword()} | nil
```

Get a tailoring overlay for the given locale and collation type.

### Arguments

* `language` - ISO 639 language code (e.g., `"sv"`, `"de"`, `"es"`).

* `type` - collation type atom (e.g., `:standard`, `:phonebook`, `:traditional`).

### Returns

* `{overlay, option_overrides}` - a map of overlay entries and a keyword list of option overrides.

* `nil` - if no tailoring exists for the given locale and type.

# `parse_rules`

```elixir
@spec parse_rules(String.t()) :: [tuple()]
```

Parse a CLDR tailoring rule string into a list of operations.

### Arguments

* `rules_str` - a CLDR/ICU tailoring rule string.

### Returns

A list of operation tuples.

### Examples

    iex> ops = Localize.Collation.Tailoring.parse_rules("&N<ñ<<<Ñ")
    iex> length(ops)
    3

# `supported_locales`

```elixir
@spec supported_locales() :: [{String.t(), atom()}]
```

List all supported locale/type combinations.

### Returns

A list of `{language, type}` tuples.

### Examples

    iex> locales = Localize.Collation.Tailoring.supported_locales()
    iex> {"es", :standard} in locales
    true

---

*Consult [api-reference.md](api-reference.md) for complete listing*
