I need to localize a gem. The gem does process text. While processing the text it is listening for different words like Friday or Next Week. Now I want to listen it for translations too, like Freitag and Nächste Woche.
Do I just need to create the yaml files and use the t method in the ruby classes? Or is there a better way to do this?
Thank you guys!
Related
I'm trying to automate my database population with sample objects, so I use rake tasks. I would like to use some data from other website pages.
I created txt file with url list from where that information supposed to be read and ran into problem: I don't know how to make requests outside from rake task. I need to get response, extract some selectord as RSPEC allows to do. Thank you, guys!
For custom rake tasks, you can always create your own plugin. Refer rails guide - plugins section.
In the plugin, you can use get method to get the data from an external URL. Refer ActionDispatch::Integration::RequestHelpers methods for the details.
You can add your own extraction logic and seed the database.
I wanna to add to my blog a counter for displaying, how many times was an article displayed. I would like to solve it through ruby (not GA or something like that).
Is available any gem that do this task (also with checking IP address and the time of latest reading of article) or I have to implement by myself?
There's one used by thousands of people at http://www.seologic.com/webmaster-tools/counters. Source code is available at https://github.com/ivanoblomov/hit_counter.
Rails 3.0.5
gem 's3_swf_upload', :git => 'git://github.com/nathancolgate/s3-swf-upload-plugin'
gem 'aws-s3'
gem 'awk-sdk'
gem "paperclip", :git => "git://github.com/thoughtbot/paperclip.git"
This is a "is it possible and how hard is it" question. I had a requirement to take in video submission to a website and store them on Amazon S3. Originally I was going to do this via paperclip. However, some one made me aware that we may eat up all our dinos since the file would first be uploaded to our app on heroku first.
Instead I went with the GEM s3-swf-upload-plugin. This is supposed to by pass our server and upload using javascript and flash. (If I am wrong on this please let me know but so far it seems to work as expected.) However, as far as I can tell I can't rename the file with out a fair bit of javascript and I don't think I can collect the URL of the file to link in my object.
What I would like to do: After the file is uploaded and before I save my object I would like to go out to S3 find the file, use paperclip to move/rename it (Using it's useful :path => ":class/:id/:filename") and then assigning the typical paperclip attributes so that I can link to the video in my object.
I have search around a bit today (I admit I have not search as long as I usually do before I come here but my time to get this done is limited) and I all can find is how to set it up normally. The s3-swf-upload-plugin has something which I think may be doing exactly what I need but I don't understand it enough to fit it into my code. https://gist.github.com/575842
If the Gist above is what I need does any one mind explaining what the important part do so I might understand and modify it appropriately? If it is not what I need is there something out there that would help? Thank you all for any help you can provide.
I'm trying to write some tests for emails generated with a mailer class using rspec and email_spec (Ruby on Rails 3.0.7)
I would like to check if the layout used for rendering the email is the layout that was specified in the mailer class.
Any idea on how to do this? I've spent 3 hours searching for a solution but couldn't find anything.
Thanks!
(I realize this is a pretty late response. You've probably found a solution already)
I won't be able to update this answer much, but does this page help? It describes how to check if a layout was rendered. You could make a get request with parameters (example here) then check if the result renders the layout you want it to render.
This is cheating a little bit, since you're not really checking which template got generated...
However, I just wanted to perform a quick sanity check that the right email is (probably) being generated - so this was good enough for my needs:
# In RSpec:
expect(ActionMailer::Base.deliveries.last.subject)
.to eq I18n.t("name.of.email.subject")
# In MiniTest:
assert_equal I18n.t("name.of.email.subject"),
ActionMailer::Base.deliveries.last.subject
Can anyone provide me sample code to develop a struts i18n application containing two jsp pages with two buttons (a single toggle button) to switch b/t two languages?
I am a new to struts.
You can start with this link for some introductory info into internationalized messages then basically, for Struts i18n messages, you would use the <bean:message> tag. The Action class has a method you can use to set your desired locale in session scope and the message tags will pick it up from there.
There are plenty of examples you can find on the web (even if not as specific as you demanded :D). Maybe this article can get you started.
Download sample app from Struts site These sample application are packaged as WAR files. You can import HelloWorld.war from your eclipse and run index.jsp
You don't really need Struts to accomplish internationalization. You can use the JSTL formatting tags. You can use the fmt:bundle tag in your JSP to set the resource bundle to use. Basically a resource bundle is a collection of property files, one for each language that your application supports, that have a common base name. The fmt:message tag will print a message from the resource bundle based on a key. The last thing you need to do is to use the fmt:setLocale tag to actually set the locale (in other words, which of the resource files in the bundle to use) based on what language you want to display.
A good place to start is here:
http://docs.oracle.com/javaee/1.4/tutorial/doc/JSTL6.html