GettextTranslator.Dashboard.TranslationStore (gettext_translator v0.2.0)

View Source

In-memory store for translation entries using ETS. This module manages the storage and retrieval of translations for the dashboard.

Summary

Functions

Returns a specification to start this module under a supervisor.

Creates a changelog entry for a translation.

Returns translations filtered by criteria.

Gets a specific translation by ID.

Returns all translations.

Scans the gettext directories and loads all translations into memory. Also loads associated changelog files.

Saves changelog entries to their corresponding files.

Starts the translation store.

Updates the status of a changelog entry.

Updates a translation entry in the ETS store.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

create_changelog_entry(translation, status \\ "NEW")

Creates a changelog entry for a translation.

filter_translations(criteria)

Returns translations filtered by criteria.

Examples

# Get all Spanish translations
TranslationStore.filter_translations(%{language_code: "es"})

# Get all pending translations
TranslationStore.filter_translations(%{status: :pending})

# Get all pending Spanish translations
TranslationStore.filter_translations(%{status: :pending, language_code: "es"})

get_translation(id)

Gets a specific translation by ID.

list_translations()

Returns all translations.

load_translations(gettext_path)

Scans the gettext directories and loads all translations into memory. Also loads associated changelog files.

save_changelog_to_files()

Saves changelog entries to their corresponding files.

start_link(opts \\ [])

Starts the translation store.

update_changelog_status(changelog_id, status)

Updates the status of a changelog entry.

update_translation(id, params)

Updates a translation entry in the ETS store.

Parameters

  • id - The ID of the translation to update
  • params - A map of attributes to update

Examples

# Update a translation with new text
TranslationStore.update_translation("abc123", %{
  translation: "New translation text",
  status: :modified
})

# Approve a translation
TranslationStore.update_translation("abc123", %{status: :translated})