Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow configuration for handling null and empty strings in translations (Fixes #456) #465

Merged

Conversation

alipadron
Copy link
Contributor

This pull request introduces configuration options to control how null and empty string values are handled in translations. It also handles a case where the column value is null it returns null instead of empty string.

Background

Solution:

This pull request provides a solution that addresses both scenarios:

  • Maintains the default behavior of the library.
  • Introduces a configuration option to allow developers to explicitly return null and empty strings where expected.

Benefits:

  • Existing codebases don't require immediate changes.
  • Developers can now configure the library for specific needs.
  • Improved flexibility and future-proofing.

@freekmurze
Copy link
Member

Could you rebase against main?

…options to `Translatable`.

- Update `HasTranslations->getTranslation` to handle null values
- Modify `HasTranslations->filterTranslations` to allow null and empty strings based on configuration.
…fluent methods to Translatable

- Introduce fluent methods to configure null and empty string translation behavior
@alipadron alipadron force-pushed the allow-null-empty-string-translations branch from 3e7af90 to 0ef9f89 Compare December 9, 2024 16:21
@alipadron
Copy link
Contributor Author

Could you rebase against main?

Done!

@freekmurze freekmurze merged commit e9cd8ee into spatie:main Dec 9, 2024
19 checks passed
@freekmurze
Copy link
Member

Thanks!

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