# `GettextTranslator.Dashboard`
[🔗](https://github.com/marmend-company/gettext_translator/blob/main/lib/gettext_translator/dashboard.ex#L1)

Phoenix LiveDashboard integration for GettextTranslator.

This module provides functions to register the GettextTranslator dashboard
with your Phoenix application.

## Setup

1. Add the required dependencies to your mix.exs:

```elixir
def deps do
  [
    {:gettext_translator, "~> 0.4.5"},
    {:phoenix_live_dashboard, ">= 0.6.0"},
    {:phoenix_live_view, ">= 0.17.0"}
  ]
end
```

2. Add the GettextTranslator supervisor to your application:

```elixir
# lib/my_app/application.ex
def start(_type, _args) do
  children = [
    # ... other children
    GettextTranslator.Supervisor
  ]

  opts = [strategy: :one_for_one, name: MyApp.Supervisor]
  Supervisor.start_link(children, opts)
end
```

3. Add the dashboard page to your Phoenix router:

```elixir
# lib/my_app_web/router.ex
import Phoenix.LiveDashboard.Router

scope "/" do
  pipe_through [:browser, :admin_auth] # replace with your actual pipeline

  live_dashboard "/dashboard",
    metrics: MyAppWeb.Telemetry,
    additional_pages: GettextTranslator.Dashboard.page_config(gettext_path: "priv/gettext")
end
```

## Usage

Once set up, you can access the Gettext Translations page from your Phoenix LiveDashboard.
The dashboard allows you to:

- View all translations across all language files
- Filter translations by language, domain, and status
- Edit translations directly in the UI
- Commit changes back to PO files
- Create Git commits and PRs (if the git_cli dependency is available)

You can also continue to use the mix task for batch translation:

```
mix gettext_translator.run
```

# `ensure_dashboard_dependencies_loaded?`

Checks if the Phoenix.LiveDashboard and Phoenix.LiveView dependencies are available.

# `load_translations`

Loads translations from the given gettext path.

This must be called after the translation store is started to load the
translations into memory.

For release environments, use an absolute path:
`Application.app_dir(:my_app, "priv/gettext")`

Returns `{:ok, count}` where count is the number of translations loaded,
or `{:error, reason}` if loading failed.

# `page`

Returns the gettext dashboard page configuration.

## Options

* `:gettext_path` - Path to the gettext directory (default: "priv/gettext")
* `:application` - The OTP application name used for resolving absolute paths in releases

## Example

```elixir
# When manually constructing the dashboard pages
additional_pages = [
my_custom_page: {MyCustomPage, []},
gettext_translations: GettextTranslator.Dashboard.page(
  gettext_path: "priv/gettext",
  application: :my_app
)
]
```

# `page_config`

Returns a list of additional pages configuration for Phoenix LiveDashboard.

## Options

* `:gettext_path` - Path to the gettext directory (default: "priv/gettext")
* `:application` - The OTP application name used for resolving absolute paths in releases

## Example

```elixir
live_dashboard "/dashboard",
metrics: MyAppWeb.Telemetry,
additional_pages: GettextTranslator.Dashboard.page_config(
  gettext_path: "priv/gettext",
  application: :my_app
)
```

# `quick_test`

Helper function to quickly test the dashboard API in IEx.

This function starts the translation store, loads translations from the
given gettext path, and returns basic stats about the loaded translations.

## Example

```elixir
iex> GettextTranslator.Dashboard.quick_test("priv/gettext")
```

# `start_translation_store`

Starts the translation store process manually if needed.

This is usually handled by the GettextTranslator.Supervisor, but can be
called directly if needed.

---

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