komposable / komponent

An opinionated way of organizing front-end code in Ruby on Rails, based on components
http://komponent.io
MIT License
427 stars 31 forks source link

Dot prefix for locales #24

Closed sigmike closed 6 years ago

sigmike commented 6 years ago

With this change the locale prefix becomes longer. It's good because it prevents conflicts but it makes the prefix even longer, so more painful to use.

I think we should :

  1. either override translate (and t) to make keys starting with a dot look into the component locales (like rails does)
  2. or use the Rails "dot look up", i.e. generate a locale file with a default hierarchy including the full namespace, for example for an "admin/button" component: <locale>.components.admin.button.admin_button (to match the partial path).

I think 1. is better because the hierarchy is simpler and if you refactor your component by moving things into partial you don't have to change your keys.

Spone commented 6 years ago

:+1: for option 1.

andrzejsliwa commented 6 years ago

can you provide examples how to use it?

florentferry commented 6 years ago
/ _button.html.slim

= t(".hello")

/ Instead of
/ = t("button_component.hello")
/ button.de.yml

de:
  button_component:
    hello: "Halo"

But it's only after we apply your changes in #18. We can already do that with the current key's naming.