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

Fix fallback backend so that it works for an array of keys #321

Closed
wants to merge 1 commit into from
Closed

Fix fallback backend so that it works for an array of keys #321

wants to merge 1 commit into from

Conversation

IrvinFan
Copy link

When multiple keys are passed to translate() as an array the following code in i18n.rb will loop through the keys to apply the fallback translation on each one of them. It re-uses the same options while doing so. As a result it only works for the first key because subsequent translation fails due to polluted options[:fallback].

        if key.is_a?(Array)
          key.map { |k| backend.translate(locale, k, options) }
        else
          backend.translate(locale, key, options)
        end

This PR fixes the issue by creating a new options object when calling super so that original options is not modified and can be re-used.

@radar
Copy link
Collaborator

radar commented Nov 16, 2016

I believe this was fixed in #304. Thanks anyway @IrvinFan!

@radar radar closed this Nov 16, 2016
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.

3 participants