komposable / komponent

An opinionated way of organizing front-end code in Ruby on Rails, based on components

Home Page:http://komponent.io

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Dot prefix for locales

sigmike opened this issue · comments

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.

👍 for option 1.

can you provide examples how to use it?

/ _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.