Comments (5)
I think this has been fixed by #71, could you confirm @juno?
from date_validator.
@oriolgual
Thank you for notifying.
I confirmed that the issue still exists with latest master
branch 9df6740. 😢
This issue blocks a technique like an extracting locale from tld/params/etc which mentioned in Rails Guide:
# This line returns parsed_locale if it defined in data_validator's locale files
I18n.available_locales.map(&:to_s).include?(parsed_locale) ? parsed_locale : nil
# [1] pry(main)> I18n.available_locales
# => [:en, :ru, :ja, :af, :ca, :de, :es, :fr, :it, :nl, :pl, :"pt-BR", :tr]
# [2] pry(main)> I18n.locale_available?(:pl)
# => true
However, since we using 0.9.0 with a following workaround, there are no problems at this time.
available_locales = [:ja, :en]
available_locales.map(&:to_s).include?(parsed_locale) ? parsed_locale : nil
So, If it's OK with you, please close this issue. 👍
from date_validator.
Maybe we could change https://github.com/codegram/date_validator/blob/585cddda057edcf5409d7ba2d29c12ee947a5d7c/lib/date_validator/engine.rb so it only loads locales that are already available in the parent Rails app.
Something like this after line 4:
available_locales = I18n.available_locales.map(&:to_s)
files = files.select do |file|
locale_from_file = file.split("/").last.split(".").first
available_locales.include?(locale_from_file)
end
Could you patch your local gem and see if this solves it?
from date_validator.
Could you patch your local gem and see if this solves it?
Sure, I'll try it tomorrow.
from date_validator.
@oriolgual
Sorry for late reply.
I checked vanilla rails app with codegram/date_validator master branch & patch.
Unfortunately, patch doesn't seem to solve the problem.
How to reproduce
Create vanilla rails app with date_validator master (not yet patched):
$ rails -v
Rails 5.0.0.1
$ rails new TestApp --skip-bundle --skip-active-record
$ cd TestApp
$ echo "gem 'date_validator', github: 'codegram/date_validator'" >> Gemfile
$ bundle install --path vendor/bundle
I18n.available_locales
returns locales within date_validator gem:
$ rails console
Loading development environment (Rails 5.0.0.1)
irb(main):001:0> I18n.available_locales
=> [:en, :af, :ca, :de, :es, :fr, :it, :ja, :nl, :pl, :"pt-BR", :ru, :tr]
Apply patch and debug prints:
$ bundle open date_validator
# lib/date_validator/engine.rb
module DateValidator
class Engine < Rails::Engine
initializer 'date_validator' do
files = Dir[Pathname.new(File.dirname(__FILE__)).join('../../config', 'locales', '*.yml')]
available_locales = I18n.available_locales.map(&:to_s)
puts "*** available_locales: #{available_locales}"
files = files.select do |file|
locale_from_file = file.split("/").last.split(".").first
available_locales.include?(locale_from_file)
end
config.i18n.load_path += files
puts "*** config.i18n.load_path: #{config.i18n.load_path}"
end
end
end
I18n.available_locales
returns same results:
$ rails console
*** available_locales: ["en"]
*** config.i18n.load_path: ["/Users/juno/src/TestApp/vendor/bundle/ruby/2.3.0/gems/web-console-3.4.0/lib/web_console/locales/en.yml", "/Users/juno/src/TestApp/vendor/bundle/ruby/2.3.0/bundler/gems/date_validator-9df67409c49b/config/locales/en.yml"]
Loading development environment (Rails 5.0.0.1)
irb(main):001:0> I18n.available_locales
=> [:en, :af, :ca, :de, :es, :fr, :it, :ja, :nl, :pl, :"pt-BR", :ru, :tr]
from date_validator.
Related Issues (20)
- Need to check time is a valid time HOT 5
- Wrong type of error in different cases HOT 2
- time range HOT 1
- Update activemodel version dependency HOT 1
- Add way to check is a string is a valid date HOT 5
- Complain of missing translation HOT 7
- Fail to detect errors when invalid strings are provided HOT 1
- Not working in certain time zones HOT 3
- Differentiating between `blank` and `not_a_date` HOT 4
- I18n conflicts with Activemodel I18n HOT 4
- URL out of date in repository description HOT 1
- Rails 5 HOT 2
- Not really ORM-Agnostic HOT 2
- Is this gem still maintained ? HOT 2
- Add a changelog HOT 1
- Skip { after: :other_attribute } validation if other_attribute is nil HOT 1
- Proc in error details
- Validation doesn't work if the value is represented as a string
- Is there any way that I can make sure that ranges are exclusive?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from date_validator.