GettextTranslator.Util.PathHelper (gettext_translator v0.4.2)

View Source

Helper functions for working with PO and changelog file paths.

Summary

Functions

Gets the changelog path corresponding to a PO file.

Ensures the translation_changelog directory exists.

Extracts the domain from a PO file path.

Extracts the language code from a PO file path.

Returns the appropriate gettext directory path.

Gets the source PO file path from a changelog path.

Returns the appropriate translation changelog directory path.

Functions

changelog_path_for_po(po_path, app \\ nil)

Gets the changelog path corresponding to a PO file.

Examples

iex> changelog_path_for_po("priv/gettext/uk/LC_MESSAGES/default.po", :my_app)
"/path/to/my_app/priv/translation_changelog/uk_default_changelog.json"

ensure_changelog_dir(app \\ nil)

Ensures the translation_changelog directory exists.

Examples

iex> ensure_changelog_dir(:my_app)
:ok

extract_domain(po_path)

Extracts the domain from a PO file path.

Examples

iex> extract_domain("priv/gettext/uk/LC_MESSAGES/default.po")
"default"

extract_language_code(po_path)

Extracts the language code from a PO file path.

Examples

iex> extract_language_code("priv/gettext/uk/LC_MESSAGES/default.po")
"uk"

gettext_dir(app \\ nil)

Returns the appropriate gettext directory path.

Examples

iex> gettext_dir(:my_app)
"/path/to/my_app/priv/gettext"

po_path_for_changelog(changelog_path, app \\ nil)

Gets the source PO file path from a changelog path.

Examples

iex> po_path_for_changelog("priv/translation_changelog/uk_default_changelog.json", :my_app)
"/path/to/my_app/priv/gettext/uk/LC_MESSAGES/default.po"

translation_changelog_dir(app \\ nil)

Returns the appropriate translation changelog directory path.

Examples

iex> translation_changelog_dir(:my_app)
"/path/to/my_app/priv/translation_changelog"