stripe-i18n 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4ddc6b9bb06026c6fdf68f038bd602629845492d
4
+ data.tar.gz: 650bee3076d4ddc4c29b1d3f30401602b45a7a3f
5
+ SHA512:
6
+ metadata.gz: 3bd071d6c527a2488f3e249093c0f5896e094b7056bd82c22ae5faa781c9b8d748e6efffd1dc3e6f2e77f5eb5c32633fde3098096985ef0892fce9227f811fa4
7
+ data.tar.gz: 4ba5637f1d1f98ecab2d9b8ca880b98318d9a02ab23643e7482b958bddc5984dc3795d4043be571cd7643586903f056d41fc6fcaa4b64b8b6940c3c829c82bb9
data/.gitignore ADDED
@@ -0,0 +1,14 @@
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
data/.travis.yml ADDED
@@ -0,0 +1,5 @@
1
+ language: ruby
2
+ rvm:
3
+ - 1.9.3
4
+ - 2.0.0
5
+ - 2.1
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in stripe-i18n.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
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.
data/README.md ADDED
@@ -0,0 +1,54 @@
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
+ **Supported Locales:**
10
+
11
+ 1. en
12
+
13
+ ## Installation
14
+
15
+ Add this line to your application's Gemfile:
16
+
17
+ ```ruby
18
+ gem 'stripe-i18n'
19
+ ```
20
+
21
+ And then execute:
22
+
23
+ $ bundle
24
+
25
+ Or install it yourself as:
26
+
27
+ $ gem install stripe-i18n
28
+
29
+ ## Usage
30
+
31
+ Use the code on the error object (`Stripe::CardError`) to get the correct
32
+ translation key.
33
+
34
+ ```ruby
35
+ def charge_token(token, amount)
36
+ Stripe::Charge.create(
37
+ amount: amount,
38
+ currency: 'usd',
39
+ card: token,
40
+ )
41
+
42
+ { success: true, msg: I18n.translate('charge.success') }
43
+ rescue Stripe::CardError => e
44
+ { success: false, msg: I18n.translate("stripe.errors.#{e.code}") }
45
+ end
46
+ ```
47
+
48
+ ## Contributing
49
+
50
+ 1. Fork it ( https://github.com/ekosz/stripe-i18n/fork )
51
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
52
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
53
+ 4. Push to the branch (`git push origin my-new-feature`)
54
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,9 @@
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
@@ -0,0 +1 @@
1
+ require 'stripe_i18n'
@@ -0,0 +1,5 @@
1
+ require "stripe_i18n/version"
2
+ require "stripe_i18n/railtie"
3
+
4
+ module StripeI18n
5
+ end
@@ -0,0 +1,25 @@
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
@@ -0,0 +1,3 @@
1
+ module StripeI18n
2
+ VERSION = "1.0.0"
3
+ end
@@ -0,0 +1,15 @@
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."
@@ -0,0 +1,15 @@
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."
@@ -0,0 +1,15 @@
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."
@@ -0,0 +1,15 @@
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: "Il n’y a pas de carte associée à un client don’t le debit est en cours."
14
+ processing_error: "Une erreur est survenue lors du contrôle de la carte."
15
+ rate_limit: "Une erreur est survenue en raison de requêtes atteignant trop rapidement l’interface de programmation. Veuillez svp nous informer si vous rencontrez cette erreur systématiquement."
@@ -0,0 +1,15 @@
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."
@@ -0,0 +1,15 @@
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."
@@ -0,0 +1,15 @@
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."
@@ -0,0 +1,19 @@
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
@@ -0,0 +1,10 @@
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
@@ -0,0 +1,26 @@
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
@@ -0,0 +1,7 @@
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
@@ -0,0 +1,28 @@
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"]
10
+ spec.email = ["ekoslow@gmail.com"]
11
+ spec.summary = %q{Ruby i18n translations for Stripe error messages.}
12
+ spec.homepage = ""
13
+ spec.license = "MIT"
14
+
15
+ spec.files = `git ls-files -z`.split("\x0")
16
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
17
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
18
+ spec.require_paths = ["lib"]
19
+
20
+ spec.add_runtime_dependency('i18n', '~> 0.6')
21
+ spec.add_runtime_dependency('railties', '~> 4.0')
22
+
23
+ spec.add_development_dependency "rspec-rails", "= 2.14.2"
24
+ spec.add_development_dependency "i18n-spec", "= 0.4.0"
25
+ spec.add_development_dependency 'spork', '~> 1.0rc'
26
+ spec.add_development_dependency "bundler", "~> 1.7"
27
+ spec.add_development_dependency "rake", "~> 10.0"
28
+ end
metadata ADDED
@@ -0,0 +1,168 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: stripe-i18n
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Eric Koslow
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-04-13 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: i18n
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ~>
18
+ - !ruby/object:Gem::Version
19
+ version: '0.6'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ~>
25
+ - !ruby/object:Gem::Version
26
+ version: '0.6'
27
+ - !ruby/object:Gem::Dependency
28
+ name: railties
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ~>
32
+ - !ruby/object:Gem::Version
33
+ version: '4.0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ~>
39
+ - !ruby/object:Gem::Version
40
+ version: '4.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rspec-rails
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - '='
46
+ - !ruby/object:Gem::Version
47
+ version: 2.14.2
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - '='
53
+ - !ruby/object:Gem::Version
54
+ version: 2.14.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: i18n-spec
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - '='
60
+ - !ruby/object:Gem::Version
61
+ version: 0.4.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - '='
67
+ - !ruby/object:Gem::Version
68
+ version: 0.4.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: spork
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - ~>
74
+ - !ruby/object:Gem::Version
75
+ version: 1.0rc
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - ~>
81
+ - !ruby/object:Gem::Version
82
+ version: 1.0rc
83
+ - !ruby/object:Gem::Dependency
84
+ name: bundler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ~>
88
+ - !ruby/object:Gem::Version
89
+ version: '1.7'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - ~>
95
+ - !ruby/object:Gem::Version
96
+ version: '1.7'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ~>
102
+ - !ruby/object:Gem::Version
103
+ version: '10.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ~>
109
+ - !ruby/object:Gem::Version
110
+ version: '10.0'
111
+ description:
112
+ email:
113
+ - ekoslow@gmail.com
114
+ executables: []
115
+ extensions: []
116
+ extra_rdoc_files: []
117
+ files:
118
+ - .gitignore
119
+ - .travis.yml
120
+ - Gemfile
121
+ - LICENSE.txt
122
+ - README.md
123
+ - Rakefile
124
+ - lib/stripe-i18n.rb
125
+ - lib/stripe_i18n.rb
126
+ - lib/stripe_i18n/railtie.rb
127
+ - lib/stripe_i18n/version.rb
128
+ - rails/locale/de.yml
129
+ - rails/locale/en.yml
130
+ - rails/locale/es.yml
131
+ - rails/locale/fr.yml
132
+ - rails/locale/it.yml
133
+ - rails/locale/nl.yml
134
+ - rails/locale/pt-BR.yml
135
+ - spec/integration/translation_spec.rb
136
+ - spec/spec_helper.rb
137
+ - spec/support/fake_app.rb
138
+ - spec/unit/translation_spec.rb
139
+ - stripe-i18n.gemspec
140
+ homepage: ''
141
+ licenses:
142
+ - MIT
143
+ metadata: {}
144
+ post_install_message:
145
+ rdoc_options: []
146
+ require_paths:
147
+ - lib
148
+ required_ruby_version: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '>='
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ required_rubygems_version: !ruby/object:Gem::Requirement
154
+ requirements:
155
+ - - '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ requirements: []
159
+ rubyforge_project:
160
+ rubygems_version: 2.4.5
161
+ signing_key:
162
+ specification_version: 4
163
+ summary: Ruby i18n translations for Stripe error messages.
164
+ test_files:
165
+ - spec/integration/translation_spec.rb
166
+ - spec/spec_helper.rb
167
+ - spec/support/fake_app.rb
168
+ - spec/unit/translation_spec.rb