jensljungblad / elemental_components

Simple view components for Rails 5.1+
MIT License
76 stars 5 forks source link

Support I18n locales for components #30

Open msalzburg opened 5 years ago

msalzburg commented 5 years ago

It would be nice to store component specific locales in the components directory (with the components CSS and JS files) and enhance I18ns lazy lookup to support a "components" namespace.

Extending the i18n load path can be quite easy:

# config/application.rb

config.i18n.load_path += Dir[Rails.root.join('app', 'components', '**', '*.yml')]

I have not yet dug up how to define a "components" namespace for the lazy lookup. Probably it would be nice to have a hierarchy like this:

# components/alert/alert_en.yml

en:
  components:
    alert:
       title: 'foo'
jensljungblad commented 5 years ago

Sounds like a good idea!