I18n

This PR implements a basic set up for abstracting content in the views into a central locale file so that translating the site into other languages will be feasible in the future.

There are at least a few considerations to make before merging this:

1. How should we indicate the current locale in the URL? At first, we (@oshiho3, @macckii and me) decided to scope all routes to the locale parameter so that urls would look like this: http://growstuff.org/en. However, that predictably broke a lot of tests. So we ended up opting for a simple query parameter that looks like this: http://growstuff.org/?locale=en. It's a bit cumbersome but it should work for the time being. The locale parameter is totally optional and defaults to **en**, so no one's bookmarks will get jacked up.

2. The organization of the locale files should definitely be considered carefully. I've followed the view directory structure, which seems relatively uncontroversial, but there are some differing schools of thought on this. I'd recommend checking out this [SO thread](http://stackoverflow.com/questions/10282857/how-do-you-structure-i18n-yaml-files-in-rails). Additionally, this thread offers a pretty [convincing refutation](http://stackoverflow.com/questions/11097572/refactoring-ruby-on-rails-i18n-yaml-files-using-dictionaries) of drying up your locale files with a dictionary.

3. Since we're passing in the links that may be contained within each translation key to the translate method, these method calls get a bit long. I couldn't find a way to format the code to make it readable because of Haml's significant white space. Very open to suggestions on that one.

We added a Japanese locale file but only for the purpose of testing changing the locale.


Huh! Well I guess we will probably get more in due course :)

I wonder whether we could override have_link to automatically add the 
locale?

On 24/09/2014 6:35 pm, Taylor Griffin wrote:
>
> In spec/features/crop_wranglers_spec.rb:
>
> > @@ -19,7 +19,7 @@
> >        within '.crop_wranglers' do
> >          expect(page).to have_content 'Crop Wranglers:'
> >          crop_wranglers.each do |crop_wrangler|
> > -          page.should have_link crop_wrangler.login_name, :href => member_path(crop_wrangler)
> > +          page.should have_link crop_wrangler.login_name, :href => member_path(crop_wrangler, {locale: 'en'})
>
> Hmm... This is the only use of the |have_link| matcher checking 
> against an internal link. It makes sense that the |have_link| matcher 
> would require the query param because the locale is automatically 
> added to every url thanks to this method in ApplicationController:
>
> |def default_url_options(options={})
>    { locale: I18n.locale }
> end
> |
>
> —
> Reply to this email directly or view it on GitHub 
> <https://github.com/Growstuff/growstuff/pull/417/files#r17959529>.
>

-- 
Alex "Skud" Bayley
skud@growstuff.org
http://growstuff.org/