Permalink
Browse files

Initial import.

  • Loading branch information...
clemens committed Aug 7, 2008
0 parents commit 7cc8f31caf059e7a9e3898d1b0996cbddd124e20
Showing 1,570 changed files with 203,436 additions and 0 deletions.
0 README
No changes.
@@ -0,0 +1,10 @@
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require(File.join(File.dirname(__FILE__), 'config', 'boot'))
+
+require 'rake'
+require 'rake/testtask'
+require 'rake/rdoctask'
+
+require 'tasks/rails'
@@ -0,0 +1,15 @@
+# Filters added to this controller apply to all controllers in the application.
+# Likewise, all the methods added will be available for all controllers.
+
+class ApplicationController < ActionController::Base
+ helper :all # include all helpers, all the time
+
+ # See ActionController::RequestForgeryProtection for details
+ # Uncomment the :secret if you're not using the cookie session store
+ protect_from_forgery # :secret => 'fc86fd4bfda299c3b079191a8f948013'
+
+ # See ActionController::Base for details
+ # Uncomment this to filter the contents of submitted sensitive data parameters
+ # from your application log (in this case, all fields with names like "password").
+ # filter_parameter_logging :password
+end
@@ -0,0 +1,2 @@
+class PagesController < ApplicationController
+end
@@ -0,0 +1,3 @@
+# Methods added to this helper will be available to all templates in the application.
+module ApplicationHelper
+end
@@ -0,0 +1,32 @@
+<html>
+ <head>
+ <title>Localizing Rails - Demo Application</title>
+ <%= stylesheet_link_tag 'application' %>
+ </head>
+ <body>
+ <div id="page">
+ <h1>Localizing Rails<span id="claim">how to localize your app with Rails' new i18n features</span></h1>
+ <div id="navigation">
+ <h4 style="margin:0; margin-bottom:5px;">Contents</h4>
+ <ul>
+ <li><%= link_to "Introduction", :action => 'index' %></li>
+ <li><%= link_to "Setup", :action => 'setup' %></li>
+ <li><%= link_to "Date formats", :action => 'date_formats' %></li>
+ <li><%= link_to "Time formats", :action => 'time_formats' %></li>
+ <li><%= link_to "DateHelper", :action => 'date_helper' %></li>
+ <li><%= link_to "ActiveRecordHelper", :action => 'active_record_helper' %></li>
+ <li><%= link_to "NumberHelper", :action => 'number_helper' %></li>
+ </ul>
+ </div>
+ <div id="content">
+ <%= yield %>
+ </div>
+ <div id="footer">
+ <p>Localizing Rails - Demo Application</p>
+ <p>&copy; 2008 Clemens Kofler &lt;<%= mail_to 'clemens@railway.at' %>&gt;</p>
+ <p><%= link_to 'www.railway.at - welcome aboard!', 'http://www.railway.at' %></p>
+ <p style="position:absolute; bottom:25px; right:25px;"><%= link_to image_tag("http://i.creativecommons.org/l/by-nc-sa/2.0/at/88x31.png"), "http://creativecommons.org/licenses/by-nc-sa/2.0/at/" %></p>
+ </div>
+ </div>
+ </body>
+</html>
@@ -0,0 +1,7 @@
+<h2>About this demo app</h2>
+<div>
+ <p>This demo app was written by <%= mail_to "clemens@railway.at", "Clemens Kofler" %>.</p>
+ <p>If you have any feedback, please feel free to drop me a line. Also visit <%= link_to "www.railway.at", "http://www.railway.at" %> where I regularly blog about Rails and other stuff.</p>
+ <p>This demo app and all its contents are licensed under the <%= link_to "Creative Commons Attribution Noncommercial Share Alike License", "http://creativecommons.org/licenses/by-nc-sa/2.0/at/" %>. If you want to use it in ways prohibited by this license, please contact me and ask my permission.</p>
+ <p><%= link_to image_tag("http://i.creativecommons.org/l/by-nc-sa/2.0/at/88x31.png"), "http://creativecommons.org/licenses/by-nc-sa/2.0/at/" %></p>
+</div>
@@ -0,0 +1,6 @@
+<h2>ActiveRecordHelper</h2>
+<div>
+ <p>No examples here since I'm too lazy to think of attributes to show <strong>all</strong> custom error messages. ;-)</p>
+ <p>It's quite easy to understand, though.</p>
+ <p style="text-align:right;"><%= link_to '&raquo; NumberHelper', :action => 'number_helper' %></p>
+</div>
@@ -0,0 +1,46 @@
+<h2>Date formats</h2>
+<div>
+ <table>
+ <tr>
+ <th scope="row">Date.today.to_s</th>
+ <td><%= Date.today.to_s %></td>
+ </tr>
+ <tr>
+ <th scope="row">Date.today.to_s(:default)</th>
+ <td><%= Date.today.to_s(:default) %></td>
+ </tr>
+ <tr>
+ <th scope="row">Date.today.to_s(:short)</th>
+ <td><%= Date.today.to_s(:short) %></td>
+ </tr>
+ <tr>
+ <th scope="row">Date.today.to_s(:long)</th>
+ <td><%= Date.today.to_s(:long) %></td>
+ </tr>
+ <tr>
+ <th scope="row">Date.today.to_s(:long_ordinal)</th>
+ <td><%= Date.today.to_s(:long_ordinal) %></td>
+ </tr>
+ <tr>
+ <th scope="row">Date.today.to_s(:only_day)</th>
+ <td><%= Date.today.to_s(:only_day) %></td>
+ </tr>
+ </table>
+ <p>Rails standard formats (Date::DATE_FORMATS) still work:</p>
+ <table>
+ <tr>
+ <th scope="row">Date.today.to_s(:db)</th>
+ <td><%= Date.today.to_s(:db) %></td>
+ </tr>
+ <tr>
+ <th scope="row">Date.today.to_s(:number)</th>
+ <td><%= Date.today.to_s(:number) %></td>
+ </tr>
+ <tr>
+ <th scope="row">Date.today.to_s(:rfc822)</th>
+ <td><%= Date.today.to_s(:rfc822) %></td>
+ </tr>
+ </table>
+</div>
+
+<p style="text-align:right;"><%= link_to '&raquo; Time formats', :action => 'time_formats' %></p>
@@ -0,0 +1,81 @@
+<h2>DateHelper</h2>
+<div>
+ <h3>Date/Time distance</h3>
+ <div>
+ <table>
+ <tr>
+ <th scope="row">time_ago_in_words(20.seconds.ago, true)</th>
+ <td><%= time_ago_in_words(20.seconds.ago, true) %></td>
+ </tr>
+ <tr>
+ <th scope="row">time_ago_in_words(1.minute.ago)</th>
+ <td><%= time_ago_in_words(1.minute.ago) %></td>
+ </tr>
+ <tr>
+ <th scope="row">time_ago_in_words(1.5.minute.ago)</th>
+ <td><%= time_ago_in_words(1.5.minute.ago) %></td>
+ </tr>
+ <tr>
+ <th scope="row">time_ago_in_words(1.day.ago)</th>
+ <td><%= time_ago_in_words(1.day.ago) %></td>
+ </tr>
+ <tr>
+ <th scope="row">time_ago_in_words(1.2.day.ago)</th>
+ <td><%= time_ago_in_words(1.2.day.ago) %></td>
+ </tr>
+ </table>
+ <p>etc.</p>
+ </div>
+
+ <h3>Forms</h3>
+ <div>
+ <table>
+ <tr>
+ <th scope="row">select_date(Date.today)</th>
+ <td><%= select_date(Date.today) %></td>
+ </tr>
+ <tr>
+ <th scope="row">select_time(Time.now)</th>
+ <td><%= select_time(Time.now) %></td>
+ </tr>
+ <tr>
+ <th scope="row">select_datetime(Time.now)</th>
+ <td><%= select_datetime(Time.now) %></td>
+ </tr>
+ <tr>
+ <th scope="row">date_select(Object.new, :date_field)</th>
+ <td><%= date_select(Object.new, :date_field) %></td>
+ </tr>
+ <tr>
+ <th scope="row">time_select(Object.new, :time_field)</th>
+ <td><%= time_select(Object.new, :time_field) %></td>
+ </tr>
+ <tr>
+ <th scope="row">datetime_select(Object.new, :date_or_time_field)</th>
+ <td><%= datetime_select(Object.new, :date_or_time_field) %></td>
+ </tr>
+ </table>
+ <p>Note: You may have spotted that <code>select_date</code> and <code>select_datetime</code> don't use the field order that has been specified in the locale. This is because these methods use a different backend from their <code>date_select</code>/<code>datetime_select</code> counterparts. Right now, you can manually hack localization behavior in by using an initializer like the following:</p>
+ <blockquote>
+ <pre>
+ActionView::Helpers::DateHelper.class_eval do
+ def select_date_with_localization(date = Date.current, options = {}, html_options = {})
+ options[:order] ||= I18n.translate(:'date.order')
+ select_date_without_localization(date, options, html_options)
+ end
+ alias_method_chain :select_date, :localization
+
+ def select_datetime_with_localization(datetime = Time.current, options = {}, html_options = {})
+ options[:order] ||= I18n.translate(:'date.order')
+ select_datetime_without_localization(datetime, options, html_options)
+ end
+ alias_method_chain :select_datetime, :localization
+end
+ </pre>
+ </blockquote>
+ <p>You can find this initializer in <code>config/initializers/date_helper_i18n.rb</code> - just remove the comments and you're good to go.</p>
+ <p>The DateHelper API is <%= link_to "being refactored", "http://github.com/josh/rails/commits/date_presenter" %> as you read this to have a consistent backend. In a few days, the changes will be merged into core and future Rails versions won't need this hack.</p>
+ </div>
+</div>
+
+<p style="text-align:right;"><%= link_to '&raquo; ActiveRecordHelper', :action => 'active_record_helper' %></p>
@@ -0,0 +1,7 @@
+<h2>Introduction</h2>
+<div>
+ <p>Lately, a lot of work has been done by <%= link_to "Sven Fuchs", "http://www.artweb-design.de/" %> and <%= link_to "others", "http://github.com/svenfuchs/i18n/tree/48ff00d2af07693171ec341500537b30e23e83bc/README.textile" %> to facilitate future internationalization and localization of Rails.</p>
+ <p>This demo app tries to show you how you can use the features that have been implemented so far to localize big parts of your Rails application.</p>
+</div>
+
+<p style="text-align:right;"><%= link_to '&raquo; Setup', :action => 'setup' %></p>
@@ -0,0 +1,118 @@
+<h2>NumberHelper</h2>
+<div>
+ <p>Note: <code>number_to_phone</code> hasn't been localized yet and probably never will be - at least not in core. Look out for new internationalization/localization plugins like a new version of <%= link_to "Globalize", "http://globalize.rubyforge.org/" %> as they will probably support stuff like that.</p>
+
+ <p>Another note: <code>number_to_currency</code>, <code>number_to_percentage</code> and <code>number_to_human_size</code> all use <code>number_with_precision</code> internally and <code>number_with_precision</code> uses <code>number_with_delimiter</code> internally.</p>
+
+ <h3>number_to_currency</h3>
+ <div>
+ <table>
+ <tr>
+ <th scope="row">number_to_currency(999)</th>
+ <td><%= number_to_currency(999) %></td>
+ </tr>
+ <tr>
+ <th scope="row">number_to_currency(1999)</th>
+ <td><%= number_to_currency(1999) %></td>
+ </tr>
+ <tr>
+ <th scope="row">number_to_currency(1999.99)</th>
+ <td><%= number_to_currency(1999.99) %></td>
+ </tr>
+ <tr>
+ <th scope="row">number_to_currency(1934524.34582)</th>
+ <td><%= number_to_currency(1934524.34582) %></td>
+ </tr>
+ </table>
+ </div>
+
+ <h3>number_to_percentage</h3>
+ <div>
+ <table>
+ <tr>
+ <th scope="row">number_to_percentage(999)</th>
+ <td><%= number_to_percentage(999) %></td>
+ </tr>
+ <tr>
+ <th scope="row">number_to_percentage(1999)</th>
+ <td><%= number_to_percentage(1999) %></td>
+ </tr>
+ <tr>
+ <th scope="row">number_to_percentage(1999.99)</th>
+ <td><%= number_to_percentage(1999.99) %></td>
+ </tr>
+ <tr>
+ <th scope="row">number_to_percentage(1934524.34582)</th>
+ <td><%= number_to_percentage(1934524.34582) %></td>
+ </tr>
+ </table>
+ </div>
+
+ <h3>number_to_human_size</h3>
+ <div>
+ <table>
+ <tr>
+ <th scope="row">number_to_human_size(1.byte)</th>
+ <td><%= number_to_human_size(1.byte) %></td>
+ </tr>
+ <tr>
+ <th scope="row">number_to_human_size(2.kilobytes)</th>
+ <td><%= number_to_human_size(2.kilobytes) %></td>
+ </tr>
+ <tr>
+ <th scope="row">number_to_human_size(2.5.kilobytes)</th>
+ <td><%= number_to_human_size(2.5.kilobytes) %></td>
+ </tr>
+ <tr>
+ <th scope="row">number_to_human_size(2.34582.kilobytes)</th>
+ <td><%= number_to_human_size(2.34582.kilobytes) %></td>
+ </tr>
+ </table>
+ </div>
+
+ <h3>number_with_precision</h3>
+ <div>
+ <table>
+ <tr>
+ <th scope="row">number_with_precision(999)</th>
+ <td><%= number_with_precision(999) %></td>
+ </tr>
+ <tr>
+ <th scope="row">number_with_precision(1999)</th>
+ <td><%= number_with_precision(1999) %></td>
+ </tr>
+ <tr>
+ <th scope="row">number_with_precision(1999.99)</th>
+ <td><%= number_with_precision(1999.99) %></td>
+ </tr>
+ <tr>
+ <th scope="row">number_with_precision(1934524.34582)</th>
+ <td><%= number_with_precision(1934524.34582) %></td>
+ </tr>
+ </table>
+ </div>
+
+ <h3>number_with_delimiter</h3>
+ <div>
+ <table>
+ <tr>
+ <th scope="row">number_with_delimiter(999)</th>
+ <td><%= number_with_delimiter(999) %></td>
+ </tr>
+ <tr>
+ <th scope="row">number_with_delimiter(1999)</th>
+ <td><%= number_with_delimiter(1999) %></td>
+ </tr>
+ <tr>
+ <th scope="row">number_with_delimiter(1999.99)</th>
+ <td><%= number_with_delimiter(1999.99) %></td>
+ </tr>
+ <tr>
+ <th scope="row">number_with_delimiter(1934524.34582)</th>
+ <td><%= number_with_delimiter(1934524.34582) %></td>
+ </tr>
+ </table>
+ </div>
+</div>
+
+<p style="text-align:right;"><%= link_to '&raquo; About this demo app', :action => 'about' %></p>
Oops, something went wrong.

0 comments on commit 7cc8f31

Please sign in to comment.