Skip to content

Commit

Permalink
Ship EN translations for the rodauth-i18n gem
Browse files Browse the repository at this point in the history
  • Loading branch information
janko committed Dec 14, 2022
1 parent 8071167 commit 565e84a
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 1 deletion.
2 changes: 2 additions & 0 deletions lib/rodauth/features/omniauth_base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def post_configure
self.class.send(:define_method, :omniauth_app) { omniauth_app }

self.class.roda_class.plugin :run_handler

i18n_register File.expand_path("#{__dir__}/../../../locales") if features.include?(:i18n)
end

def route!
Expand Down
4 changes: 4 additions & 0 deletions locales/en.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
en:
rodauth:
omniauth_failure_error_flash: There was an error logging in with the external provider
omniauth_login_unverified_account_error_flash: The account matching the external identity is currently awaiting verification
3 changes: 2 additions & 1 deletion rodauth-omniauth.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Gem::Specification.new do |spec|
spec.metadata["homepage_uri"] = spec.homepage
spec.metadata["source_code_uri"] = spec.homepage

spec.files = Dir["README.md", "LICENSE.txt", "*.gemspec", "lib/**/*"]
spec.files = Dir["README.md", "LICENSE.txt", "*.gemspec", "lib/**/*", "locales/**/*"]
spec.require_paths = ["lib"]

spec.add_dependency "rodauth", "~> 2.13"
Expand All @@ -28,4 +28,5 @@ Gem::Specification.new do |spec|
spec.add_development_dependency "net-smtp"
spec.add_development_dependency "capybara"
spec.add_development_dependency "jwt"
spec.add_development_dependency "rodauth-i18n"
end
17 changes: 17 additions & 0 deletions test/omniauth_base_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -475,4 +475,21 @@ def request_phase
visit "/auth/other"
assert_equal 404, page.status_code
end

it "has translations" do
rodauth do
enable :omniauth_base, :i18n
omniauth_provider :developer
omniauth_before_callback_phase do
omniauth_strategy.fail!(:some_error, KeyError.new("foo"))
end
end
roda do |r|
r.rodauth
r.root { view content: "" }
end

omniauth_login "/auth/developer"
assert_equal "There was an error logging in with the external provider", page.find("#error_flash").text
end
end
16 changes: 16 additions & 0 deletions test/omniauth_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -236,4 +236,20 @@
click_on "Confirm Password"
assert_equal "password", page.html
end

it "has translations" do
DB[:accounts].update(status_id: 1)

rodauth do
enable :omniauth, :i18n
omniauth_provider :developer
end
roda do |r|
r.rodauth
r.root { view content: "" }
end

omniauth_login "/auth/developer"
assert_equal "The account matching the external identity is currently awaiting verification", page.find("#error_flash").text
end
end

0 comments on commit 565e84a

Please sign in to comment.