Skip to content

Idea: pluggable translation backends #500

Description

@tomash

Two things have happened lately.

One: I've been browsing Globalize's issues and PRs, realizing many of them (if not most) are related to how we integrate with ActiveRecord associated translation tables. Which is not a surprise because Globalize is basically a nice DSL for managing these.
Two: Postgres, Rails community database of choice, is improving its complex-data storage mechanisms, mostly JSON ones.

I'm thinking about putting an abstraction layer between Globalize's logic (reading and saving translated attributes) and ActiveRecord-translation-associations, allowing the latter to be seamlessly replaced with a different approach for storing actual translations. Like, for example, a "transations" complex column (e.g. JSON type) storing translated attributes in the same row.

This will be not unlike a Repository pattern. And this way we could isolate and separate layers of Globalize's logic. Trasto shows a nice approach for starting with this:

    def define_localized_attribute(column)
      define_method(column) do
        read_localized_value(column)
      end

      define_method("#{column}=") do |value|
        write_localized_value(column, value)
      end
    end

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions