Comments (30)
I agree with this change, but take a look at my patch at http://github.com/joshk/paperclip which uses the proper namespacing for the errors. Currently it only supports I18n, but I will add in backward compatibility shortly.
from paperclip.
Ok, I have added backwards compatibility and checked to make sure all tests pass. I have also added two extra error message types for the attachment size validation. Any and all comments on my fork would be appreciated.
from paperclip.
Hi,
joshk, can you add i8n specific tests to your fork (something like what is in Peter's fork)?
We can pull your fork in once it has those tests.
from paperclip.
Hi cpytel,
Thanks for the message, I will get this working asap. Its a bit more complicated to test as I am using the active record errors.add which then uses generate_message to create a very detailed I18n.translate call.
Will let you know when i am finished.
Thanks
from paperclip.
Any news?
from paperclip.
Hi dmitry,
Although I created a patch for Paperclip, I need to start from scratch as I have found a bug or two which causes issues with valid? and errors. I hope to have this finished this week as work is a bit quieter now.
Sorry for the wait
Josh
from paperclip.
Thank you, Josh!
from paperclip.
Hi dmitry,
I have removed my old fork and started from scratch as my old enhancements did not seem clear and concise.
I have pushed a version which uses i18n for error messages, comes with a locale file, includes two extra message types for the size validations, and tests that i18n is being used. All tests pass and no functionality has been removed.
I still have to add backwards compatibility but I would love any and all feedback.
You can take a look at my fork here : http://github.com/joshk/paperclip
Thanks
Josh
from paperclip.
Hi Josh,
I've wrote some review comments. If you will need any more help, tell me.
Thanks,
Dmitry
from paperclip.
Hi Dmitry,
Thanks for the comments, I have commented on your comments and await further comment :)
Thanks
Josh
from paperclip.
Josh's account appears to be dead, is anyone working on this?
from paperclip.
I had problem when dynamically changing locale validator messages haven't changed. My solution to this is to use translation key symbol instead of text and let Rails pick translation according to current locale, like this:
validates_attachment_size :data, :less_than => Setting.max_upload_size, :message => :invalid_attachment_size
Add translation to I18n file:
en: activerecord: errors: messages: invalid_attachment_size: is over the limit. Please choose a different file.
This works with validates_attachment_presence, validates_attachment_content_type. Current Paperclip throws an exception if you pass a symbol to validates_attachment_size. That's because size validator does some string replacement to inform user about min/max sizes.
I created a tiny patch to fix it, hopefully it will get merged into Paperclip:
http://github.com/laurynas/paperclip/commit/82120eb009573b121568ecb2dc0a948486d3104e
from paperclip.
What''s the status on this? did it merge?
from paperclip.
I think it didn't merge. I also got one tip by email from Maciej M. regarding to this that could be useful for the others:
however some coders (such as me) use smhtg like that:
lambda{I18n.t('activerecord.errors.messages.paperclip.size', {:min => 20, :max => "#{MAX_SIZE} KB"})}
To make paperclip work with different languages.
Your solution does not allow passing parameters to messages, "wrong size" is not the best msg ;)
"wrong size (up to 200kb)" looks better.
Fix is simple. Before your patch, you need to add:
message = message.call if message.is_a?(Proc)
And then you can use syntax with "lambda"
from paperclip.
Any update on this? Why it's not merged yet?
For me the solution can use the default Rails behavior to interpolate value in yml. Like:
en:
paperclip:
errors:
attachment:
size: "must be between %{min} and %{max} bytes."
content_type: "Unsupported content type"
presence: "Cant' be blank"
I would like to work on this problem but I need to know what the authors of the gem think about.
from paperclip.
I Totally agree Daniel, why isn't this merged yet? Loads of good solutions starting from 2009. I love paperclip, but it's a real issue for me that i18n isn't supported properly (like almost any other gem does).
from paperclip.
I Totally agree Daniel, why isn't this merged yet? Loads of good solutions starting from 2009. I love paperclip, but it's a real issue for me that i18n isn't supported properly (like almost any other gem does).
from paperclip.
Any update?
from paperclip.
"Still waiting for I18n support" is really rather rude don't you think?
While I usually don't usually this kind of reply I think it is merited here:
This is an open-source project for which you have paid nothing, while the owners of FOSS projects usually do their best to keep things updated they are not beholden to you to do it.
If you need I18n THAT badly and cannot wait for it to be merged then you can always use a fork which has the functionality you need or make your own fork and apply the functionality.
from paperclip.
Sorry @rurounijones but this was what I said in my comment. I already fixed in my own projects but I would like to help the paperclip and make the solution more elegant.
But I need to know why the core of the project don't want to merge the code. I'll not waste time to create a fork and start to have another gem.
from paperclip.
My apologies @danielvlopes (Just learned about the @!) my comment was not directed at you but at @maxx11 . I should have been clearer
from paperclip.
Just wanted to agree with @danielvlopes, sorry for any inconvenience.
from paperclip.
Hi everyone, unfortunately @joshk's fork is no longer available. @joshk, any chance you should have this so I can merge it in? I'm sorry for the delay everyone, we'd definitely like to merge this in if we can get it.
from paperclip.
Any update on this?
from paperclip.
Must be faster to rewrite it than to wait for @joshk.
from paperclip.
Hey Guys,
I am sorry for my lack of reply on this matter.
A lot has changed in paperclip since my fork, but I do believe I still have it floating around on my comp.
I think it would be best to rewrite then to take my changes as I was unable to test my changes against a pre-i18n ActiveRecord (since PC is now tested on Travis against different Gemfile configs, this is no longer the case).
I would volunteer to help with adding this, but I am too swamped with Travis-CI work at the moment, sorry.
Let me know if there is anything else I can help with,
J
from paperclip.
:(
from paperclip.
Since this is such an old ticket, I'm going to close it. @joshk is still swamped with work and so can't redo his work. If someone else wants to code this up so that it can be merged into master and submit a pull request, I'd really appreciate it.
from paperclip.
@danielvlopes, @brunomac: "I Totally agree". As a simple utilizer of the Paperclip gem I really would like to have full support for the I18n gem, but I am not so expert and encouraged to solve the problem (that is, to fork the gem) my self.
I would appreciate if the Official Paperclip gem will support the I18n gem.
See also: http://stackoverflow.com/questions/11963146/how-to-properly-translate-paperclip-error-messages
from paperclip.
@jyurek @joshk is this support? I only see support for :blank and :spoofed_media_type 😢
from paperclip.
Related Issues (20)
- Upload file apk to s3 HOT 1
- AWS::S3::Errors::NoSuchKey No Such Key
- Directly inheriting from ActiveRecord::Migration is not supported. Please specify the Rails release the migration was written for: HOT 3
- How to store original in different storage bucket?
- PaperClip 2.8 - Rails 2.3 - Ruby 1.87 - OpenSSL::SSL::SSLError (SSL_read:: shutdown while in init): HOT 2
- With Ruby 3.0 validator produces "ArgumentError: wrong number of arguments (given 3, expected 1..2)" HOT 6
- Paperclip mimemagic dependency licensing implication HOT 11
- Transfer ownership of gem to Kreeti HOT 3
- Generate s3 bucket key from DB records
- Migrate to ActiveStorage without re-uploading files?
- default_url is always hit with a HTTP request
- Paperclip::AdapterRegistry::NoHandlerError:
- "attachment" type migration error in Rails 7 HOT 5
- Uploading same attachment twice.
- Uploading same attachment twice fails until i refresh the ui after first upload.
- *_file_name attribute without extension
- Webp image upload issue HOT 2
- use file -b --mime 'test.json' have problem in AWS linux 2
- ContentTypeDetector false positive from Mime HOT 1
- s3 deprecating TLS 1.1 and moving to default TLS 1.2
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 paperclip.