I have a multilingual rails application. On the base.html.erb I am setting the lang attribute like that :
<html lang="<%= I18n.locale %>" ng-app="myApp">
Is that a good way to do it or there is a better one ?
It might work okay; although you might prefer setting the current locale within your controllers for better flexibility
class ApplicationController < ActionController::Base
  helper_method :current_locale
  ...
  private
  def current_locale
    @current_locale ||= begin
      # complex logic, switching locale based on
      # user defined locale, subdomain, params, etc...
    end
  end
end
Then in your view :
<html lang="<%= current_locale %>" ng-app="myApp">
...
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With