Search code examples
ruby-on-rails-4urlroutesrails-i18n

Rails how to hide only default locale in url, but show others


Is it possible to hide the default locale in the url, but show the locale in the other languages?

Say, 'de' is my default locale, my login url should look like this:

domain.com/login

All the other login urls should show the language, e.g.:

domain.com/fr/login

domain.com/es/login

Solution

  • domain.com/login and domain.com/de/login are equivalent, if 'de' is the default_locale. So it is not necessary to hide the default locale. Either works.