Ruby on rails internationalization for Spanish - ruby-on-rails

I'm creating a fast application with ruby on rails, and after doing a lot of scaffolding and validation I'm very happy with some of the features that are embeded in RoR... but I live in Mexico and all my users would love the application to be in Spanish of course. So, I noticed theres a lot of functions that write actual text in English for example time_ago_in_words and all the errors produced by the scaffolding and validation.
Before actually doing those things on my own (like I would in php for example) I wanted to know if theres some kind of language file I could edit (or even download one in Spanish). After all, the books I'm reading and the tutorials (and webcast) I'm following to learn this new framework are all in English (and fail to include this problem).

Here you can find a nice sample app which demonstrates some basics of i18n (internationalization features) in Rails.

This guide contains the most recent work on internationalization. A pretty decent reference:
http://guides.rails.info/i18n.html

Related

Getting more Ruby On Rails Helpers

I am completely new on Ruby On Rails and I already watched a long tutorial to start developing a small web application. In such a tutorial I could see several helpers for textboxes, textareas, dates, times, checkboxes, radiobuttons, comboboxes, and so on.
Where can I find other helpers like accordions, WYSIWYG editors (like an HTML editor), and others that can be bound to data from model and used in views? Maybe a toolbox for example.
I will very much appreciate your feedback.
Best regards.
What you're mostly talking about are Form Helpers. There are a bunch of other Rails Guides so I'd recommend reading through them and getting a better idea of what Rails does and can provide.
If you're not finding what you need in that documentation, you may need to add a 3rd party gem to your app's Gemfile, and follow the gem's documentation for getting it working. The Ruby Toolbox is a good place to start searching if you want to see which gems are most common.
And, of course, in the end you might not be able to find something that someone else already wrote and that solves your problem, in which case you will need to write it yourself. For front-end stuff you'll want to get up to speed on how to use HTML, CSS, and Javascript.

How is it possible to use RoR for front-end?

I was reading an article titled The Secret Behind Twitter's Growth, and I noticed something that made me a little confused:
The third paragraph which gives some background began with this:
"The popular Web programming language Ruby on Rails is responsible for the look and feel of Twitter’s user interface..."
Now, I know that RoR is for back-end development, so how is it possible to use it in the user interface aka the “front end”?
link to the article: https://www.technologyreview.com/s/412834/the-secret-behind-twitters-growth/
You can display data from your database in your views.
You can use ERB(embedded ruby) inside of your HTML to display cool ruby coded front end stuff (the current date for example).
You can use all kinds of cool gems like(pagination) which sorts long lists into multiple pages etc.
And also; Ruby On Rails is not just backend, it's a framework where you can use practically any front-end languages/tools(Javascript, Coffeescript, HTML5, CSS, XML, AJAX, Angular.js, React.js, SCSS, LESS, you name the rest) aswell.
In short; The list is endless, you can do a lot to improve the user experience.
If you are really interested in this exact stuff, you can read the book 'The Ruby On Rails Tutorial' by Michael Hartl where you can build a copy of the Twitter website along with him. Then you will see exactly how Ruby on Rails helps improve the user experience. And you will learn a lot aswell :)

Apply I18 to Ruby on Rails Completed Site.

I am new to Internationalization(I18). I want to apply I18 to my Ruby on Rails site but the problem is site is already complete and I don't want to go to each HTML page change the code. I want my site in English, French, and Spanish language.
Please show me the way and I appreciate any example or tutorial for I18.
Thanks.
Unless the development team on your inherited site had future-I18n on their mind when they made the site (e.g. strings are not hardcoded but reference values found in config/locales/en.yml using the I18n.translate method), then you will have no choice but to go in and change every file that uses strings you want to translate.
I'm sure you've already found the following references, but just in case, you should probably start with these:
Rails I18n guide
Rails I18n Railscast
Rails I18n backends Railscasts
Other Rails I18n questions on StackOverflow
As #Dougui pointed out, you probably have a fair amount of work ahead of you.
Sorry but I think there is no way to do this. It's just a very long work... Good luck!

Extracting a Rails application into a plugin or engine

I have a Rails 2.3 application which I would like to extract into a plugin, or engine. The application has user authentication, and basic cms capabilities supported by ancestry plugin.
I want to extract the logic for the application into a plugin/engine so that I can use this code for future projects, with a different "skin" or "theme" if required.
I'm not entirely sure I actually understand the difference between plugin and engine concepts, so that would be a good first point.
What is the best approach, are there any good starting points, links, explanations, examples that I should follow. Also, with the release of R3 to consider, is there anything that I should be aware of for that, with regards to plugins etc.
I am going to start off by watching Ryan's http://railscasts.com/episodes/149-rails-engines
but obviously thats over a year old now, so one of the challenges I'm faced with is finding the most up to date and relevant information on this subject.
All tips and help gratefully received.
Actually, converting an application is pretty straigtforward. Just create a plugin-folder, put an app-folder inside containing all yor model-views-controllers folders, and that's it.
You will have to manage your migrations yourself though. Also you have to define rake-tasks to copy files to your public folder. I think the railscasts is still pretty up-to-date, if anything it is now easier in rails 2.3.
Good luck!
[EDIT: for rails3] Rails 3 engines are very clean and powerful. Check this gist by Jose Valim.
You will probably be better off focusing your engine on Rails 3, as opposed to trying to make it compatible for Rails 2 and Rails 3, due to the backwards incompatible changes. Here is a more up to date tutorial for Rails 3
also the book "Crafting Rails applications" by Rails Core member Jose Valim, has a good chapter on it. Int he shows how to use his tool EngineX which generates a Rails 3 engine structure, so you can more easily create engines for your Rails 3 projects. His gem devise is also a rails engine which is also nice, because you can easily customize it by copying the templates into the application directory, and allowing you to subclass the controllers that you want to customize more.
Writing a plugin is an entirely different process than writing an app, if you already have your app code it should be straightforward converting it into a plugin.
Consider that if you use third-party plugins in your app it could get pretty messy.

Implementing globalization in Rails

While I have experience developing Rails apps in English, I am a blank slate when it comes to handling globalization, so please don't shoot me in the head if my question 'doesn't make sense' :)
I have been asked to add multi language feature to a part of a Rails app that I am working on. Initially its only going to be 2 languages, French and German. The content that will be translated (which is in English now) is rendered using partials at the moment hence I am getting a bit inclined on creating partials with different languages and then based on the users language selection call the relevant partial - Would you recommend this approach?
Although it seems a heavy weight solution for this particular purpose, but I am also looking at the Rails Globalize plugin. This seems to appeal if I look at the long term gains, something like what if later I am asked to translate the entire app.
Any insights on what would be a proper structured approach to handle globalization in Rails?
Many Thanks
Have you had a look at the i18n (internationalization) API that is in Rails itself as of 2.2? It makes it easy to store your language translation files as .yml files, so a fr.yml and a de.yml or whatever. It also steps through different approaches of making languages accessible via browser prefs, or URLs, subdomains, etc. In your HTML template files you use symbols to specify the keys for the string you've translated. At least in my basic usage and testing, it was very easy to work with.
I preffer using translator instead of Rail's i18n, since the former handles "scoping of translation" automatically. I recommend you give it a look.
This is a great article on how to use Ruby's GetText to localise you Rails App.

Resources