svenfuchs/i18n — pull request #250 by jimmycuadra (2014-04-12 04:11:05+00:00)
Title: Maintain subclasses of Hash when calling Hash#slice

This patch corrects i18n's implementation of `Hash#slice` so that it always returns an object of the same class it was originally called on.

In the current implementation, it creates a new hash, copies the selected key/value pairs into it, and returns it. This causes the returned value to be a different class, in the case where the original object was a subclass of Hash. This behavior is problematic when using something like `Hashie` or `HashWithIndifferentAccess`, because translation string interpolation only works for symbols, and keys can be copied into the new hash as strings, depending on the implementation of the subclass.

I discovered this in another library that returns `Hashie::Rash` objects, which work like allow symbol and string key access, but when copied by i18n's `Hash#slice`, lose their ability to look up values by symbol keys.