Skip to content
This repository has been archived by the owner on Jan 5, 2019. It is now read-only.

i18n considerations #32

Closed
buhrmi opened this issue Oct 22, 2018 · 2 comments
Closed

i18n considerations #32

buhrmi opened this issue Oct 22, 2018 · 2 comments

Comments

@buhrmi
Copy link

buhrmi commented Oct 22, 2018

Hello,

I like the inclusion of a rich-text editor in rails by default.

One issue I'd like to raise is internationalization/translations. I've been using the globalize gem to save translation records for fields on models that have translations. Now I was wondering if this will work for rich text fields, too.

@IvanGrgurevic
Copy link

IvanGrgurevic commented Dec 31, 2018

I gave it a try and doesn't quite work as expected but I've come up with a quick hack to get it working. I delegated all the methods has_rich_text creates to the translation and attached has_rich_text :content to the translation class by opening up globalize's nested Translation class. You can find an example below with a Post model that has content as the rich text field.

Disclaimer: Not fully tested.

class Post < ApplicationRecord
  translates :title, :content, touch: true

  delegate :content, to: :translation
  delegate :content=, to: :translation

  after_save do
    content.save if content.changed?
  end

  class Translation
    has_rich_text :content
  end
end

@georgeclaghorn
Copy link
Contributor

Action Text has been merged into Rails. Please do investigate whether Action Text plays nicely with popular plugins and report back to rails/rails if there’s anything we can reasonably do in the framework to address incompatibilities.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants