Reputation: 7215
I went through http://guides.rubyonrails.org/i18n.html and set up my en.yml
file:
en:
test:
welcome: Welcome!!!
registration:
signup: Sign up for an invite!!
However, in my new.html.haml
file,
How do I reference signup
?
The tutorial only shows how to do so using ERB, not HAML. I tried this and it didn't work:
%h2 <%=t :registration.signup %>
Any ideas?
Upvotes: 8
Views: 5904
Reputation: 40333
You should probably read the HAML reference to understand how HAML works. To add code to generate content for a tag, you use =, as in:
%h2= t('registration.signup')
Upvotes: 10
Reputation: 1509
Other comments here relay how you can do this. For what it's worth though, you can also check out haml-i18n-extractor. It's a tool that helps with the string interpolation you need to extract from the templates automatically instead of needing to do things by hand. Should save you a bunch of time.
Upvotes: -1
Reputation: 8833
app/views/registration/index.html.haml
%h2
=t('.signup')
en.yml:
en:
registration:
index:
signup: Sign up for an invite!!
NB:
.signup
. Read more about lazy lookups Upvotes: 3
Reputation: 7215
It worked once I did this:
change en.yml
registration:
signup: "Sign up for an invite to join CorkLabs!!!"
in .haml file
%h2= t 'registration.signup'
Upvotes: 0