Skip to content

Translate devise to pt-BR#290

Merged
edimossilva merged 6 commits intoespoo-dev:mainfrom
lucasleandro1:fix-translate-devise-pt
May 8, 2025
Merged

Translate devise to pt-BR#290
edimossilva merged 6 commits intoespoo-dev:mainfrom
lucasleandro1:fix-translate-devise-pt

Conversation

@lucasleandro1
Copy link
Contributor

@lucasleandro1 lucasleandro1 commented Apr 29, 2025

Context

  • Devise's default messages were in English, requiring a translation into Portuguese.

Solution

  • Added the devise-i18n gem and set the locale to pt-BR, allowing Devise messages to be show in Portuguese.

config.load_defaults 7.0

# translate to PT-br
config.i18n.available_locales = %w[pt-BR en]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should create a separate file for this configuration.

config/initializers/i18n.rb

frozen_string_literal: true

I18n.load_path += Rails.root.glob("/config/locales/**/*.{rb,yml}")
I18n.available_locales = :"pt-BR"
I18n.default_locale = :"pt-BR"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -0,0 +1,147 @@
pt-BR:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This file can be located at:

config/locales/pt-BR/devise.yml

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@lucasleandro1 lucasleandro1 changed the title tranlate devise to pt feat: tranlate devise to pt May 2, 2025
@lucasleandro1 lucasleandro1 changed the title feat: tranlate devise to pt feat: tranlate devise to pt-BR May 2, 2025
# devise-api authenticate API requests [https://github.com/nejdetkadir/devise-api]
gem "devise-api", github: "nejdetkadir/devise-api", branch: "main"
# Add devise-i18n for automatic translation of Devise views and messages
gem "devise-i18n", "~> 1.10"
Copy link
Collaborator

@danielnottingham danielnottingham May 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need this gem?

I believe we can do this without adding another gem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You're right that it's possible to translate Devise manually. I actually tested that approach without using the devise-i18n gem, but it didn’t translate everything, only any messages.

That’s because we didn’t generate the Devise views, so it kept using the default ones from the gem, which are hardcoded in English and don’t use t() for translations.

@edimossilva edimossilva merged commit b66353a into espoo-dev:main May 8, 2025
3 checks passed
@lucasleandro1 lucasleandro1 changed the title feat: tranlate devise to pt-BR Translate devise to pt-BR May 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants