Skip to content

Conversation

@leandrogehlen
Copy link
Contributor

❓ Type of change

  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

This change modifies the locale method to provide a default locale if none is specified. Previously, if the locale parameter was omitted, it would result in an undefined value being passed to the I18n instance. By using locale || this.defaultLocale, we ensure that the default locale is used, improving usability.

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@thetutlage
Copy link
Member

I think this PR changes the behavior of the locale method. Instead of making the first parameter as required, we are making it optional. Any reasons, you want to make the parameter optional?

@leandrogehlen
Copy link
Contributor Author

leandrogehlen commented Oct 9, 2024

Hello @thetutlage,

Currently, to use i18n, we need to do something like:

const i18n = i18nManager.locale(i18nManager.defaultLocale)
const subject = i18n.t('messages.email_confirmation_subject')

I think const i18n = i18nManager.locale() would be a cleaner code style.

Another suggestion is to provide a simpler way to use i18n, such as:

const { t } = i18nManager.default()
const subject = t('messages.email_confirmation_subject')

@thetutlage
Copy link
Member

Alright, makes sense!

@thetutlage thetutlage merged commit faca7d0 into adonisjs:develop Dec 10, 2024
5 checks passed
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.

2 participants