简体   繁体   中英

Loading I18n files in a gemified plugin

I'm building a gemified plugin with Rails 4. For the most part, it works as expected, but I can't get the I18n to work. When I try, I get this error:

translation missing: en.errors.messages.no_revisions_made

My I18n file looks like this:

#config/locales/en.yml
en:
  errors:
    messages:
      no_revisions_made: "You must edit at least one attribute"

While the I18n call looks like this:

I18n.t("errors.messages.no_revisions_made")

I'm assuming this is happening because the plugin is not loading the en.yml file. How can I prompt it to do so?

Turns out a standard gemified plugin cannot do this. However, a Rails Engine can. A Rails Engine has all the same functionality as a gemified plugin, but with extra perks. For instance, it can have self-contained models, views, and controllers--as well as I18n files, routes, and initializers.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM