Skip to content
This repository has been archived by the owner on Mar 30, 2021. It is now read-only.

ekosz/stripe-i18n

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

39 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

StripeI18n

Build Status

The gem adds a collection of translated error strings for Stripe::CardError.

ARCHIVED

Unfortunatly I have not done any work with Ruby in 6+ years now. I have reached out multiple times to the Stripe team trying to hand off this gem to them with no responses. Please feel free to fork this library if you would like revive it!

Supported Locales:

  1. en (English - US)
  2. es (Spanish)
  3. de (German)
  4. fr (French)
  5. it (Italian)
  6. nl (Dutch)
  7. pt-BR (Portuguese - Brazil)
  8. ru (Russian)
  9. nb (Norwegian)
  10. ja (Japanese)
  11. zh-HK (Chinese - Hong Kong)

Installation

Add this line to your application's Gemfile:

gem 'stripe-i18n'

And then execute:

$ bundle

Or install it yourself as:

$ gem install stripe-i18n

Usage

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

Contributing

  1. Fork it ( https://github.com/ekosz/stripe-i18n/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request

About

I18n translations for Stripe error codes

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages