Admittedly I'm probably stretching the scope of the question too far but ... what about using .rb
files for the translations? You can do both of your points then.
1) Instead of config/locales/en.yml
(say), you can have config/locales/en.rb
:
account_name = 'Megacorp'
{
en: {
account: {
label: account_name
},
user: {
creation: 'Welcome aboard user of ' + account_name
}
}
}
2) Similarly you can use a class variable in en.rb
:
{
en: {
user: {
creation: 'Welcome aboard user of ' + Account.to_s
}
}
}
You don't have to use .rb
files for all your translations if you prefer yaml (and most people do) but you could use it for those translations that you want to do this kind of thing on.