Skip to content

Add global shortcuts T() and L() convenience methods#10

Merged
markets merged 5 commits intomasterfrom
copilot/fix-8
Jul 15, 2025
Merged

Add global shortcuts T() and L() convenience methods#10
markets merged 5 commits intomasterfrom
copilot/fix-8

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jul 14, 2025

This PR introduces global shortcut methods for MiniI18n's main functionality by injecting them into the Kernel module:

  • T() and t() - shortcuts for MiniI18n.t()
  • L() and l() - shortcuts for MiniI18n.l()

Usage

The shortcuts work exactly like their full counterparts:

# Before
MiniI18n.t(:hello)
MiniI18n.t(:hello, locale: :fr)
MiniI18n.l(1000.25)

# After (using shortcuts)
T(:hello)
t(:hello, locale: :fr)
L(1000.25)

Implementation

  • Created lib/mini_i18n/kernel.rb with the four global methods
  • Integrated the kernel extension into the main library
  • Added comprehensive tests to verify all shortcuts work correctly
  • All existing tests continue to pass (34 examples, 0 failures)

The methods are simple delegation methods that pass all arguments through to the original MiniI18n methods, ensuring full compatibility with all existing options and features.

Fixes #8.


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI changed the title [WIP] Add T or t shortcut Add global shortcuts T/t and L/l for MiniI18n convenience methods Jul 14, 2025
Copilot AI requested a review from markets July 14, 2025 21:38
Copy link
Copy Markdown
Owner

@markets markets left a comment

Choose a reason for hiding this comment

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

Cool! Some changes:

  • Lets keep only the upcase versions
  • Update the README explaining these new methods
  • Rename the file to "kernel_extensions.rb"

…ions, rename file, update README

Co-authored-by: markets <[email protected]>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jul 14, 2025

Cool! Some changes:

  • Lets keep only the upcase versions
  • Update the README explaining these new methods
    ...

Done! I've implemented all the requested changes:

  1. ✅ Kept only the uppercase versions (T and L) - removed lowercase t and l methods
  2. ✅ Updated the README with a new "Global shortcuts" section explaining the new methods
  3. ✅ Renamed the file from kernel.rb to kernel_extensions.rb

The changes are in commit b15a738. The global shortcuts now only include T() and L() methods, which work exactly like their MiniI18n.t() and MiniI18n.l() counterparts.

Copilot AI requested a review from markets July 14, 2025 21:49
Copy link
Copy Markdown
Owner

@markets markets left a comment

Choose a reason for hiding this comment

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

In the docs, dont add a title, add just a sentence as we do for current aliases. Please and mention each method under their specific section.

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jul 14, 2025

In the docs, dont add a title, add just a sentence as we do for current aliases. Please and mention each method under their specific section.

Updated the README documentation to integrate the global shortcuts into their respective sections instead of having a separate section. The T() shortcut is now documented under the translation section and L() under the localization section, following the same pattern as existing aliases. Changes in commit 52d5e41.

Copilot AI requested a review from markets July 14, 2025 22:18
@markets markets marked this pull request as ready for review July 15, 2025 08:46
@markets markets changed the title Add global shortcuts T/t and L/l for MiniI18n convenience methods Add global shortcuts T() and L() convenience methods Jul 15, 2025
@markets markets merged commit 9817697 into master Jul 15, 2025
14 checks passed
@markets markets deleted the copilot/fix-8 branch July 15, 2025 08:48
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.

Add T or t shortcut

2 participants