Hello hello! I just finished translating my app, however my
translations won't load. So first, what am I doing wrong? And second,
is there anything that can be done better? I'm a bit confused since
every tutorial and demo app seems to have its own way of doing things.
Alright, that's it. Thanks everyone!
/myapp
/myapp/lang
/myapp/lang/en
/myapp/lang/en/en.yml
/myapp/lang/en/en_about.yml
/myapp/lang/en/en_app.yml
/myapp/lang/is/is.yml
/myapp/lang/is/is_about.yml
/myapp/lang/is/is_app.yml
## /myapp/config/environment.rb
I18n.default_locale = "en"
LOCALES_DIRECTORY = "#{RAILS_ROOT}/lang/"
LOCALES_AVAILABLE = Dir["#{LOCALES_DIRECTORY}/*/*.yml"].collect do |locale_file|
File.basename(locale_file, ".yml")
end.uniq
## /myapp/app/controllers/application.rb
before_filter :set_locale
def set_locale
I18n.locale = params[:locale] if params[:locale]
end
## /myapp/app/helpers/application_helper.rb
def t(*args)
translate(*args)
end
## /myapp/app/views/admin/preferences/edit.html.erb
<%= f.label "locale", t(:"locale") %><%= f.select("locale",
options_for_select(LOCALES_AVAILABLE, I18n.locale) %>
--
http://www.home.no/reddvinylene
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"rails-i18n" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rails-i18n?hl=en
-~----------~----~----~----~------~----~------~--~---