From 559c394ec4b09ed474c582613c01d7e829fcb1ca Mon Sep 17 00:00:00 2001 From: Mike Gunderloy Date: Sat, 28 Feb 2009 11:46:25 -0600 Subject: Update 2.3 release notes. --- railties/guides/source/2_3_release_notes.textile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/guides/source/2_3_release_notes.textile b/railties/guides/source/2_3_release_notes.textile index 051379c437..c58cbc0b81 100644 --- a/railties/guides/source/2_3_release_notes.textile +++ b/railties/guides/source/2_3_release_notes.textile @@ -320,6 +320,7 @@ h4. Other Action Controller Changes * You can now use symbols for the +:type+ option of +send_file+ and +send_data+, like this: +send_file("fabulous.png", :type => :png)+. * The +:only+ and +:except+ options for +map.resources+ are no longer inherited by nested resources. * The bundled memcached client has been updated to version 1.6.4.99. +* The +expires_in+, +stale?+, and +fresh_when+ methods now accept a +:public+ option to make them work well with proxy caching. h3. Action View @@ -448,7 +449,7 @@ In most cases, you'll want template caching to be turned on in production, which config.action_view.cache_template_loading = true -This line will be generated for you by default in a new Rails 2.3 application. But please note: if you've upgraded from an older version of Rails, you won't have this setting in your +production.rb+ and template caching will be off by default. Unless you really need the ability to update templates in production without restarting the server, you should be sure to add this setting when you upgrade. +This line will be generated for you by default in a new Rails 2.3 application. If you've upgraded from an older version of Rails, Rails will default to caching templates in production and test but not in development. h4. Other Action View Changes -- cgit v1.2.3 From c674d209e15237ff276be7513825139f578fe2d7 Mon Sep 17 00:00:00 2001 From: Pratik Naik Date: Sat, 28 Feb 2009 19:40:34 +0000 Subject: Fix some formatting in the caching guide --- railties/guides/source/caching_with_rails.textile | 17 +++++++++-------- railties/guides/source/index.erb.textile | 8 ++++++-- 2 files changed, 15 insertions(+), 10 deletions(-) (limited to 'railties') diff --git a/railties/guides/source/caching_with_rails.textile b/railties/guides/source/caching_with_rails.textile index 9736be8443..b1c1af8be4 100644 --- a/railties/guides/source/caching_with_rails.textile +++ b/railties/guides/source/caching_with_rails.textile @@ -500,16 +500,17 @@ seriously considering optimizing their caching needs. Also the new "Cache money":http://github.com/nkallen/cache-money/tree/master plugin is supposed to be mad cool. h3. References - * "RailsEnvy, Rails Caching Tutorial, Part 1":http://www.railsenvy.com/2007/2/28/rails-caching-tutorial - * "RailsEnvy, Rails Caching Tutorial, Part 1":http://www.railsenvy.com/2007/3/20/ruby-on-rails-caching-tutorial-part-2 - * "ActiveSupport::Cache documentation":http://api.rubyonrails.org/classes/ActiveSupport/Cache.html - * "Rails 2.1 integrated caching tutorial":http://thewebfellas.com/blog/2008/6/9/rails-2-1-now-with-better-integrated-caching +* "RailsEnvy, Rails Caching Tutorial, Part 1":http://www.railsenvy.com/2007/2/28/rails-caching-tutorial +* "RailsEnvy, Rails Caching Tutorial, Part 1":http://www.railsenvy.com/2007/3/20/ruby-on-rails-caching-tutorial-part-2 +* "ActiveSupport::Cache documentation":http://api.rubyonrails.org/classes/ActiveSupport/Cache.html +* "Rails 2.1 integrated caching tutorial":http://thewebfellas.com/blog/2008/6/9/rails-2-1-now-with-better-integrated-caching h3. Changelog + "Lighthouse ticket":http://rails.lighthouseapp.com/projects/16213-rails-guides/tickets/10-guide-to-caching -February 22, 2009: Beefed up the section on cache_stores -December 27, 2008: Typo fixes -November 23, 2008: Incremental updates with various suggested changes and formatting cleanup -September 15, 2008: Initial version by Aditya Chadha +* February 22, 2009: Beefed up the section on cache_stores +* December 27, 2008: Typo fixes +* November 23, 2008: Incremental updates with various suggested changes and formatting cleanup +* September 15, 2008: Initial version by Aditya Chadha diff --git a/railties/guides/source/index.erb.textile b/railties/guides/source/index.erb.textile index 4751c3a1f5..49d8cad404 100644 --- a/railties/guides/source/index.erb.textile +++ b/railties/guides/source/index.erb.textile @@ -73,6 +73,10 @@ h3. Digging Deeper
+<% guide("Rails on Rack", 'rails_on_rack.html') do %> + This guide covers Rails integration with Rack and interfacing with other Rack components. +<% end %> + <% guide("Rails Internationalization API", 'i18n.html', :ticket => 23) do %> This guide covers how to add internationalization to your applications. Your application will be able to translate content to different languages, change pluralization rules, use correct date formats for each country and so on. <% end %> @@ -109,8 +113,8 @@ h3. Digging Deeper This guide covers the command line tools and rake tasks provided by Rails. <% end %> -<% guide("Rails on Rack", 'rails_on_rack.html', :ticket => 58) do %> - This guide covers Rails integration with Rack and interfacing with other Rack components. +<% guide("Caching with Rails", 'caching_with_rails.html', :ticket => 10) do %> + Various caching techniques provided by Rails. <% end %>
-- cgit v1.2.3 From e1c0763e47f76b916324c5a062b50ede41a51e3c Mon Sep 17 00:00:00 2001 From: Karel Minarik Date: Sun, 1 Mar 2009 10:54:18 +0100 Subject: Get rid of drop shadows in screenshots for the I18N guide TODOS are in http://rails.lighthouseapp.com/projects/16213/tickets/23-rails-i18 --- .../guides/images/i18n/demo_localized_pirate.png | Bin 36500 -> 15027 bytes railties/guides/images/i18n/demo_translated_en.png | Bin 32877 -> 12057 bytes .../guides/images/i18n/demo_translated_pirate.png | Bin 34506 -> 13392 bytes .../guides/images/i18n/demo_translation_missing.png | Bin 34373 -> 13143 bytes railties/guides/images/i18n/demo_untranslated.png | Bin 32793 -> 11925 bytes 5 files changed, 0 insertions(+), 0 deletions(-) (limited to 'railties') diff --git a/railties/guides/images/i18n/demo_localized_pirate.png b/railties/guides/images/i18n/demo_localized_pirate.png index 22b93416a0..9134709573 100644 Binary files a/railties/guides/images/i18n/demo_localized_pirate.png and b/railties/guides/images/i18n/demo_localized_pirate.png differ diff --git a/railties/guides/images/i18n/demo_translated_en.png b/railties/guides/images/i18n/demo_translated_en.png index 7ea0c437a5..ecdd878d38 100644 Binary files a/railties/guides/images/i18n/demo_translated_en.png and b/railties/guides/images/i18n/demo_translated_en.png differ diff --git a/railties/guides/images/i18n/demo_translated_pirate.png b/railties/guides/images/i18n/demo_translated_pirate.png index 60ef370158..41c580923a 100644 Binary files a/railties/guides/images/i18n/demo_translated_pirate.png and b/railties/guides/images/i18n/demo_translated_pirate.png differ diff --git a/railties/guides/images/i18n/demo_translation_missing.png b/railties/guides/images/i18n/demo_translation_missing.png index 86a3121cc1..af9e2d0427 100644 Binary files a/railties/guides/images/i18n/demo_translation_missing.png and b/railties/guides/images/i18n/demo_translation_missing.png differ diff --git a/railties/guides/images/i18n/demo_untranslated.png b/railties/guides/images/i18n/demo_untranslated.png index e6717fb7d1..3603f43463 100644 Binary files a/railties/guides/images/i18n/demo_untranslated.png and b/railties/guides/images/i18n/demo_untranslated.png differ -- cgit v1.2.3 From 48d4c0f0116117e45fd268f9fa8ae502d7f15cc7 Mon Sep 17 00:00:00 2001 From: Karel Minarik Date: Sun, 1 Mar 2009 11:03:59 +0100 Subject: Added note how to configure Rails loading mechanism to look for nested locale files (+config/locales/models/book/es.yml+, etc) to the I18N guide --- railties/guides/source/i18n.textile | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'railties') diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile index bb445c0bf7..bc8be1f068 100644 --- a/railties/guides/source/i18n.textile +++ b/railties/guides/source/i18n.textile @@ -416,7 +416,7 @@ TIP: Right now you might need to add some more date/time formats in order to mak h4. Organization of locale files -When you are using the default SimpleStore, shipped with the i18n library, you store dictionaries in plain-text files on the disc. Putting translations for all parts of your application in one file per locale could be hard to manage. You can store these files in a hierarchy which makes sense to you. +When you are using the default SimpleStore, shipped with the i18n library, dictionaries are stored in plain-text files on the disc. Putting translations for all parts of your application in one file per locale could be hard to manage. You can store these files in a hierarchy which makes sense to you. For example, your +config/locale+ directory could look like this: @@ -443,9 +443,14 @@ For example, your +config/locale+ directory could look like this: |-----en.rb -This way, you can separate model and model attribute names from text inside views, and all of this from the "defaults" (eg. date and time formats). +This way, you can separate model and model attribute names from text inside views, and all of this from the "defaults" (eg. date and time formats). Other stores for the i18n library could provide different means of such separation. -Other stores for the i18n library could provide different means of such separation. +NOTE: The default locale loading mechanism in Rails does not load locale files in nested dictionaries, like we have here. So, for this to work, we must explicitely tell Rails to look further: + + + # config/environment.rb + config.i18n.load_path += Dir[File.join(RAILS_ROOT, 'config', 'locales', '**', '*.{rb,yml}')] + Do check the "Rails i18n Wiki":http://rails-i18n.org/wiki for list of tools available for managing translations. -- cgit v1.2.3 From 92dd9b3e9f7bffe16ec53aeefd048d7da4eb1543 Mon Sep 17 00:00:00 2001 From: Karel Minarik Date: Sun, 1 Mar 2009 12:06:50 +0100 Subject: Added information about "Localized views" into I18N guide See: * http://github.com/rails/rails/commit/a98cd7ca9b2f24a4500963e58ba5c37d6bdf9259 * http://afreshcup.com/2009/02/01/rails-23-localized-views/ --- railties/guides/source/i18n.textile | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'railties') diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile index bc8be1f068..f5a50ee78b 100644 --- a/railties/guides/source/i18n.textile +++ b/railties/guides/source/i18n.textile @@ -414,6 +414,12 @@ So that would give you: TIP: Right now you might need to add some more date/time formats in order to make the I18n backend work as expected. Of course, there's a great chance that somebody already did all the work by *translating Rails's defaults for your locale*. See the "rails-i18n repository at Github":http://github.com/svenfuchs/rails-i18n/tree/master/rails/locale for an archive of various locale files. When you put such file(s) in +config/locale/+ directory, they will automatically ready for use. +h4. Localized views + +Rails 2.3 brings one convenient feature: localized views (templates). Let's say you have a _BooksController_ in your application. Your _index_ action renders content in +app/views/books/index.html.erb+ template. When you put a _localized variant_ of this template: *+index.es.html.erb+* in the same directory, Rails will render content in this template, when the locale is set to +:es+. When the locale is set to the default locale, generic +index.html.erb+ view will be used. (Future Rails versions may well bring this _automagic_ localization to assets in +public+, etc.) + +You can make use this feature eg. when working with great amount of static content, which would be clumsy to put inside YAML or Ruby dictionaries. Bear in mind, though, that any change you would like to do later to the template must be propagated to all of them. + h4. Organization of locale files When you are using the default SimpleStore, shipped with the i18n library, dictionaries are stored in plain-text files on the disc. Putting translations for all parts of your application in one file per locale could be hard to manage. You can store these files in a hierarchy which makes sense to you. -- cgit v1.2.3 From 959b827e40248691864221d9d8561f17fb5755a6 Mon Sep 17 00:00:00 2001 From: Karel Minarik Date: Sun, 1 Mar 2009 12:37:03 +0100 Subject: Clarified info about "pragmatic approach to locale codes" and removed speculation about "locale inheritance" in the I18N guide [thanks Kip] See http://groups.google.com/group/rails-i18n/msg/7b4513b3ca8abbf5 --- railties/guides/source/i18n.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'railties') diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile index f5a50ee78b..d882a65d8d 100644 --- a/railties/guides/source/i18n.textile +++ b/railties/guides/source/i18n.textile @@ -91,7 +91,7 @@ This means, that in the +:en+ locale, the key _hello_ will map to _Hello world_ The I18n library will use *English* as a *default locale*, ie. if you don't set a different locale, +:en+ will be used for looking up translations. -NOTE: The i18n library takes *pragmatic approach* to locale keys (after "some discussion":http://groups.google.com/group/rails-i18n/browse_thread/thread/14dede2c7dbe9470/80eec34395f64f3c?hl=en), including only the _locale_ ("language") part, like +:en+, +:pl+, not the _region_ part, like +:en-US+ or +:en-UK+, which are traditionally used for separating "languages" and "regional setting" or "dialects". (For instance, in the +:en-US+ locale you would have $ as a currency symbol, while in +:en-UK+, you would have £. Also, insults would be different in American and British English :) Reason for this pragmatic approach is that most of the time, you usually care about making your application available in different "languages", and working with locales is much simpler this way. However, nothing stops you from separating regional and other settings in the traditional way. In this case, you could eg. inherit from the default +en+ locale and then provide UK specific settings in a +:en-UK+ dictionary. +NOTE: The i18n library takes *pragmatic approach* to locale keys (after "some discussion":http://groups.google.com/group/rails-i18n/browse_thread/thread/14dede2c7dbe9470/80eec34395f64f3c?hl=en), including only the _locale_ ("language") part, like +:en+, +:pl+, not the _region_ part, like +:en-US+ or +:en-UK+, which are traditionally used for separating "languages" and "regional setting" or "dialects". Many international applications use only the "language" element of a locale such as +:cz+, +:th+ or +:es+ (for Czech, Thai and Spanish). However, there are also regional differences within different language groups that may be important. For instance, in the +:en-US+ locale you would have $ as a currency symbol, while in +:en-UK+, you would have £. Nothing stops you from separating regional and other settings in this way: you just have to provide full "English - United Kingdom" locale in a +:en-UK+ dictionary. Various "Rails I18n plugins":http://rails-i18n.org/wiki such as "Globalize2":http://github.com/joshmh/globalize2 may help you implement it. The *translations load path* (+I18n.load_path+) is just a Ruby Array of paths to your translation files that will be loaded automatically and available in your application. You can pick whatever directory and translation file naming scheme makes sense for you. -- cgit v1.2.3 From a6f1e42c096a626b8a071094545d35f90d19ab55 Mon Sep 17 00:00:00 2001 From: Karel Minarik Date: Sun, 1 Mar 2009 12:51:18 +0100 Subject: Added information about "lazy lookup" inside views (`t '.foo'`) in I18N guide --- railties/guides/source/i18n.textile | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'railties') diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile index d882a65d8d..bb17e1ffc4 100644 --- a/railties/guides/source/i18n.textile +++ b/railties/guides/source/i18n.textile @@ -539,6 +539,23 @@ I18n.t 'active_record.error_messages' # => { :inclusion => "is not included in the list", :exclusion => ... } +h5. "Lazy" lookup + +Rails 2.3 implements convenient way to lookup locale inside _views_. When you have following dictionary: + + +es: + books: + index: + title: "Título" + + +you can lookup the +books.index.title+ value *inside* +app/views/books/index.html.erb+ template like this (note the dot): + + +<%= t '.title' %> + + h4. Interpolation In many cases you want to abstract your translations so that *variables can be interpolated into the translation*. For this reason the I18n API provides an interpolation feature. -- cgit v1.2.3 From 61656cf7702f46fcbb810a70bf0298ac5ea6c0d3 Mon Sep 17 00:00:00 2001 From: Karel Minarik Date: Sun, 1 Mar 2009 13:03:26 +0100 Subject: Fixed incorrect examples of ActiveRecord error message lookup in the I18N guide [Thanks Alex Fortuna] See http://www.ruby-forum.com/topic/179273 --- railties/guides/source/i18n.textile | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'railties') diff --git a/railties/guides/source/i18n.textile b/railties/guides/source/i18n.textile index bb17e1ffc4..4d9232917d 100644 --- a/railties/guides/source/i18n.textile +++ b/railties/guides/source/i18n.textile @@ -705,20 +705,20 @@ end The key for the error message in this case is +:blank+. Active Record will lookup this key in the namespaces: -activerecord.errors.messages.models.[model_name].attributes.[attribute_name] -activerecord.errors.messages.models.[model_name] +activerecord.errors.models.[model_name].attributes.[attribute_name] +activerecord.errors.models.[model_name] activerecord.errors.messages Thus, in our example it will try the following keys in this order and return the first result: -activerecord.errors.messages.models.user.attributes.name.blank -activerecord.errors.messages.models.user.blank +activerecord.errors.models.user.attributes.name.blank +activerecord.errors.models.user.blank activerecord.errors.messages.blank -When your models are additionally using inheritance then the messages are looked up for the inherited model class names are looked up. +When your models are additionally using inheritance then the messages are looked up in the inheritance chain. For example, you might have an Admin model inheriting from User: -- cgit v1.2.3