Hacker News new | ask | show | jobs
by reidjs 1694 days ago
Interesting article. How do people usually name their keys in their i18n data files? For example, do you name based on the 'what' or the 'where'?

The what:

greeting: "Hello"

or the where:

dashboard.header: "Hello"

edit: I guess you could do both

dashboard.header:

  greeting: "Hello"
1 comments

Personally I like to add the context of the string, not at what place it is used.

For example:

  title.welcome = "Welcome"
  button.submit = "Submit"
In my experience this makes reusing of texts much easier and there will be less to translate. Because the same welcome title could be used in the dashboard header but also at other places.

But I think this is just a matter of taste. Use what works for you.