# `Unicode.Transform.Loader`
[🔗](https://github.com/elixir-unicode/unicode_transform/blob/v1.1.0/lib/unicode/transform/loader.ex#L1)

Loads CLDR transform definitions from XML files.

Uses SweetXml to parse the XML and extract the transform
metadata and rule text.

# `build_alias_index`

```elixir
@spec build_alias_index() :: map()
```

Builds the alias index from all transform XML files and stores
it in a `persistent_term`. Called at application startup to
avoid lazy initialization on the first transform call.

### Returns

The alias index map.

# `find_transform`

```elixir
@spec find_transform(String.t()) :: {Path.t(), :forward | :backward} | nil
```

Finds the XML file path and direction for a given transform ID.

Resolves transform names by checking:

1. Exact filename match (e.g., `"Latin-ASCII"` → `"priv/transforms/Latin-ASCII.xml"`).

2. Forward alias match from XML metadata.

3. Backward alias match from XML metadata.

4. Reverse direction lookup (e.g., `"ConjoiningJamo-Latin"` found via
   `"Latin-ConjoiningJamo.xml"` with `direction="both"`).

5. BCP47 (ISO 15924) script code resolution (e.g., `"Grek-Latn"` →
   `"Greek-Latin"`).

### Arguments

* `transform_id` — the transform name to resolve.

### Returns

* `{file_path, :forward}` — use the file's rules in forward direction.

* `{file_path, :backward}` — use the file's rules in backward/reverse direction.

* `nil` — no matching transform found.

# `list_transforms`

```elixir
@spec list_transforms() :: [Path.t()]
```

Lists all available transform XML files.

### Returns

A list of file paths to transform XML files.

# `load_file`

```elixir
@spec load_file(Path.t()) :: map()
```

Loads a transform definition from an XML file.

### Arguments

* `file_path` — path to the XML file.

### Returns

A map with the following keys:

* `:source` — source script/locale.

* `:target` — target script/locale.

* `:direction` — `"forward"`, `"backward"`, or `"both"`.

* `:alias` — transform alias string.

* `:backward_alias` — backward transform alias string.

* `:rules` — the raw rule text string.

# `transform_id`

```elixir
@spec transform_id(String.t(), String.t()) :: String.t()
```

Derives a transform ID from source and target.

### Arguments

* `source` — the source script name.

* `target` — the target script name.

### Returns

A string like `"Latin-ASCII"` or `"Greek-Latin"`.

# `transform_id_from_file`

```elixir
@spec transform_id_from_file(Path.t()) :: String.t()
```

Derives a transform ID from a filename.

### Arguments

* `file_path` — the path to the XML file.

### Returns

A string transform ID derived from the filename.

# `transforms_dir`

```elixir
@spec transforms_dir() :: Path.t()
```

Returns the default transforms directory path.

### Returns

The path to the transforms directory.

---

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