Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
T

title

> 编程语言
Open source

I18n your <title>s

200 stars0 likes2 views
WebsiteGitHub

About

I18n your <title>s

Title

Translations for \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

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
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.

Issues· 1 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

Ruby

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言