Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Aug 26, 2025

This PR adds support for using locale: '*' in both translate and localize methods to automatically use all available locales, building on the existing multiple locales functionality.

Changes

  • Enhanced translate method: Now accepts locale: '*' to translate keys across all available locales
  • Enhanced localize method: Now accepts locale: '*' to localize objects across all available locales
  • Backward compatible: All existing functionality remains unchanged

Usage Examples

# Before: You had to explicitly specify all locales
MiniI18n.t(:hello, locale: [:en, :es, :fr])
#=> ["hello", "hola", "bonjour"]

# Now: Use '*' to automatically include all available locales
MiniI18n.t(:hello, locale: '*')
#=> ["hello", "hola", "bonjour"]

# Works with interpolation
MiniI18n.t(:greeting, name: 'world', locale: '*')
#=> ["hello world", "hola world", "bonjour world"]

# Also works with localization
MiniI18n.l(1234.56, locale: '*')
#=> ["1,234.56", "1.234,56", "1 234,56"]

MiniI18n.l(1000, as: :currency, locale: '*')
#=> ["1,000 $", "1.000 €", nil]

Implementation Details

The implementation is minimal and leverages the existing multiple locales infrastructure:

  1. Added helper methods that convert locale: '*' to locale: available_locales array
  2. This conversion happens before the existing array handling logic
  3. The feature automatically adapts when available_locales changes

Testing

Added comprehensive tests covering:

  • Translation with '*' locale
  • Translation with interpolation and '*' locale
  • Localization with '*' locale
  • Currency formatting across all locales
  • Edge cases and backward compatibility

All existing tests continue to pass, ensuring no regression in functionality.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI changed the title [WIP] Now both the translate and the localize methods have the multiple locales return, lets add a nee feature on top, if locale: '*' is provided, all available locales will be used Add support for locale: '*' to use all available locales Aug 26, 2025
Copilot AI requested a review from markets August 26, 2025 00:25
Copilot AI requested a review from markets August 26, 2025 07:58
@markets markets marked this pull request as ready for review August 26, 2025 07:59
@markets markets merged commit e80e27c into master Aug 26, 2025
8 checks passed
@markets markets deleted the copilot/fix-f9634a75-f035-4f61-96c2-ffda7e70e9e5 branch August 26, 2025 08:01
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