AshPhoenixTranslations.Info (ash_phoenix_translations v1.0.0)
View SourceIntrospection module for AshPhoenixTranslations extension.
Provides functions to retrieve translation configuration and metadata from resources that use the AshPhoenixTranslations extension.
Examples
Assuming you have a resource with translations configured:
defmodule MyApp.Product do
use Ash.Resource,
extensions: [AshPhoenixTranslations]
translations do
translatable_attribute :name, locales: [:en, :es, :fr]
translatable_attribute :description, locales: [:en, :es, :fr]
backend :database
cache_ttl 7200
end
endYou can introspect the configuration:
iex> AshPhoenixTranslations.Info.translatable?(MyApp.Product)
true
iex> AshPhoenixTranslations.Info.supported_locales(MyApp.Product)
[:en, :es, :fr]
iex> AshPhoenixTranslations.Info.backend(MyApp.Product)
:database
iex> AshPhoenixTranslations.Info.cache_ttl(MyApp.Product)
7200
Summary
Functions
Returns the all translations calculation name for an attribute.
Get the approval policy for a resource.
Returns whether translation changes should be audited.
Returns whether translations should be automatically validated.
Returns the configured backend for translations.
Returns the cache TTL in seconds.
Get the edit policy for a resource.
Returns the translation storage field name for an attribute.
Returns all supported locales across all translatable attributes.
Returns whether a resource has any translatable attributes.
Returns a specific translatable attribute by name.
Returns all translatable attributes for a resource.
Get the translation policy configuration for a resource.
translations DSL entities
Whether to audit translation changes
Whether to audit translation changes
Whether to automatically validate required translations
Whether to automatically validate required translations
The backend to use for storing translations (database or gettext)
The backend to use for storing translations (database or gettext)
Cache TTL in seconds
Cache TTL in seconds
The Gettext module to use (e.g., MyAppWeb.Gettext). Required when backend is :gettext
The Gettext module to use (e.g., MyAppWeb.Gettext). Required when backend is :gettext
translations DSL options
Policy configuration for translation access control
Policy configuration for translation access control
Get the view policy for a resource.
Functions
Returns the all translations calculation name for an attribute.
@spec approval_policy(Ash.Resource.t() | Spark.Dsl.t()) :: keyword() | nil
Get the approval policy for a resource.
@spec audit_changes?(Ash.Resource.t() | Spark.Dsl.t()) :: boolean()
Returns whether translation changes should be audited.
@spec auto_validate?(Ash.Resource.t() | Spark.Dsl.t()) :: boolean()
Returns whether translations should be automatically validated.
@spec backend(Ash.Resource.t() | Spark.Dsl.t()) :: :database | :gettext
Returns the configured backend for translations.
@spec cache_ttl(Ash.Resource.t() | Spark.Dsl.t()) :: pos_integer()
Returns the cache TTL in seconds.
@spec edit_policy(Ash.Resource.t() | Spark.Dsl.t()) :: atom() | tuple() | nil
Get the edit policy for a resource.
Returns the translation storage field name for an attribute.
@spec supported_locales(Ash.Resource.t() | Spark.Dsl.t()) :: [atom()]
Returns all supported locales across all translatable attributes.
@spec translatable?(Ash.Resource.t() | Spark.Dsl.t()) :: boolean()
Returns whether a resource has any translatable attributes.
@spec translatable_attribute(Ash.Resource.t() | Spark.Dsl.t(), atom()) :: AshPhoenixTranslations.TranslatableAttribute.t() | nil
Returns a specific translatable attribute by name.
@spec translatable_attributes(Ash.Resource.t() | Spark.Dsl.t()) :: [ AshPhoenixTranslations.TranslatableAttribute.t() ]
Returns all translatable attributes for a resource.
@spec translation_policies(Ash.Resource.t() | Spark.Dsl.t()) :: keyword() | nil
Get the translation policy configuration for a resource.
translations DSL entities
Whether to audit translation changes
Whether to audit translation changes
Whether to automatically validate required translations
Whether to automatically validate required translations
@spec translations_backend(dsl_or_extended :: module() | map()) :: {:ok, :gettext | :database} | :error
The backend to use for storing translations (database or gettext)
@spec translations_backend!(dsl_or_extended :: module() | map()) :: (:gettext | :database) | no_return()
The backend to use for storing translations (database or gettext)
@spec translations_cache_ttl(dsl_or_extended :: module() | map()) :: {:ok, pos_integer()} | :error
Cache TTL in seconds
@spec translations_cache_ttl!(dsl_or_extended :: module() | map()) :: pos_integer() | no_return()
Cache TTL in seconds
The Gettext module to use (e.g., MyAppWeb.Gettext). Required when backend is :gettext
The Gettext module to use (e.g., MyAppWeb.Gettext). Required when backend is :gettext
translations DSL options
Returns a map containing the and any configured or default values.
@spec translations_policy(dsl_or_extended :: module() | map()) :: {:ok, approval: [required_for: [atom()], approvers: [atom()]], edit: (:translator | :admin) | {atom(), [atom()]} | atom(), view: (:translator | :admin | :authenticated | :public) | {atom(), keyword()} | atom()} | :error
Policy configuration for translation access control
@spec translations_policy!(dsl_or_extended :: module() | map()) :: [ approval: [required_for: [atom()], approvers: [atom()]], edit: (:translator | :admin) | {atom(), [atom()]} | atom(), view: (:translator | :admin | :authenticated | :public) | {atom(), keyword()} | atom() ] | no_return()
Policy configuration for translation access control
@spec view_policy(Ash.Resource.t() | Spark.Dsl.t()) :: atom() | tuple() | nil
Get the view policy for a resource.