Why locales are not in assets?

52 views
Skip to first unread message

Alexey

unread,
Apr 4, 2012, 3:54:10 PM4/4/12
to Ruby on Rails: Core
Why in a standard rails application locales are in config directory
and not in assets?

Ryan Bigg

unread,
Apr 4, 2012, 3:57:10 PM4/4/12
to rubyonra...@googlegroups.com
How are these files assets? They're not served to the end user, but are rather used by the backend to display information in different languages to the end-user, thereby making them configuration.

On Wednesday, 4 April 2012 at 2:54 PM, Alexey wrote:

Why in a standard rails application locales are in config directory
and not in assets?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To post to this group, send email to rubyonra...@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-co...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-core?hl=en.

Johnneylee Rollins

unread,
Apr 4, 2012, 4:00:44 PM4/4/12
to rubyonra...@googlegroups.com
This sounds like it could be more of a feature request than a complaint.

Compiling yaml files for translation (Or whatever store) down to maybe json for use might lend towards the more pro client-side views crowd. I haven't even thought out the implications of such a thing, but it might be really cool to do that.

~Johnneylee

Ryan Bigg

unread,
Apr 4, 2012, 4:05:46 PM4/4/12
to rubyonra...@googlegroups.com
That's quite an interesting twist on it. I never thought of doing it that way, but now it would make sense to be able to have these made available to client-side applications which can then use them to translate... but what are the translation libraries like on the client-side these days?

Carlos Antonio da Silva

unread,
Apr 4, 2012, 4:18:28 PM4/4/12
to rubyonra...@googlegroups.com
This library does exactly what you're talking about here: https://github.com/fnando/i18n-js

It's a small library to provide the I18n translations on the Javascript. It comes with Rails support.

It is for sure worth to take a look.

-- 
At.
Carlos Antonio

Alexey

unread,
Apr 4, 2012, 4:30:39 PM4/4/12
to rubyonra...@googlegroups.com
Maybe this was a stupid question and i do not understand what assets exactly are.  For me assets were things which are not Ruby code or user data, but on which the developer spends a lot of time.

Josh Susser

unread,
Apr 4, 2012, 5:25:26 PM4/4/12
to rubyonra...@googlegroups.com

On Wednesday, April 4, 2012 at 1:30 PM, Alexey wrote:

Maybe this was a stupid question and i do not understand what assets exactly are.  For me assets were things which are not Ruby code or user data, but on which the developer spends a lot of time.

Assets are things that are embedded in a web page and get downloaded by the browser. This includes images (JPGs, PNGs), javascript files, CSS files, flash movies, mp3s, etc. Since locales are used only by the server and not downloaded by the browser, they are server configuration, not assets.




 
On Wednesday, April 4, 2012 9:57:10 PM UTC+2, Ryan Bigg wrote:
How are these files assets? They're not served to the end user, but are rather used by the backend to display information in different languages to the end-user, thereby making them configuration.


--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/KxrC7em_agcJ.

Alexey

unread,
Apr 4, 2012, 5:34:18 PM4/4/12
to rubyonra...@googlegroups.com


On Wednesday, April 4, 2012 11:25:26 PM UTC+2, Josh Susser wrote:

On Wednesday, April 4, 2012 at 1:30 PM, Alexey wrote:

Maybe this was a stupid question and i do not understand what assets exactly are.  For me assets were things which are not Ruby code or user data, but on which the developer spends a lot of time.

Assets are things that are embedded in a web page and get downloaded by the browser. This includes images (JPGs, PNGs), javascript files, CSS files, flash movies, mp3s, etc. Since locales are used only by the server and not downloaded by the browser, they are server configuration, not assets.


Josh, thanks for the explanation.  However, i may argue that one can keep SCSS or CoffeeScript in assets, and those are not downloaded, only generated CSS and JavaScript are.  YAML files of localizations are not downloaded, but the localized strings for the current page are.

Ryan Bigg

unread,
Apr 4, 2012, 5:40:51 PM4/4/12
to rubyonra...@googlegroups.com
You're right that they're not downloadable. They're still used in the process of generating assets that are downloadable. The ones that are downloadable live in public/assets anyway.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/lhsv3Xp19oQJ.

Alexey

unread,
Apr 5, 2012, 12:05:22 PM4/5/12
to rubyonra...@googlegroups.com
I give up about calling them assets, but maybe locales can be at least in app/ directory?

Rafael Mendonça França

unread,
Apr 5, 2012, 12:35:14 PM4/5/12
to rubyonra...@googlegroups.com
You can put it inside the app directory too. Both are loaded.
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-core/-/FJeSmbkwA0MJ.

Andrés Mejía

unread,
Apr 5, 2012, 2:40:46 PM4/5/12
to rubyonra...@googlegroups.com
You can put them anywhere you want. If you want to put them in assets, just add

config.i18n.load_path += Dir[Rails.root.join('assets', 'locales', '*.{rb,yml}').to_s]

to your config/application.rb file.

Ryan Bigg

unread,
Apr 5, 2012, 2:42:26 PM4/5/12
to rubyonra...@googlegroups.com
I would advise against doing this though. As a developer, I expect to find locales in config/locales. If things aren't in their correct places, I tend to mildly freak out.
Reply all
Reply to author
Forward
0 new messages