0

I waste tons of time trying to construct the the proper yaml for translating text and labels in Rails.

Is there an easy way to pinpoint what path I should use in the YAML to provide the translation?

As an example, I am using a nested simple_form with this form erb:

<%= f.input :birth_date, as:'string' %>

The label I get is Birth date and I am assuming is just coming from the model attribute.

When I debug that line and type f.object_name I get

=> "user_wizard[children_attributes] 

Here's my YAML

en-US:
  simple_form:
    labels:
      user_wizard:
        children_attributes:
          birth_date: "Name Date or Expected Date"

Is there a sure-fire way to log, print, probe, watch, render or query that will give the (or one) exact path I need in almost any situation? Not just simple_form or a model attribute but for error messages, buttons, mailers, etc.

JHo
  • 1,068
  • 1
  • 14
  • 29

1 Answers1

0

We have had tons of issues with the i18n key management as well, that's why we have decided to go down a different road and display the whole key name, with a possibility to edit it in place as well. We feel that this solves the problem of finding the correct key name and filling it. Check out our solution, PhraseApp and especially our In-Context Editor.

To summarize: The best thing might be to expose the key name through code. We have built our own solution, but you probably can do it with a little monkey patch to i18n as well.

docstun
  • 90
  • 3
  • PhraseApp is a complete solution. Thanks for pointing it out. I am looking for something a little more limited in scope. – JHo Aug 13 '13 at 11:01