Skip to content

Instantly share code, notes, and snippets.

@silvio-galli
silvio-galli / questions_about_i18n_strategy.md
Last active July 12, 2016 15:00
Questions about rails i18n strategy

In the YAML file is it better to use key names related to the translation or referencing to the role they have in the resulting HTML page?

Should I write <h1><%= t '.title' %></h1>

Writing .yml files with key names related to the translation has the advantage to rely on rails ability to manage key names when the translation is missing, e.i. new_product becomes "New Product" in the views. This can be useful because allow to forget about the english version and focus on the other language translation.

# config/locales/it.yml
# key names reference to translation
@silvio-galli
silvio-galli / bloccit-rails-console-assignment
Last active November 18, 2015 14:02
Bloc - assignment 29 ORM
[49] pry(main)> post = Post.first
Post Load (0.3ms) SELECT "posts".* FROM "posts" ORDER BY "posts"."id" ASC LIMIT 1
=> #<Post:0x007f031686f5e0
id: 1,
title: "First Post",
body: "This is the first post in our system",
created_at: Tue, 17 Nov 2015 14:29:24 UTC +00:00,
updated_at: Tue, 17 Nov 2015 14:29:24 UTC +00:00>
[50] pry(main)> cd post
[51] pry(#<Post>):1> self.methods.sort