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 key #1

Closed
wants to merge 1 commit into from

Conversation

IrvinFan
Copy link
Owner

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. The current code 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.

@IrvinFan
Copy link
Owner Author

Close this as the official PR is here: ruby-i18n#321

@IrvinFan IrvinFan closed this Aug 18, 2015
@IrvinFan IrvinFan deleted the fix_for_array_key branch August 18, 2015 16:51
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