GettextTranslator.Util.PathHelper (gettext_translator v0.2.0)

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.

Gets the source PO file path from a changelog path.

Functions

changelog_path_for_po(po_path)

Gets the changelog path corresponding to a PO file.

Examples

iex> changelog_path_for_po("priv/gettext/uk/LC_MESSAGES/default.po")
"priv/translation_changelog/uk_default_changelog.json"

ensure_changelog_dir()

Ensures the translation_changelog directory exists.

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"

po_path_for_changelog(changelog_path)

Gets the source PO file path from a changelog path.

Examples

iex> po_path_for_changelog("priv/translation_changelog/uk_default_changelog.json")
"priv/gettext/uk/LC_MESSAGES/default.po"