The gem adds a collection of translated error strings for Stripe::CardError
.
Supported Locales:
- en (English - US)
- es (Spanish)
- de (German)
- fr (French)
- it (Italian)
- nl (Dutch)
- pt-BR (Portuguese - Brazil)
- ru (Russian)
- nb (Norwegian)
- ja (Japanese)
- zh-HK (Chinese - Hong Kong)
Add this line to your application's Gemfile:
gem 'stripe-i18n'
And then execute:
$ bundle
Or install it yourself as:
$ gem install stripe-i18n
Use the code on the error object (Stripe::CardError
) to get the correct
translation key.
def charge_token(token, amount)
Stripe::Charge.create(
amount: amount,
currency: 'usd',
card: token,
)
{ success: true, msg: I18n.translate('charge.success') }
rescue Stripe::CardError => e
{ success: false, msg: I18n.translate("stripe.errors.#{e.code}") }
end
- Fork it ( https://github.com/ekosz/stripe-i18n/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request