Embedded translations for Ecto schemas using PostgreSQL JSONB columns to avoid extra tables.
Trans is an Elixir library that provides embedded translations for Ecto schemas, eliminating the need for separate translation tables. It leverages PostgreSQL's JSONB datatype to store translations directly within the schema, reducing database complexity and improving query performance by avoiding extra JOINs.
Elixir developers using Ecto with PostgreSQL who need to internationalize content in their applications, particularly those seeking to simplify database schema and optimize query performance for translated data.
Developers choose Trans over traditional translation table approaches because it stores translations in a JSONB column within the same table, which reduces database complexity, simplifies migrations, and improves performance by minimizing JOINs. It integrates seamlessly with Ecto schemas, changesets, and migrations, offering a lightweight, modular design focused on simplicity.
Embedded translations for Ecto
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Stores translations in a JSONB column within the same table, eliminating separate tables and reducing JOINs, which simplifies database schema and improves performance as emphasized in the README's philosophy.
Works natively with Ecto schemas, changesets, and migrations, allowing easy setup via macros like `use Trans` and `translations`, as shown in the quickstart example.
Generates optimized database queries for translated data using Ecto SQL and PostgreSQL JSONB, avoiding extra JOINs and enhancing query efficiency, as detailed in the QueryBuilder section.
Allows overriding the default translation field name and supports custom translation modules, demonstrated in the README sections on custom containers and schemas for advanced use cases.
Requires PostgreSQL 9.4+ for JSONB support, making it unsuitable for projects using other databases and limiting portability, as noted in the optional requirements.
Lacks out-of-the-box features like translation fallbacks, management interfaces, or versioning, relying on manual implementation via Ecto changesets, which can increase development overhead.
Customizing translation schemas or handling nested translations requires additional code and understanding of embedded schemas, as seen in the customization examples, adding setup complexity.