Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to configure i18n pt-BR on ruby on rails App, getting an error

I am trying to configure pt-BR on ruby on rails using i18n.

I have added on the file config/application.rb

config.i18n.default_locale = :pt-BR

And on the controller controllers/application_controller.rb

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel


class ApplicationController < ActionController::Base
    before_action :set_locale

    def set_locale
        I18n.locale = params[:lang] || I18n.default_locale
    end
end

When i run rails s i get the error:

: uninitialized constant MyApp::Application::BR (NameError)

If i change the :pt-BR to :pt, for example, it works fine, but not working with pt-BR

Any suggestions to fix that?

>Solution :

you should use quotes around :"pt-BR", instead of only :pt-BR.

try that:

config.i18n.default_locale = :"pt-BR"

source:
https://guiarails.com.br/i18n.html

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading