My website is localized in two languages right now:
www.website.com/book
www.website.com/de/book
I just use the "de" local, not the "en" in the url.
Is there a way to change the de-urls to e.g.
www.website.com/de/buch
without using an extra gem? I already use the globalize gem but due to many problems in the past I prefer to use as few gems as possible.
Part of my application.rb is:
class Application < Rails::Application
config.active_record.whitelist_attributes = false
config.i18n.default_locale = :en
config.i18n.available_locales = [:en, :de]
config.i18n.fallbacks = true
config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '*.{rb,yml}').to_s]
config.i18n.enforce_available_locales = true
Part of my application_controller.rb is:
before_filter :set_locale
def set_locale
I18n.locale = params[:locale] || :en
end
def default_url_options(options = {})
{ :locale => ((I18n.locale == I18n.default_locale) ? nil : I18n.locale) }.merge options
end
The routes are localized too.