-
Notifications
You must be signed in to change notification settings - Fork 413
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
85 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative '../../test_helper' | ||
require 'rails-i18n' | ||
require_relative '../../mock_helpers/app' # load after the extra | ||
|
||
###### Pagy initializer block ########### | ||
# module LocalizePagyCalendar | ||
# def localize(...) = ::I18n.l(...) | ||
# end | ||
# Pagy::Offset::Calendar::Unit.prepend LocalizePagyCalendar | ||
# module LocalizePagyCalendar | ||
# def localize(...) = ::I18n.l(...) | ||
# end | ||
Pagy::Offset::Calendar::Unit.prepend(Module.new { def localize(...) = I18n.l(...) }) | ||
|
||
path = Pathname.new(Gem.loaded_specs['rails-i18n']&.full_gem_path) | ||
I18n.load_path += %i[en de].map { |locale| path.join("rails/locale/#{locale}.yml") } | ||
######################################### | ||
|
||
Time.zone = 'EST' | ||
Date.beginning_of_week = :sunday | ||
|
||
## Test not needed: Now it's a manual patch in the pagy.rb initializer | ||
describe 'Calendar with I18n.l' do | ||
it 'works in :en' do | ||
pagy = Pagy::Offset::Calendar.send(:create, :month, | ||
period: [Time.zone.local(2021, 10, 21, 13, 18, 23, 0), | ||
Time.zone.local(2023, 11, 13, 15, 43, 40, 0)], | ||
page: 3, format: '%B, %A') | ||
_(pagy.label).must_equal "December, Wednesday" | ||
_(pagy.label(locale: :de)).must_equal "Dezember, Mittwoch" | ||
_(pagy.label(format: '%b')).must_equal "Dec" | ||
_(pagy.label(format: '%b', locale: :de)).must_equal "Dez" | ||
_(pagy.label(page: 5)).must_equal "February, Tuesday" | ||
_(pagy.label(page: 5, locale: :de)).must_equal "Februar, Dienstag" | ||
I18n.locale = :de | ||
_(pagy.label).must_equal "Dezember, Mittwoch" | ||
_(pagy.label(format: '%b')).must_equal "Dez" | ||
_(pagy.label(page: 5)).must_equal "Februar, Dienstag" | ||
_(pagy.label(page: 5, format: '%b')).must_equal "Feb" | ||
I18n.locale = :en | ||
end | ||
end |
4 changes: 2 additions & 2 deletions
4
test/pagy/extras/i18n/extra_test.rb → test/pagy/extras/i18n_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.