ActionView::Helpers::NumberHelper
Show archive.org snapshot
Accept-Language
Show archive.org snapshot
HTTP header. Can be parsed with a gem like
accept_language
Show archive.org snapshot
.Even if your application only supports a single language, it makes sense to place some strings into your locale files:
You will use these strings in multiple places in your app, and maintaining them in a central place makes your code DRY. E.g. Movie.human_attribute_name(:title)
will return the title translation from activerecord.attributes.movie.title
.
Browse through the locale files of a recent sample app (like Deskbot) to see this pattern in practice.
The default strings used by Rails can be found in the rails-i18n Show archive.org snapshot repository.
When we start a new project we often copy the German/English locale files Show archive.org snapshot and customize them.
Many gems like Devise or assignable_values also place their strings in locale files. This way you can override them with your own wording.
Localization is a cross-cutting concern that affects all screens.
To get a 100% coverage you would need to duplicate all your tests for every single locale. This is not sustainable.
We recommend the following instead:
I18n.t
:
We want to make the following changes to our MovieDB:
User
attribute or locale-specific URLs (with a custom hostname or with
routing-filter
Show archive.org snapshot
- currently
only Rails < 7.1
Show archive.org snapshot
).Start by estimating the required time using the techniques you learnt.
After you reviewed the estimate with your mentor: