GettextTranslator (gettext_translator v0.2.0)
View SourceA 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:
- Scans the specified root directory for gettext files using
Parser.scan/1
. - Processes each folder corresponding to a language.
- 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.translate(provider, root_path)
{:ok, total_translations}
Summary
Functions
Translates the gettext files located at the given root path.
Functions
Translates the gettext files located at the given root path.
This function performs the following steps:
- Scans the
root_gettext_path
for gettext files usingParser.scan/1
. - Processes each language folder found by filtering out languages that are ignored
(as specified in the
provider
map'signored_languages
key) and running the translation process on the rest usingProcessor.run/2
. - Summarizes the total number of translations performed across all folders.
Parameters
provider
: A map or struct that configures the translation process. It must include anignored_languages
key which is a list of language codes to be skipped.root_gettext_path
: The root directory path where gettext files are stored.
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 = "path/to/gettext"
iex> GettextTranslator.translate(provider, root_gettext_path)
{:ok, total_translations}