Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: ruby-i18n/i18n
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.14.5
Choose a base ref
...
head repository: ruby-i18n/i18n
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: v1.14.6
Choose a head ref
  • 12 commits
  • 12 files changed
  • 6 contributors

Commits on Jul 19, 2024

  1. Configuration menu
    Copy the full SHA
    869460a View commit details
    Browse the repository at this point in the history

Commits on Jul 25, 2024

  1. Optimize pluralization logic in test data

    - Switch from Array#include? to Range#cover? for more than 5 items
    zachmargolis committed Jul 25, 2024
    Configuration menu
    Copy the full SHA
    51e205a View commit details
    Browse the repository at this point in the history

Commits on Aug 19, 2024

  1. Configuration menu
    Copy the full SHA
    55dc807 View commit details
    Browse the repository at this point in the history
  2. Merge pull request #698 from davetron5000/rdoc-fixes

    fix issues with RDoc generation
    radar authored Aug 19, 2024
    Configuration menu
    Copy the full SHA
    eacc34f View commit details
    Browse the repository at this point in the history

Commits on Aug 23, 2024

  1. Fixes strings being interpolated multiple times

    Similarly to #599, I've observed issues issues where untrusted user input
    that includes interpolation patterns gets unintentionally interpolated
    and leads to bogus `I18n::MissingInterpolationArgument` exceptions.
    
    This happens when multiple lookups are required for a key to be resolved,
    which is common when resolving defaults, or resolving a key that itself
    resolves to a Symbol.
    
    As an example let's consider these translations, common for Rails apps:
    
    ```yaml
    en:
      activerecord:
        errors:
          messages:
            taken: "%{value} has already been taken"
    ```
    
    If the `value` given to interpolate ends up containing interpolation characters,
    and Rails specifies default keys (as [described here](https://guides.rubyonrails.org/i18n.html#error-message-scopes)), resolving
    those defaults will cause a `I18n::MissingInterpolationArgument` to be raised:
    
    ```rb
    I18n.t('activerecord.errors.models.organization.attributes.name.taken',
      value: '%{dont_interpolate_me}',
      default: [
        :"activerecord.errors.models.organization.taken",
        :"activerecord.errors.messages.taken"
      ]
    )
    ```
    
    Raises:
    
    ```
    I18n::MissingInterpolationArgument: missing interpolation argument :dont_interpolate_me in "%{dont_interpolate_me}" ({:value=>"%{dont_interpolate_me}"} given)
    ```
    
    Instead of this, we'd expect the translation to resolve to:
    
    ```
    %{dont_interpolate_me} has already been taken
    ```
    
    This behaviour is caused by the way that recursive lookups work: whenever a
    key can't be resolved to a string directly, the `I18n.translate`
    method is called either to walk through the defaults specified, or if a Symbol
    is matched, to try to resolve that symbol.
    
    This results in interpolation being executed twice for recursive
    lookups... once on the pass that finally resolves to a string, and again
    on the original call to `I18n.translate`.
    
    A "proper" fix here would likely revolve around decoupling key resolution
    from interpolation... it feels odd to me that the `resolve_entry` method calls
    `I18n.translate`... however I see this as a fundamental change beyond
    the scope of this fix.
    
    Instead I'm proposing to add a new reserved key `skip_interpolation`
    that gets passed down into every recursive call of `I18n.translate` and
    instructs the method to skip interpolation.
    
    This ensures that only the initial `I18n.translate` call is the one that
    gets its string interpolated.
    alexpls committed Aug 23, 2024
    Configuration menu
    Copy the full SHA
    229d57e View commit details
    Browse the repository at this point in the history

Commits on Sep 3, 2024

  1. Configuration menu
    Copy the full SHA
    ee22f10 View commit details
    Browse the repository at this point in the history

Commits on Sep 15, 2024

  1. Merge pull request #701 from stevegeek/fix_load_rb_with_pathname

    Fix loading of .rb locale files when `load_path` is not a string
    radar authored Sep 15, 2024
    Configuration menu
    Copy the full SHA
    d718ed4 View commit details
    Browse the repository at this point in the history
  2. Merge pull request #699 from alexpls/master

    Fixes strings being interpolated multiple times
    radar authored Sep 15, 2024
    Configuration menu
    Copy the full SHA
    aacb76a View commit details
    Browse the repository at this point in the history
  3. Merge pull request #697 from zachmargolis/margolis-optimize-plurals

    Optimize pluralization logic in test data
    radar authored Sep 15, 2024
    Configuration menu
    Copy the full SHA
    18799df View commit details
    Browse the repository at this point in the history
  4. Merge pull request #696 from KinWang-2013/fix/exists-method-nil-key

    [FIX] Raise ArgumentError on nil key in exists?
    radar authored Sep 15, 2024
    Configuration menu
    Copy the full SHA
    1fbc930 View commit details
    Browse the repository at this point in the history
  5. Add post install message for Ruby < 3.2 users

    As per #686
    radar committed Sep 15, 2024
    2 Configuration menu
    Copy the full SHA
    6d0c2ce View commit details
    Browse the repository at this point in the history
  6. Bump to 1.14.6

    radar committed Sep 15, 2024
    Configuration menu
    Copy the full SHA
    3b65f65 View commit details
    Browse the repository at this point in the history
Loading