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

A module for translating gettext files.

This module provides functionality to scan directories for gettext files,
process translation folders, and summarize the results. It leverages helper functions
and processors defined in other modules.

## Overview

The main entry point of this module is the `translate/2` function which:
  1. Scans the specified root directory for gettext files using `Parser.scan/1`.
  2. Processes each folder corresponding to a language.
  3. Summarizes the total number of translations made.

Languages that are defined in the `provider`'s `ignored_languages` list will be skipped,
and a log message is generated.

## Example Usage

    iex> provider = %{ignored_languages: ["fr", "de"]}
    iex> root_path = "path/to/gettext"
    iex> GettextTranslator.configure(application: :my_app)
    iex> GettextTranslator.translate(provider, root_path)
    {:ok, total_translations}

# `application`

Returns the configured application name or nil if not configured.

# `configure`

Configures the GettextTranslator module.

## Options
  * `:application` - The OTP application name to use for resolving paths

## Example

    iex> GettextTranslator.configure(application: :my_app)
    :ok

# `translate`

Translates the gettext files located at the given root path.

This function performs the following steps:
  1. Scans the `root_gettext_path` for gettext files using `Parser.scan/1`.
  2. Processes each language folder found by filtering out languages that are ignored
     (as specified in the `provider` map's `ignored_languages` key) and running the translation
     process on the rest using `Processor.run/2`.
  3. Summarizes the total number of translations performed across all folders.

## Parameters

  - `provider`: A map or struct that configures the translation process. It must include an
    `ignored_languages` key which is a list of language codes to be skipped.
  - `root_gettext_path`: The root directory path where gettext files are stored.
                        Can be a relative path "priv/gettext" or an absolute path.

## Return Value

Returns `{:ok, total}` where `total` is the sum of translations performed.
If the scan fails, the function will return the corresponding error tuple.

## Examples

    iex> provider = %{ignored_languages: ["fr", "de"]}
    iex> root_gettext_path = "priv/gettext"
    iex> GettextTranslator.translate(provider, root_gettext_path)
    {:ok, total_translations}

---

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