├── lib ├── stripe-i18n.rb ├── stripe_i18n │ ├── version.rb │ └── railtie.rb └── stripe_i18n.rb ├── .travis.yml ├── Gemfile ├── .gitignore ├── spec ├── spec_helper.rb ├── unit │ └── translation_spec.rb ├── integration │ └── translation_spec.rb └── support │ └── fake_app.rb ├── Rakefile ├── rails └── locale │ ├── zh-HK.yml │ ├── ja.yml │ ├── nb.yml │ ├── ru.yml │ ├── en.yml │ ├── de.yml │ ├── it.yml │ ├── pt-BR.yml │ ├── fr.yml │ ├── es.yml │ └── nl.yml ├── LICENSE.txt ├── stripe-i18n.gemspec └── README.md /lib/stripe-i18n.rb: -------------------------------------------------------------------------------- 1 | require 'stripe_i18n' 2 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: ruby 2 | rvm: 3 | - 2.2.2 4 | - 2.3.2 5 | -------------------------------------------------------------------------------- /lib/stripe_i18n/version.rb: -------------------------------------------------------------------------------- 1 | module StripeI18n 2 | VERSION = "2.0.0" 3 | end 4 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | # Specify your gem's dependencies in stripe-i18n.gemspec 4 | gemspec 5 | -------------------------------------------------------------------------------- /lib/stripe_i18n.rb: -------------------------------------------------------------------------------- 1 | require "stripe_i18n/version" 2 | require "stripe_i18n/railtie" 3 | 4 | module StripeI18n 5 | end 6 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | /.bundle/ 2 | /.yardoc 3 | /Gemfile.lock 4 | /_yardoc/ 5 | /coverage/ 6 | /doc/ 7 | /pkg/ 8 | /spec/reports/ 9 | /tmp/ 10 | *.bundle 11 | *.so 12 | *.o 13 | *.a 14 | mkmf.log 15 | .idea 16 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | ENV["RAILS_ENV"] = "test" 2 | 3 | require 'i18n-spec' 4 | require 'support/fake_app' 5 | 6 | I18n.enforce_available_locales = false 7 | 8 | RSpec.configure do |config| 9 | config.mock_with :rspec 10 | end 11 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | require "bundler/gem_tasks" 2 | 3 | require 'rspec/core' 4 | require 'rspec/core/rake_task' 5 | RSpec::Core::RakeTask.new(:spec) do |spec| 6 | spec.pattern = FileList['spec/**/*_spec.rb'] 7 | end 8 | 9 | task :default => :spec 10 | -------------------------------------------------------------------------------- /spec/unit/translation_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | Dir.glob('rails/locale/*.yml') do |locale_file| 4 | describe "a stripe-i18n #{locale_file} locale file" do 5 | it_behaves_like 'a valid locale file', locale_file 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/integration/translation_spec.rb: -------------------------------------------------------------------------------- 1 | require 'spec_helper' 2 | 3 | describe "Translation" do 4 | let(:app) do 5 | StripeI18n::Spec::FakeApp 6 | end 7 | 8 | context "when default locale is English" do 9 | let(:translation) do 10 | app.run lambda { I18n.t("stripe.errors.expired_card") } do |config| 11 | config.i18n.default_locale = :en 12 | end 13 | end 14 | 15 | it "is available" do 16 | translation.should == "The card has expired." 17 | end 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /rails/locale/zh-HK.yml: -------------------------------------------------------------------------------- 1 | zh-HK: 2 | stripe: 3 | errors: 4 | incorrect_number: "信用卡號碼不正確" 5 | invalid_number: "信用卡號碼不是一個有效的信用卡號碼" 6 | invalid_expiry_month: "到期月份無效" 7 | invalid_expiry_year: "到期年份無效" 8 | invalid_cvc: "信用卡驗證碼無效" 9 | expired_card: "信用卡已過期" 10 | incorrect_cvc: "信用卡驗證碼不正確" 11 | incorrect_zip: "信用卡驗證碼不被接納" 12 | card_declined: "信用卡被拒絕" 13 | missing: "沒有客戶信用卡被付款" 14 | processing_error: "在處理信用卡時發生錯誤" 15 | rate_limit: "由於請求過快地觸及API,因此發生錯誤。如果您一直遇到此錯誤,請告知我們。" 16 | -------------------------------------------------------------------------------- /rails/locale/ja.yml: -------------------------------------------------------------------------------- 1 | ja: 2 | stripe: 3 | errors: 4 | incorrect_number: "クレジットカード番号が正しくありません。" 5 | invalid_number: "クレジットカード番号が無効です。" 6 | invalid_expiry_month: "クレジットカード有効期限月が不正です。" 7 | invalid_expiry_year: "クレジットカード有効期限年が不正です。" 8 | invalid_cvc: "クレジットカードセキュリティコードが不正です。" 9 | expired_card: "クレジットカードが有効期限切れです。" 10 | incorrect_cvc: "クレジットカードセキュリティコードが正しくありません。" 11 | incorrect_zip: "クレジットカードの請求先郵便番号が不正です。" 12 | card_declined: "クレジットカードへの請求が拒否されました。" 13 | missing: "クレジットカードが設定されていません。" 14 | processing_error: "クレジットカード処理でエラーが発生しました。" 15 | rate_limit: "処理中にエラーが発生しました。エラーが続くようであればユーザーサポートにお知らせください。" -------------------------------------------------------------------------------- /lib/stripe_i18n/railtie.rb: -------------------------------------------------------------------------------- 1 | require 'rails' 2 | 3 | module StripeI18n 4 | class Railtie < ::Rails::Railtie 5 | initializer 'stripe-i18n' do |app| 6 | StripeI18n::Railtie.instance_eval do 7 | pattern = pattern_from app.config.i18n.available_locales 8 | 9 | add("rails/locale/#{pattern}.yml") 10 | end 11 | end 12 | 13 | protected 14 | 15 | def self.add(pattern) 16 | files = Dir[File.join(File.dirname(__FILE__), '../..', pattern)] 17 | I18n.load_path.concat(files) 18 | end 19 | 20 | def self.pattern_from(args) 21 | array = Array(args || []) 22 | array.blank? ? '*' : "{#{array.join ','}}" 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /spec/support/fake_app.rb: -------------------------------------------------------------------------------- 1 | require 'spork' 2 | 3 | module StripeI18n 4 | module Spec 5 | module FakeApp 6 | def self.run(*tests) 7 | forker = Spork::Forker.new do 8 | require 'stripe-i18n' 9 | require 'action_controller/railtie' 10 | 11 | app = Class.new(Rails::Application) 12 | app.config.active_support.deprecation = :log 13 | app.config.eager_load = false 14 | 15 | yield(app.config) if block_given? 16 | app.initialize! 17 | 18 | results = tests.map(&:call) 19 | results.size == 1 ? results.first : results 20 | end 21 | 22 | forker.result 23 | end 24 | end 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /rails/locale/nb.yml: -------------------------------------------------------------------------------- 1 | nb: 2 | stripe: 3 | errors: 4 | incorrect_number: "Kortnummeret er feil." 5 | invalid_number: "Kortnummeret er ugyldig" 6 | invalid_expiry_month: "Utløpsmåned på kortet er ugyldig." 7 | invalid_expiry_year: "Utløpsåret på kortet er ugyldig." 8 | invalid_cvc: "Sikkerhetskoden på kortet (CVC) er ugyldig." 9 | expired_card: "Kortet har utløpt." 10 | incorrect_cvc: "Sikkerhetskoden for kortet (CVC) er feil." 11 | incorrect_zip: "Kortet feilet validering av postnummer." 12 | card_declined: "Kortet ble avvist." 13 | missing: "Det finnes ingen kort på kunden." 14 | processing_error: "En feil oppstod ved behandling av kortet." 15 | rate_limit: "En feil oppstod da, grunnet for mange forespørsler til Stripe API. Vennligst kontakt oss hvis du opplever denne feilen ofte." 16 | -------------------------------------------------------------------------------- /rails/locale/ru.yml: -------------------------------------------------------------------------------- 1 | ru: 2 | stripe: 3 | errors: 4 | incorrect_number: "Неверный номер карты." 5 | invalid_number: "Недействительный номер карты." 6 | invalid_expiry_month: "Неверный месяц истечения срока действия карты." 7 | invalid_expiry_year: "Неверный год истечения срока действия карты." 8 | invalid_cvc: "Неверный код карты." 9 | expired_card: "Истёк срок действия карты." 10 | incorrect_cvc: "Недействительный код карты." 11 | incorrect_zip: "ZIP-код карты не прошёл проверку." 12 | card_declined: "Карта была отклонена." 13 | missing: "Нет такой карты у клиента который производит оплату." 14 | processing_error: "Во время обработки карты произошла ошибка." 15 | rate_limit: "Произошла ошибка из-за слишком большого количества запросов API. Пожалуйста, сообщите нам, если вы часто сталкиваетесь с этой ошибкой." 16 | -------------------------------------------------------------------------------- /rails/locale/en.yml: -------------------------------------------------------------------------------- 1 | en: 2 | stripe: 3 | errors: 4 | incorrect_number: "The card number is incorrect." 5 | invalid_number: "The card number is not a valid credit card number." 6 | invalid_expiry_month: "The card's expiration month is invalid." 7 | invalid_expiry_year: "The card's expiration year is invalid." 8 | invalid_cvc: "The card's security code is invalid." 9 | expired_card: "The card has expired." 10 | incorrect_cvc: "The card's security code is incorrect." 11 | incorrect_zip: "The card's zip code failed validation." 12 | card_declined: "The card was declined." 13 | missing: "There is no card on a customer that is being charged." 14 | processing_error: "An error occurred while processing the card." 15 | rate_limit: "An error occurred due to requests hitting the API too quickly. Please let us know if you're consistently running into this error." 16 | -------------------------------------------------------------------------------- /rails/locale/de.yml: -------------------------------------------------------------------------------- 1 | de: 2 | stripe: 3 | errors: 4 | incorrect_number: "Die Kartennummer ist falsch." 5 | invalid_number: "Die Kartennummer ist keine gültige Kreditkartennummer." 6 | invalid_expiry_month: "Der Monat des Ablaufdatums ist ungültig." 7 | invalid_expiry_year: "Das Jahr des Ablaufdatums ist ungültig." 8 | invalid_cvc: "Der Sicherheitscode ist ungültig." 9 | expired_card: "Die Karte ist abgelaufen." 10 | incorrect_cvc: "Der Sicherheitscode ist falsch." 11 | incorrect_zip: "Die Postleitzahl ist ungültig." 12 | card_declined: "Die Karte wurde abgelehnt." 13 | missing: "Es gibt keine Karte von der abgebucht wird." 14 | processing_error: "Ein Fehler ist aufgetreten bei der Bearbeitung der Karteninformationen." 15 | rate_limit: "Es ist ein Fehler aufgetreten bei der API-Anfrage. Bitte lassen Sie uns wissen wenn dieses Problem konstant vorkommt." 16 | -------------------------------------------------------------------------------- /rails/locale/it.yml: -------------------------------------------------------------------------------- 1 | it: 2 | stripe: 3 | errors: 4 | incorrect_number: "Il numero di carta è errato." 5 | invalid_number: "Il numero di carta non è un numero di carta valido." 6 | invalid_expiry_month: "Il mese di scadenza della carta non è valido." 7 | invalid_expiry_year: "L’anno di scadenza della carta non è valido." 8 | invalid_cvc: "Il codice di sicurezza della carta non è valido." 9 | expired_card: "La carta è scaduta." 10 | incorrect_cvc: "Il codice di sicurezza della carta è errato." 11 | incorrect_zip: "Il CAP della carta non è valido." 12 | card_declined: "La carta è stata declinata." 13 | missing: "La carta di uno dei clienti addebitati è mancante." 14 | processing_error: "C’è stato un errore nell’elaborazione della carta." 15 | rate_limit: "C’è stato un errore in quanto la richiesta ha raggiunto l’API troppo in fretta. Ti preghiamo di comunicarci se questo errore dovesse capitare ripetutamente." 16 | -------------------------------------------------------------------------------- /rails/locale/pt-BR.yml: -------------------------------------------------------------------------------- 1 | pt-BR: 2 | stripe: 3 | errors: 4 | incorrect_number: "O número do cartão está incorreto." 5 | invalid_number: "O número do cartão não é um número válido de cartão de crédito." 6 | invalid_expiry_month: "O mês de validade do cartão não é válido." 7 | invalid_expiry_year: "O ano de validade do cartão não é válido." 8 | invalid_cvc: "O código de segurança do cartão não é válido." 9 | expired_card: "O cartão expirou." 10 | incorrect_cvc: "O código de segurança do cartão está incorreto." 11 | incorrect_zip: "O CEP do cartão falhou a validação." 12 | card_declined: "O cartão foi recusado." 13 | missing: "Não existe qualquer cartão em um cliente que está sendo cobrado." 14 | processing_error: "Ocorreu um erro durante o processamento do cartão." 15 | rate_limit: "Ocorreu um erro devido a pedidos que atingem a API muito rapidamente. Por favor, nos avise se você está constantemente recebendo esse erro." 16 | -------------------------------------------------------------------------------- /rails/locale/fr.yml: -------------------------------------------------------------------------------- 1 | fr: 2 | stripe: 3 | errors: 4 | incorrect_number: "Le numéro de carte est incorrect." 5 | invalid_number: "Le numéro de carte n’est pas un numéro de carte valide." 6 | invalid_expiry_month: "Le mois d’expiration de la carte n’est pas valide." 7 | invalid_expiry_year: "L’année d’expiration de la carte n’est pas valide." 8 | invalid_cvc: "Le code de sécurité de la carte n’est pas valide." 9 | expired_card: "La carte a expiré." 10 | incorrect_cvc: "Le code de sécurité de la carte est incorrect." 11 | incorrect_zip: "La validation du code postal de la carte a échoué." 12 | card_declined: "La carte a été refusée." 13 | missing: "Aucun client associé à cette carte" 14 | processing_error: "Une erreur est survenue lors du contrôle de la carte." 15 | rate_limit: "Une erreur est survenue en raison d'un trop grand nombre de requêtes vers le serveur. Veuillez nous contacter si vous rencontrez cette erreur systématiquement." 16 | -------------------------------------------------------------------------------- /rails/locale/es.yml: -------------------------------------------------------------------------------- 1 | es: 2 | stripe: 3 | errors: 4 | incorrect_number: "El número de tarjeta es incorrecto." 5 | invalid_number: "El número de tarjeta no es válido." 6 | invalid_expiry_month: "El mes de vencimiento de la tarjeta no es válido." 7 | invalid_expiry_year: "El año de vencimiento de la tarjeta no es válido." 8 | invalid_cvc: "El código de seguridad de la tarjeta no es válido." 9 | expired_card: "La tarjeta está vencida." 10 | incorrect_cvc: "El código de seguridad de la tarjeta es incorrecto." 11 | incorrect_zip: "La verificación del código postal de la tarjeta falló." 12 | card_declined: "La tarjeta fue rechazada." 13 | missing: "No existe una tarjeta asociada al cliente al que se le está cobrando." 14 | processing_error: "Ocurrió un error mientras se procesaba la tarjeta." 15 | rate_limit: "Ocurrió un error debido a las solicitudes que llegan a IPA muy rápido. Háganos saber si este error se le presenta de manera constante." 16 | -------------------------------------------------------------------------------- /rails/locale/nl.yml: -------------------------------------------------------------------------------- 1 | nl: 2 | stripe: 3 | errors: 4 | incorrect_number: "Het nummer van uw creditcard is niet correct." 5 | invalid_number: "Dit is geen geldig creditcardnummer." 6 | invalid_expiry_month: "De vervaldatum van uw creditcard is ongeldig." 7 | invalid_expiry_year: "Het jaar waarop de creditcard vervalt is ongeldig." 8 | invalid_cvc: "De veiligheidscode van de creditcard is invalid." 9 | expired_card: "De creditcard is verlopen." 10 | incorrect_cvc: "De veiligheidscode van de creditcard is niet correct." 11 | incorrect_zip: "De postcode van de creditcard werd niet herkend." 12 | card_declined: "De creditcard werd geweigerd." 13 | missing: "Dit kaartnummer hoort niet bij een van onze huidige klanten." 14 | processing_error: "Er is een fout opgetreden bij het verwerken van de creditcard." 15 | rate_limit: "Er is een fout opgetreden vanwege het feit dat er te snel teveel verzoeken via de API binnenkomen. Laat ons a.u.b. weten als je stelselmatig tegen deze fout aanloopt." 16 | -------------------------------------------------------------------------------- /LICENSE.txt: -------------------------------------------------------------------------------- 1 | Copyright (c) 2015 Eric Koslow 2 | 3 | MIT License 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining 6 | a copy of this software and associated documentation files (the 7 | "Software"), to deal in the Software without restriction, including 8 | without limitation the rights to use, copy, modify, merge, publish, 9 | distribute, sublicense, and/or sell copies of the Software, and to 10 | permit persons to whom the Software is furnished to do so, subject to 11 | the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be 14 | included in all copies or substantial portions of the Software. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 19 | NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE 20 | LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION 21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION 22 | WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 23 | -------------------------------------------------------------------------------- /stripe-i18n.gemspec: -------------------------------------------------------------------------------- 1 | # coding: utf-8 2 | lib = File.expand_path('../lib', __FILE__) 3 | $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib) 4 | require 'stripe_i18n/version' 5 | 6 | Gem::Specification.new do |spec| 7 | spec.name = "stripe-i18n" 8 | spec.version = StripeI18n::VERSION 9 | spec.authors = ["Eric Koslow", "Spencer Bell"] 10 | spec.email = ["ekoslow@gmail.com", "spencer@teespring.com"] 11 | spec.summary = %q{Ruby i18n translations for Stripe error messages.} 12 | spec.description = %q{Currently supports German (de), French (fr), Italian (it), Dutch (nl), Spanish (es), and Brazilian Portuguese (pt-BR)} 13 | spec.homepage = "" 14 | spec.license = "MIT" 15 | 16 | spec.files = `git ls-files -z`.split("\x0") 17 | spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) } 18 | spec.test_files = spec.files.grep(%r{^(test|spec|features)/}) 19 | spec.require_paths = ["lib"] 20 | spec.required_ruby_version = ">= 2.2.2" 21 | 22 | spec.add_runtime_dependency('i18n', '~> 0.6') 23 | spec.add_runtime_dependency('railties', '>= 4.0') 24 | 25 | spec.add_development_dependency "rspec-rails", "= 2.14.2" 26 | spec.add_development_dependency "i18n-spec", "= 0.4.0" 27 | spec.add_development_dependency 'spork', '~> 1.0rc' 28 | spec.add_development_dependency "bundler", "~> 1.7" 29 | spec.add_development_dependency "rake", "~> 10.0" 30 | end 31 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | StripeI18n 2 | ========== 3 | 4 | [![Build 5 | Status](https://secure.travis-ci.org/ekosz/stripe-i18n.png)](http://travis-ci.org/ekosz/stripe-i18n) 6 | 7 | The gem adds a collection of translated error strings for `Stripe::CardError`. 8 | 9 | **ARCHIVED** 10 | 11 | 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! 12 | 13 | **Supported Locales:** 14 | 15 | 1. en (English - US) 16 | 1. es (Spanish) 17 | 1. de (German) 18 | 1. fr (French) 19 | 1. it (Italian) 20 | 1. nl (Dutch) 21 | 1. pt-BR (Portuguese - Brazil) 22 | 1. ru (Russian) 23 | 1. nb (Norwegian) 24 | 1. ja (Japanese) 25 | 1. zh-HK (Chinese - Hong Kong) 26 | 27 | ## Installation 28 | 29 | Add this line to your application's Gemfile: 30 | 31 | ```ruby 32 | gem 'stripe-i18n' 33 | ``` 34 | 35 | And then execute: 36 | 37 | $ bundle 38 | 39 | Or install it yourself as: 40 | 41 | $ gem install stripe-i18n 42 | 43 | ## Usage 44 | 45 | Use the code on the error object (`Stripe::CardError`) to get the correct 46 | translation key. 47 | 48 | ```ruby 49 | def charge_token(token, amount) 50 | Stripe::Charge.create( 51 | amount: amount, 52 | currency: 'usd', 53 | card: token, 54 | ) 55 | 56 | { success: true, msg: I18n.translate('charge.success') } 57 | rescue Stripe::CardError => e 58 | { success: false, msg: I18n.translate("stripe.errors.#{e.code}") } 59 | end 60 | ``` 61 | 62 | ## Contributing 63 | 64 | 1. Fork it ( https://github.com/ekosz/stripe-i18n/fork ) 65 | 2. Create your feature branch (`git checkout -b my-new-feature`) 66 | 3. Commit your changes (`git commit -am 'Add some feature'`) 67 | 4. Push to the branch (`git push origin my-new-feature`) 68 | 5. Create a new Pull Request 69 | --------------------------------------------------------------------------------