Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined method 'initialized?' for I18n::Backend::ActiveRecord #428

Closed
karlkaebnick opened this issue Sep 23, 2016 · 7 comments
Closed
Assignees

Comments

@karlkaebnick
Copy link

Am running Rails 4.2.5.1. Have tried versions 3.0.0.rc11 as well as 2.1.2 of the i18n-js gem. With both of them, when I run 'rake i18n:js:export' I get NoMethodError: undefined method `initialized?' for #I18n::Backend::ActiveRecord.

I know other people have seen this error for other i18n backends (and appear to have found solutions) - is there a known workaround for this with the ActiveRecord backend?

@PikachuEXE
Copy link

It's due to
https://github.com/fnando/i18n-js/blob/master/lib/i18n/js.rb#L153
And that method is assuming simple backend

@stavskiys
Copy link

+1
I have the same problem

@andreslemik
Copy link

andreslemik commented Feb 8, 2017

try add this code to initializers:

module I18n
  module JS
    def self.translations
     ::I18n::Backend::Simple.new.instance_eval do
        init_translations unless initialized?
        Private::HashWithSymbolKeys.new(translations)
                                   .slice(*::I18n.available_locales)
                                   .to_h
      end
    end
  end
end

Keep in mind that in this case i18n-js will get translations from yaml instead database

@Iuriy-Budnikov
Copy link

@andreslemik +1

@PikachuEXE PikachuEXE self-assigned this Nov 1, 2018
@PikachuEXE
Copy link

A new version 3.1.0 is released with #519 merged
Can you guys try it?

@sbungartz
Copy link

Update: If you do try this out, mind the reloading-limitations documented in #521. Possible workarounds for use-cases with and without a Chain-Backend are also documented there.

@vipera
Copy link

vipera commented Feb 28, 2020

i18n-active_record 0.4.0 includes a patch that makes it compatible as a backend for i18n-js. I'm using an (ActiveRecord, Simple) chain backend and it works fine.

More details are in the PR svenfuchs/i18n-active_record#97.

@fnando fnando closed this as completed May 25, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

8 participants