I would do that with the I18n gem that ships with Rails instead, it's made for that, handles plurals, prepares you for multiple languages if that was ever needed down the road, and it's as easy to change for non-developers.
The count key has a special role that tells the gem which translation to pick. You can read more about pluralization here: guides.rubyonrails.org/i18n.html#p....
If the template is static, definitely the I18n is the right solution. But we have to provide the ability to the business team to customize those SEO templates
I would do that with the I18n gem that ships with Rails instead, it's made for that, handles plurals, prepares you for multiple languages if that was ever needed down the road, and it's as easy to change for non-developers.
In
config/locals/en.yml
The
count
key has a special role that tells the gem which translation to pick. You can read more about pluralization here: guides.rubyonrails.org/i18n.html#p....And in your views (or in
Article#title
)If the template is static, definitely the I18n is the right solution. But we have to provide the ability to the business team to customize those SEO templates
You can still do it with I18n if your business team needs to input those via an admin interface instead of a yaml file.
and then
I18n.t("name_with_reviews", count: 2, name: "Bob")
Of course if you don't want to support plural it's just
and
I18n.t("name_with_reviews", name: "Bob")