Sha256: c7c0b6328e5df68d84ccf00f07300475dda55ccdf54f3a68048b871909af8948
Contents?: true
Size: 1.12 KB
Versions: 2
Compression:
Stored size: 1.12 KB
Contents
# Title Translations for \<title\>s! ## Usage Add to your translations: ```yaml en: titles: # titles.application defaults to the sigficant portion of # AppName::Application, which would be: application: AppName dashboards: show: Dashboard users: show: '%{user}' new: Registration ``` And to your HTML: ```erb <title><%= title %></title> ``` And to your `User` model: ```ruby def to_s name end ``` You can pass additional values to the `#title` helper, which can be referenced in your translations: ```erb <title><%= title(user_name: current_user.name) %></title> ``` ```yaml en: titles: application: '%{user_name} - AppName' ``` ## Acknowledgement Though the idea of translating titles was arrived at seperately, [Brandon Keepers] wrote [Abusing Rails I18N to Set Page Titles] which outlines an extremely similar approach, and from whence came the idea of using the view context to get local assigns to be used in interpolation. [Brandon Keepers]: https://github.com/bkeepers [Abusing Rails I18N to Set Page Titles]: https://opensoul.org/2012/11/05/abusing-rails-i18n-to-set-page-titles/
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
title-0.0.10 | README.md |
title-0.0.9 | README.md |