gettext_rails 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/COPYING +55 -0
- data/ChangeLog +4 -0
- data/README.rdoc +173 -0
- data/Rakefile +113 -0
- data/data/locale/bg/LC_MESSAGES/gettext_rails.mo +0 -0
- data/data/locale/bs/LC_MESSAGES/gettext_rails.mo +0 -0
- data/data/locale/ca/LC_MESSAGES/gettext_rails.mo +0 -0
- data/data/locale/cs/LC_MESSAGES/gettext_rails.mo +0 -0
- data/data/locale/de/LC_MESSAGES/gettext_rails.mo +0 -0
- data/data/locale/el/LC_MESSAGES/gettext_rails.mo +0 -0
- data/data/locale/eo/LC_MESSAGES/gettext_rails.mo +0 -0
- data/data/locale/es/LC_MESSAGES/gettext_rails.mo +0 -0
- data/data/locale/et/LC_MESSAGES/gettext_rails.mo +0 -0
- data/data/locale/fr/LC_MESSAGES/gettext_rails.mo +0 -0
- data/data/locale/hr/LC_MESSAGES/gettext_rails.mo +0 -0
- data/data/locale/hu/LC_MESSAGES/gettext_rails.mo +0 -0
- data/data/locale/it/LC_MESSAGES/gettext_rails.mo +0 -0
- data/data/locale/ja/LC_MESSAGES/gettext_rails.mo +0 -0
- data/data/locale/ko/LC_MESSAGES/gettext_rails.mo +0 -0
- data/data/locale/lv/LC_MESSAGES/gettext_rails.mo +0 -0
- data/data/locale/nb/LC_MESSAGES/gettext_rails.mo +0 -0
- data/data/locale/nl/LC_MESSAGES/gettext_rails.mo +0 -0
- data/data/locale/pt_BR/LC_MESSAGES/gettext_rails.mo +0 -0
- data/data/locale/ru/LC_MESSAGES/gettext_rails.mo +0 -0
- data/data/locale/sr/LC_MESSAGES/gettext_rails.mo +0 -0
- data/data/locale/ua/LC_MESSAGES/gettext_rails.mo +0 -0
- data/data/locale/vi/LC_MESSAGES/gettext_rails.mo +0 -0
- data/data/locale/zh/LC_MESSAGES/gettext_rails.mo +0 -0
- data/data/locale/zh_TW/LC_MESSAGES/gettext_rails.mo +0 -0
- data/lib/gettext_rails.rb +33 -0
- data/lib/gettext_rails/action_controller.rb +104 -0
- data/lib/gettext_rails/action_mailer.rb +45 -0
- data/lib/gettext_rails/action_view.rb +16 -0
- data/lib/gettext_rails/action_view/active_record_helper.rb +109 -0
- data/lib/gettext_rails/action_view/date_helper.rb +48 -0
- data/lib/gettext_rails/action_view/form_builder.rb +26 -0
- data/lib/gettext_rails/tools.rb +22 -0
- data/lib/gettext_rails/version.rb +14 -0
- data/po/bg/gettext_rails.po +89 -0
- data/po/bs/gettext_rails.po +98 -0
- data/po/ca/gettext_rails.po +90 -0
- data/po/cs/gettext_rails.po +102 -0
- data/po/de/gettext_rails.po +94 -0
- data/po/el/gettext_rails.po +89 -0
- data/po/eo/gettext_rails.po +90 -0
- data/po/es/gettext_rails.po +90 -0
- data/po/et/gettext_rails.po +90 -0
- data/po/fr/gettext_rails.po +94 -0
- data/po/gettext_rails.pot +87 -0
- data/po/hr/gettext_rails.po +99 -0
- data/po/hu/gettext_rails.po +90 -0
- data/po/it/gettext_rails.po +89 -0
- data/po/ja/gettext_rails.po +90 -0
- data/po/ko/gettext_rails.po +87 -0
- data/po/lv/gettext_rails.po +95 -0
- data/po/nb/gettext_rails.po +91 -0
- data/po/nl/gettext_rails.po +91 -0
- data/po/pt_BR/gettext_rails.po +91 -0
- data/po/ru/gettext_rails.po +98 -0
- data/po/sr/gettext_rails.po +98 -0
- data/po/test.rb +11 -0
- data/po/ua/gettext_rails.po +104 -0
- data/po/vi/gettext_rails.po +90 -0
- data/po/zh/gettext_rails.po +86 -0
- data/po/zh_TW/gettext_rails.po +86 -0
- data/replace.rb +21 -0
- data/sample/README +80 -0
- data/sample/Rakefile +11 -0
- data/sample/app/controllers/application_controller.rb +37 -0
- data/sample/app/controllers/articles_controller.rb +97 -0
- data/sample/app/helpers/application_helper.rb +3 -0
- data/sample/app/helpers/articles_helper.rb +60 -0
- data/sample/app/models/article.rb +16 -0
- data/sample/app/views/articles/edit.html.erb +22 -0
- data/sample/app/views/articles/index.html.erb +18 -0
- data/sample/app/views/articles/new.html.erb +20 -0
- data/sample/app/views/articles/show.html.erb +7 -0
- data/sample/app/views/layouts/articles.html.erb +27 -0
- data/sample/config/boot.rb +109 -0
- data/sample/config/database.yml +22 -0
- data/sample/config/environment.rb +45 -0
- data/sample/config/environments/development.rb +17 -0
- data/sample/config/environments/production.rb +27 -0
- data/sample/config/environments/test.rb +27 -0
- data/sample/config/initializers/backtrace_silencers.rb +7 -0
- data/sample/config/initializers/inflections.rb +10 -0
- data/sample/config/initializers/mime_types.rb +5 -0
- data/sample/config/initializers/new_rails_defaults.rb +19 -0
- data/sample/config/initializers/session_store.rb +15 -0
- data/sample/config/routes.rb +45 -0
- data/sample/db/development.sqlite3 +0 -0
- data/sample/db/production.sqlite3 +0 -0
- data/sample/db/schema.rb +19 -0
- data/sample/db/test.sqlite3 +0 -0
- data/sample/doc/README_FOR_APP +2 -0
- data/sample/lib/tasks/gettext.rake +13 -0
- data/sample/locale/bg/LC_MESSAGES/blog.mo +0 -0
- data/sample/locale/bs/LC_MESSAGES/blog.mo +0 -0
- data/sample/locale/ca/LC_MESSAGES/blog.mo +0 -0
- data/sample/locale/cs/LC_MESSAGES/blog.mo +0 -0
- data/sample/locale/de/LC_MESSAGES/blog.mo +0 -0
- data/sample/locale/el/LC_MESSAGES/blog.mo +0 -0
- data/sample/locale/en/LC_MESSAGES/blog.mo +0 -0
- data/sample/locale/eo/LC_MESSAGES/blog.mo +0 -0
- data/sample/locale/es/LC_MESSAGES/blog.mo +0 -0
- data/sample/locale/fr/LC_MESSAGES/blog.mo +0 -0
- data/sample/locale/hr/LC_MESSAGES/blog.mo +0 -0
- data/sample/locale/hu/LC_MESSAGES/blog.mo +0 -0
- data/sample/locale/it/LC_MESSAGES/blog.mo +0 -0
- data/sample/locale/ja/LC_MESSAGES/blog.mo +0 -0
- data/sample/locale/ko/LC_MESSAGES/blog.mo +0 -0
- data/sample/locale/lv/LC_MESSAGES/blog.mo +0 -0
- data/sample/locale/nb/LC_MESSAGES/blog.mo +0 -0
- data/sample/locale/nl/LC_MESSAGES/blog.mo +0 -0
- data/sample/locale/pt_BR/LC_MESSAGES/blog.mo +0 -0
- data/sample/locale/ru/LC_MESSAGES/blog.mo +0 -0
- data/sample/locale/sr/LC_MESSAGES/blog.mo +0 -0
- data/sample/locale/ua/LC_MESSAGES/blog.mo +0 -0
- data/sample/locale/vi/LC_MESSAGES/blog.mo +0 -0
- data/sample/locale/zh/LC_MESSAGES/blog.mo +0 -0
- data/sample/locale/zh_TW/LC_MESSAGES/blog.mo +0 -0
- data/sample/log/development.log +635 -0
- data/sample/log/production.log +79475 -0
- data/sample/log/test.log +1592 -0
- data/sample/po/bg/blog.po +101 -0
- data/sample/po/blog.pot +102 -0
- data/sample/po/bs/blog.po +103 -0
- data/sample/po/ca/blog.po +101 -0
- data/sample/po/cs/blog.po +104 -0
- data/sample/po/de/blog.po +104 -0
- data/sample/po/el/blog.po +102 -0
- data/sample/po/en/blog.po +103 -0
- data/sample/po/eo/blog.po +102 -0
- data/sample/po/eo/tmp.patch +21 -0
- data/sample/po/es/blog.po +101 -0
- data/sample/po/fr/blog.po +102 -0
- data/sample/po/hr/blog.po +102 -0
- data/sample/po/hu/blog.po +101 -0
- data/sample/po/it/blog.po +102 -0
- data/sample/po/ja/blog.po +101 -0
- data/sample/po/ko/blog.po +102 -0
- data/sample/po/lv/blog.po +103 -0
- data/sample/po/nb/blog.po +102 -0
- data/sample/po/nl/blog.po +102 -0
- data/sample/po/pt_BR/blog.po +102 -0
- data/sample/po/ru/blog.po +102 -0
- data/sample/po/sr/blog.po +103 -0
- data/sample/po/ua/blog.po +105 -0
- data/sample/po/vi/blog.po +102 -0
- data/sample/po/zh/blog.po +101 -0
- data/sample/po/zh_TW/blog.po +103 -0
- data/sample/public/404.html +30 -0
- data/sample/public/422.html +30 -0
- data/sample/public/500.html +33 -0
- data/sample/public/favicon.ico +0 -0
- data/sample/public/images/rails.png +0 -0
- data/sample/public/index.html +275 -0
- data/sample/public/javascripts/application.js +2 -0
- data/sample/public/javascripts/controls.js +963 -0
- data/sample/public/javascripts/dragdrop.js +973 -0
- data/sample/public/javascripts/effects.js +1128 -0
- data/sample/public/javascripts/prototype.js +4320 -0
- data/sample/public/robots.txt +5 -0
- data/sample/public/stylesheets/blog.css +136 -0
- data/sample/public/stylesheets/scaffold.css +54 -0
- data/sample/script/about +4 -0
- data/sample/script/console +3 -0
- data/sample/script/dbconsole +3 -0
- data/sample/script/destroy +3 -0
- data/sample/script/generate +3 -0
- data/sample/script/performance/benchmarker +3 -0
- data/sample/script/performance/profiler +3 -0
- data/sample/script/plugin +3 -0
- data/sample/script/runner +3 -0
- data/sample/script/server +3 -0
- data/sample/test/fixtures/articles.yml +11 -0
- data/sample/test/functional/articles_controller_test.rb +45 -0
- data/sample/test/performance/browsing_test.rb +9 -0
- data/sample/test/result/en/list.html +69 -0
- data/sample/test/test_helper.rb +38 -0
- data/sample/test/unit/article_test.rb +8 -0
- data/sample/test/unit/helpers/articles_helper_test.rb +4 -0
- data/sample/vendor/plugins/lang_helper/README +17 -0
- data/sample/vendor/plugins/lang_helper/Rakefile +17 -0
- data/sample/vendor/plugins/lang_helper/init.rb +21 -0
- data/sample/vendor/plugins/lang_helper/lib/lang_helper.rb +32 -0
- data/sample/vendor/plugins/lang_helper/locale/bg/LC_MESSAGES/lang_helper.mo +0 -0
- data/sample/vendor/plugins/lang_helper/locale/bs/LC_MESSAGES/lang_helper.mo +0 -0
- data/sample/vendor/plugins/lang_helper/locale/ca/LC_MESSAGES/lang_helper.mo +0 -0
- data/sample/vendor/plugins/lang_helper/locale/cs/LC_MESSAGES/lang_helper.mo +0 -0
- data/sample/vendor/plugins/lang_helper/locale/de/LC_MESSAGES/lang_helper.mo +0 -0
- data/sample/vendor/plugins/lang_helper/locale/el/LC_MESSAGES/lang_helper.mo +0 -0
- data/sample/vendor/plugins/lang_helper/locale/eo/LC_MESSAGES/lang_helper.mo +0 -0
- data/sample/vendor/plugins/lang_helper/locale/es/LC_MESSAGES/lang_helper.mo +0 -0
- data/sample/vendor/plugins/lang_helper/locale/fr/LC_MESSAGES/lang_helper.mo +0 -0
- data/sample/vendor/plugins/lang_helper/locale/hr/LC_MESSAGES/lang_helper.mo +0 -0
- data/sample/vendor/plugins/lang_helper/locale/hu/LC_MESSAGES/lang_helper.mo +0 -0
- data/sample/vendor/plugins/lang_helper/locale/it/LC_MESSAGES/lang_helper.mo +0 -0
- data/sample/vendor/plugins/lang_helper/locale/ja/LC_MESSAGES/lang_helper.mo +0 -0
- data/sample/vendor/plugins/lang_helper/locale/ko/LC_MESSAGES/lang_helper.mo +0 -0
- data/sample/vendor/plugins/lang_helper/locale/lv/LC_MESSAGES/lang_helper.mo +0 -0
- data/sample/vendor/plugins/lang_helper/locale/nb/LC_MESSAGES/lang_helper.mo +0 -0
- data/sample/vendor/plugins/lang_helper/locale/nl/LC_MESSAGES/lang_helper.mo +0 -0
- data/sample/vendor/plugins/lang_helper/locale/pt_BR/LC_MESSAGES/lang_helper.mo +0 -0
- data/sample/vendor/plugins/lang_helper/locale/ru/LC_MESSAGES/lang_helper.mo +0 -0
- data/sample/vendor/plugins/lang_helper/locale/sr/LC_MESSAGES/lang_helper.mo +0 -0
- data/sample/vendor/plugins/lang_helper/locale/ua/LC_MESSAGES/lang_helper.mo +0 -0
- data/sample/vendor/plugins/lang_helper/locale/vi/LC_MESSAGES/lang_helper.mo +0 -0
- data/sample/vendor/plugins/lang_helper/locale/zh/LC_MESSAGES/lang_helper.mo +0 -0
- data/sample/vendor/plugins/lang_helper/locale/zh_TW/LC_MESSAGES/lang_helper.mo +0 -0
- data/sample/vendor/plugins/lang_helper/po/bg/lang_helper.po +27 -0
- data/sample/vendor/plugins/lang_helper/po/bs/lang_helper.po +27 -0
- data/sample/vendor/plugins/lang_helper/po/ca/lang_helper.po +27 -0
- data/sample/vendor/plugins/lang_helper/po/cs/lang_helper.po +29 -0
- data/sample/vendor/plugins/lang_helper/po/de/lang_helper.po +29 -0
- data/sample/vendor/plugins/lang_helper/po/el/lang_helper.po +27 -0
- data/sample/vendor/plugins/lang_helper/po/eo/lang_helper.po +28 -0
- data/sample/vendor/plugins/lang_helper/po/es/lang_helper.po +28 -0
- data/sample/vendor/plugins/lang_helper/po/fr/lang_helper.po +27 -0
- data/sample/vendor/plugins/lang_helper/po/hr/lang_helper.po +27 -0
- data/sample/vendor/plugins/lang_helper/po/hu/lang_helper.po +27 -0
- data/sample/vendor/plugins/lang_helper/po/it/lang_helper.po +27 -0
- data/sample/vendor/plugins/lang_helper/po/ja/lang_helper.po +28 -0
- data/sample/vendor/plugins/lang_helper/po/ko/lang_helper.po +27 -0
- data/sample/vendor/plugins/lang_helper/po/lang_helper.pot +28 -0
- data/sample/vendor/plugins/lang_helper/po/lv/lang_helper.po +28 -0
- data/sample/vendor/plugins/lang_helper/po/nb/lang_helper.po +29 -0
- data/sample/vendor/plugins/lang_helper/po/nl/lang_helper.po +28 -0
- data/sample/vendor/plugins/lang_helper/po/pt_BR/lang_helper.po +27 -0
- data/sample/vendor/plugins/lang_helper/po/ru/lang_helper.po +25 -0
- data/sample/vendor/plugins/lang_helper/po/sr/lang_helper.po +28 -0
- data/sample/vendor/plugins/lang_helper/po/ua/lang_helper.po +30 -0
- data/sample/vendor/plugins/lang_helper/po/vi/lang_helper.po +27 -0
- data/sample/vendor/plugins/lang_helper/po/zh/lang_helper.po +27 -0
- data/sample/vendor/plugins/lang_helper/po/zh_TW/lang_helper.po +29 -0
- data/test/README +6 -0
- data/test/Rakefile +27 -0
- data/test/app/controllers/application_controller.rb +18 -0
- data/test/app/controllers/articles_controller.rb +114 -0
- data/test/app/controllers/mailers_controller.rb +18 -0
- data/test/app/controllers/users_controller.rb +19 -0
- data/test/app/helpers/application_helper.rb +3 -0
- data/test/app/helpers/articles_helper.rb +2 -0
- data/test/app/models/article.rb +9 -0
- data/test/app/models/human_resources/resume.rb +3 -0
- data/test/app/models/mailer.rb +38 -0
- data/test/app/models/user.rb +4 -0
- data/test/app/models/user_observer.rb +7 -0
- data/test/app/views/articles/_form.html.erb +13 -0
- data/test/app/views/articles/_form_fr.html.erb +1 -0
- data/test/app/views/articles/active_form_error.html.erb +1 -0
- data/test/app/views/articles/change_title_error_messages_for.html.erb +15 -0
- data/test/app/views/articles/edit.html.erb +9 -0
- data/test/app/views/articles/list.html.erb +25 -0
- data/test/app/views/articles/list_fr.html.erb +1 -0
- data/test/app/views/articles/multi_error_messages_for.html.erb +19 -0
- data/test/app/views/articles/new.html.erb +8 -0
- data/test/app/views/articles/show.html.erb +9 -0
- data/test/app/views/layouts/application.html.erb +16 -0
- data/test/app/views/layouts/mailers.html.erb +20 -0
- data/test/app/views/layouts/users.html.erb +14 -0
- data/test/app/views/mailer/coverpage.html.erb +6 -0
- data/test/app/views/mailer/coverpage_fr.html.erb +6 -0
- data/test/app/views/mailer/index.html.erb +1 -0
- data/test/app/views/mailer/singlepart.html.erb +3 -0
- data/test/app/views/mailer/singlepart_fr.html.erb +3 -0
- data/test/app/views/users/custom_error_message.html.erb +13 -0
- data/test/app/views/users/custom_error_message_fr.html.erb +13 -0
- data/test/app/views/users/distance_of_time_in_words.html.erb +18 -0
- data/test/config/boot.rb +109 -0
- data/test/config/database.yml +22 -0
- data/test/config/environment.rb +45 -0
- data/test/config/environments/development.rb +17 -0
- data/test/config/environments/production.rb +27 -0
- data/test/config/environments/test.rb +27 -0
- data/test/config/initializers/backtrace_silencers.rb +7 -0
- data/test/config/initializers/inflections.rb +10 -0
- data/test/config/initializers/mime_types.rb +5 -0
- data/test/config/initializers/new_rails_defaults.rb +19 -0
- data/test/config/initializers/session_store.rb +15 -0
- data/test/config/routes.rb +13 -0
- data/test/db/development.sqlite3 +0 -0
- data/test/db/schema.rb +45 -0
- data/test/db/test.sqlite3 +0 -0
- data/test/doc/README_FOR_APP +2 -0
- data/test/locale/ja/LC_MESSAGES/rails_test.mo +0 -0
- data/test/log/development.log +1284 -0
- data/test/log/test.log +5595 -0
- data/test/po/ja/rails_test.po +206 -0
- data/test/po/rails_test.pot +206 -0
- data/test/public/404.html +30 -0
- data/test/public/422.html +30 -0
- data/test/public/500.html +33 -0
- data/test/public/favicon.ico +0 -0
- data/test/public/images/rails.png +0 -0
- data/test/public/index.html +28 -0
- data/test/public/javascripts/application.js +2 -0
- data/test/public/javascripts/controls.js +963 -0
- data/test/public/javascripts/dragdrop.js +973 -0
- data/test/public/javascripts/effects.js +1128 -0
- data/test/public/javascripts/prototype.js +4320 -0
- data/test/public/robots.txt +5 -0
- data/test/public/stylesheets/blog.css +136 -0
- data/test/public/stylesheets/scaffold.css +54 -0
- data/test/script/about +4 -0
- data/test/script/console +3 -0
- data/test/script/dbconsole +3 -0
- data/test/script/destroy +3 -0
- data/test/script/generate +3 -0
- data/test/script/performance/benchmarker +3 -0
- data/test/script/performance/profiler +3 -0
- data/test/script/plugin +3 -0
- data/test/script/runner +3 -0
- data/test/script/server +3 -0
- data/test/test/fixtures/articles.yml +13 -0
- data/test/test/functional/articles_controller_test.rb +97 -0
- data/test/test/functional/mailers_controller_test.rb +54 -0
- data/test/test/functional/users_controller_test.rb +47 -0
- data/test/test/performance/browsing_test.rb +9 -0
- data/test/test/result/en/change_title_error_messages_for.html +89 -0
- data/test/test/result/en/create_error.html +97 -0
- data/test/test/result/en/custom_error_message.html +84 -0
- data/test/test/result/en/custom_error_message_with_plural.html +84 -0
- data/test/test/result/en/distance_of_time_in_words.html +32 -0
- data/test/test/result/en/list.html +62 -0
- data/test/test/result/en/multi_error_messages_for.html +155 -0
- data/test/test/result/en/multipart.html +175 -0
- data/test/test/result/en/new.html +97 -0
- data/test/test/result/en/show.html +33 -0
- data/test/test/result/en/singlepart.html +10 -0
- data/test/test/result/fr/custom_error_message.html +84 -0
- data/test/test/result/fr/custom_error_message_with_plural.html +84 -0
- data/test/test/result/fr/distance_of_time_in_words.html +32 -0
- data/test/test/result/fr/list.html +17 -0
- data/test/test/result/fr/multipart.html +175 -0
- data/test/test/result/fr/new.html +25 -0
- data/test/test/result/fr/singlepart.html +10 -0
- data/test/test/result/ja/change_title_error_messages_for.html +89 -0
- data/test/test/result/ja/create_error.html +97 -0
- data/test/test/result/ja/custom_error_message.html +84 -0
- data/test/test/result/ja/custom_error_message_with_plural.html +84 -0
- data/test/test/result/ja/distance_of_time_in_words.html +32 -0
- data/test/test/result/ja/list.html +62 -0
- data/test/test/result/ja/multi_error_messages_for.html +155 -0
- data/test/test/result/ja/multipart.html +175 -0
- data/test/test/result/ja/new.html +97 -0
- data/test/test/result/ja/show.html +33 -0
- data/test/test/result/ja/singlepart.html +10 -0
- data/test/test/test_helper.rb +83 -0
- data/test/test/unit/article_test.rb +8 -0
- data/test/test/unit/helpers/articles_helper_test.rb +4 -0
- metadata +754 -0
data/sample/Rakefile
ADDED
@@ -0,0 +1,11 @@
|
|
1
|
+
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
|
+
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
|
+
|
4
|
+
require(File.join(File.dirname(__FILE__), 'config', 'boot'))
|
5
|
+
|
6
|
+
require 'rake'
|
7
|
+
require 'rake/testtask'
|
8
|
+
require 'rake/rdoctask'
|
9
|
+
|
10
|
+
require 'tasks/rails'
|
11
|
+
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# Filters added to this controller apply to all controllers in the application.
|
2
|
+
# Likewise, all the methods added will be available for all controllers.
|
3
|
+
class ApplicationController < ActionController::Base
|
4
|
+
helper :all # include all helpers, all the time
|
5
|
+
protect_from_forgery # See ActionController::RequestForgeryProtection for details
|
6
|
+
# Scrub sensitive parameters from your log
|
7
|
+
# filter_parameter_logging :password
|
8
|
+
|
9
|
+
# Initialize GetText and Content-Type.
|
10
|
+
# You need to call this once a request from WWW browser.
|
11
|
+
# You can select the scope of the textdomain.
|
12
|
+
# 1. If you call init_gettext in ApplicationControler,
|
13
|
+
# The textdomain apply whole your application.
|
14
|
+
# 2. If you call init_gettext in each controllers
|
15
|
+
# (In this sample, blog_controller.rb is applicable)
|
16
|
+
# The textdomains are applied to each controllers/views.
|
17
|
+
init_gettext "blog" # textdomain, options(:charset, :content_type)
|
18
|
+
|
19
|
+
I18n.supported_locales = Dir[ File.join(RAILS_ROOT, 'locale/*') ].collect{|v| File.basename(v)}
|
20
|
+
|
21
|
+
=begin
|
22
|
+
# You can set callback methods. These methods are called on the each WWW request.
|
23
|
+
def before_init_gettext(cgi)
|
24
|
+
p "before_init_gettext"
|
25
|
+
end
|
26
|
+
def after_init_gettext(cgi)
|
27
|
+
p "after_init_gettext"
|
28
|
+
end
|
29
|
+
=end
|
30
|
+
|
31
|
+
=begin
|
32
|
+
# you can redefined the title/explanation of the top of the error message.
|
33
|
+
ActionView::Helpers::ActiveRecordHelper::L10n.set_error_message_title(N_("An error is occured on %{record}"), N_("%{num} errors are occured on %{record}"))
|
34
|
+
ActionView::Helpers::ActiveRecordHelper::L10n.set_error_message_explanation(N_("The error is:"), N_("The errors are:"))
|
35
|
+
=end
|
36
|
+
|
37
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# articles_controller.rb - a sample script for Ruby on Rails
|
2
|
+
#
|
3
|
+
# Copyright (C) 2005-2009 Masao Mutoh
|
4
|
+
#
|
5
|
+
# This file is distributed under the same license as Ruby-GetText-Package.
|
6
|
+
|
7
|
+
|
8
|
+
class ArticlesController < ApplicationController
|
9
|
+
# If you want to have textdomains each as controllers.
|
10
|
+
# You need to bind textdomain here.
|
11
|
+
|
12
|
+
#init_gettext "article"
|
13
|
+
|
14
|
+
# GET /articles
|
15
|
+
# GET /articles.xml
|
16
|
+
def index
|
17
|
+
@articles = Article.find(:all)
|
18
|
+
|
19
|
+
respond_to do |format|
|
20
|
+
format.html # index.html.erb
|
21
|
+
format.xml { render :xml => @articles }
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
# GET /articles/1
|
26
|
+
# GET /articles/1.xml
|
27
|
+
def show
|
28
|
+
@article = Article.find(params[:id])
|
29
|
+
|
30
|
+
respond_to do |format|
|
31
|
+
format.html # show.html.erb
|
32
|
+
format.xml { render :xml => @article }
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# GET /articles/new
|
37
|
+
# GET /articles/new.xml
|
38
|
+
def new
|
39
|
+
@article = Article.new
|
40
|
+
|
41
|
+
respond_to do |format|
|
42
|
+
format.html # new.html.erb
|
43
|
+
format.xml { render :xml => @article }
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
# GET /articles/1/edit
|
48
|
+
def edit
|
49
|
+
@article = Article.find(params[:id])
|
50
|
+
end
|
51
|
+
|
52
|
+
# POST /articles
|
53
|
+
# POST /articles.xml
|
54
|
+
def create
|
55
|
+
@article = Article.new(params[:article])
|
56
|
+
|
57
|
+
respond_to do |format|
|
58
|
+
if @article.save
|
59
|
+
flash[:notice] = _('Article was successfully created.')
|
60
|
+
format.html { redirect_to(@article) }
|
61
|
+
format.xml { render :xml => @article, :status => :created, :location => @article }
|
62
|
+
else
|
63
|
+
format.html { render :action => "new" }
|
64
|
+
format.xml { render :xml => @article.errors, :status => :unprocessable_entity }
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
# PUT /articles/1
|
70
|
+
# PUT /articles/1.xml
|
71
|
+
def update
|
72
|
+
@article = Article.find(params[:id])
|
73
|
+
|
74
|
+
respond_to do |format|
|
75
|
+
if @article.update_attributes(params[:article])
|
76
|
+
flash[:notice] = _('Article was successfully updated.')
|
77
|
+
format.html { redirect_to(@article) }
|
78
|
+
format.xml { head :ok }
|
79
|
+
else
|
80
|
+
format.html { render :action => "edit" }
|
81
|
+
format.xml { render :xml => @article.errors, :status => :unprocessable_entity }
|
82
|
+
end
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
86
|
+
# DELETE /articles/1
|
87
|
+
# DELETE /articles/1.xml
|
88
|
+
def destroy
|
89
|
+
@article = Article.find(params[:id])
|
90
|
+
@article.destroy
|
91
|
+
|
92
|
+
respond_to do |format|
|
93
|
+
format.html { redirect_to(articles_url) }
|
94
|
+
format.xml { head :ok }
|
95
|
+
end
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# articles_helper.rb - a sample script for Ruby on Rails
|
2
|
+
#
|
3
|
+
# Copyright (C) 2005-2008 Masao Mutoh
|
4
|
+
#
|
5
|
+
# This file is distributed under the same license as Ruby-GetText-Package.
|
6
|
+
#
|
7
|
+
# ArticlesHelper is bound a textdomain which is bound in application.rb or
|
8
|
+
# articles_controller.rb.
|
9
|
+
# So you don't need to call bindtextdomain here.
|
10
|
+
#
|
11
|
+
|
12
|
+
module ArticlesHelper
|
13
|
+
def show_article(article, show_link = true)
|
14
|
+
ret = %Q[
|
15
|
+
<h2>#{article["title"]} (#{article["lastupdate"]})</h2>
|
16
|
+
<pre>#{article["description"]}</pre>
|
17
|
+
]
|
18
|
+
if show_link
|
19
|
+
ret += %Q[<p style="text-align:right;margin-right:3em">#{link_to(_("Show"), :action => 'show', :id => article)}</p>]
|
20
|
+
end
|
21
|
+
ret
|
22
|
+
end
|
23
|
+
|
24
|
+
def show_list(articles)
|
25
|
+
ret = ""
|
26
|
+
articles.each_with_index do |article, index|
|
27
|
+
ret << %Q[<li>#{article["lastupdate"]}: #{link_to((h article["title"]), :action => 'show', :id => article)}</li>]
|
28
|
+
break if index > 9
|
29
|
+
end
|
30
|
+
ret
|
31
|
+
end
|
32
|
+
|
33
|
+
def show_navigation
|
34
|
+
articles = Article.find(:all, :order => 'lastupdate desc, id desc')
|
35
|
+
%Q[
|
36
|
+
<div class="navigation">
|
37
|
+
<img src="/images/rails.png" width="100" height="100" />
|
38
|
+
<div class="window">
|
39
|
+
#{show_language}
|
40
|
+
</div>
|
41
|
+
<div class="window">
|
42
|
+
<h4>] + _("Ruby Links") + %Q[</h4>
|
43
|
+
<dl>
|
44
|
+
<li><a href="http://www.ruby-lang.org/">Ruby</a></li>
|
45
|
+
<li><a href="http://rubyforge.org/projects/gettext/">Ruby-GetText-Package</a></li>
|
46
|
+
<li><a href="http://wiki.rubyonrails.com/">Ruby on Rails Wiki</a></li>
|
47
|
+
</dl>
|
48
|
+
</div>
|
49
|
+
<div class="window">
|
50
|
+
<h4>] + _("Old articles") + %Q[</h4>
|
51
|
+
<p>
|
52
|
+
<dl>
|
53
|
+
#{show_list(articles)}
|
54
|
+
</dl>
|
55
|
+
</p>
|
56
|
+
</div>
|
57
|
+
</div>
|
58
|
+
]
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
class Article < ActiveRecord::Base
|
2
|
+
validates_presence_of :title
|
3
|
+
validates_length_of :description, :minimum => 10
|
4
|
+
|
5
|
+
# With your own message with L10n.
|
6
|
+
# old style(Backward compatibility).
|
7
|
+
# blog.po in RAILS_ROOT/po/*/ is used.
|
8
|
+
# validates_presence_of :title, :message => N_("can't be empty")
|
9
|
+
# validates_length_of :description, :minimum => 10, :message => N_("is too short (min is %d characters)")
|
10
|
+
|
11
|
+
# new style (you can use %{fn} and %d freely in the message)
|
12
|
+
# blog.po in RAILS_ROOT/po/*/ is used.
|
13
|
+
# validates_presence_of :title, :message => N_("%{fn} can't be empty!")
|
14
|
+
# validates_length_of :description, :minimum => 10, :message => N_("%{fn} is too short (min is %d characters)")
|
15
|
+
#
|
16
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
<h1><%= _("Editing article") %></h1>
|
2
|
+
|
3
|
+
<%= error_messages_for :article %>
|
4
|
+
|
5
|
+
<% form_for(@article) do |f| %>
|
6
|
+
<p>
|
7
|
+
<p><%= f.label :lastupdate %></p>
|
8
|
+
<p><%= f.date_select :lastupdate, :use_month_numbers => true %></p>
|
9
|
+
<p><%= f.label :title, _("Title: Required.") %></p>
|
10
|
+
<p><%= f.text_field :title %></p>
|
11
|
+
<p><%= f.label :title, _("Description: More than 10 characters.") %></p>
|
12
|
+
<p><%= f.text_area :description %></p>
|
13
|
+
<p><%= f.submit _("Edit") %></p>
|
14
|
+
</p>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<p>
|
18
|
+
<%= link_to _('Show'), @article %> |
|
19
|
+
<%= link_to _('Destroy'), @article, :confirm => _('Are you sure?'), :method => :delete %> |
|
20
|
+
<%= link_to _('Back'), articles_path %>
|
21
|
+
</p>
|
22
|
+
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<h1><%= _("GetText Sample Blog on RoR") %></h1>
|
2
|
+
|
3
|
+
<p style="text-align:right">
|
4
|
+
<%= link_to _('New article'), new_article_path %>
|
5
|
+
</p>
|
6
|
+
<% if @articles.size == 0 %>
|
7
|
+
<p><%= _("No articles were found.") %></p>
|
8
|
+
<% else %>
|
9
|
+
<%
|
10
|
+
@articles.each_with_index do |article, index|
|
11
|
+
%>
|
12
|
+
<%= show_article(article) %>
|
13
|
+
<%
|
14
|
+
break if index > 1
|
15
|
+
end
|
16
|
+
%>
|
17
|
+
<% end %>
|
18
|
+
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<h1><%= _("New article") %></h1>
|
2
|
+
|
3
|
+
<%= error_messages_for :article %>
|
4
|
+
|
5
|
+
<% form_for(@article) do |f| %>
|
6
|
+
<p>
|
7
|
+
<p><%= f.label :lastupdate %></p>
|
8
|
+
<p><%= f.date_select :lastupdate, :use_month_numbers => true %></p>
|
9
|
+
<p><%= f.label :title, _("Title: Required.") %></p>
|
10
|
+
<p><%= f.text_field :title %></p>
|
11
|
+
<p><%= f.label :title, _("Description: More than 10 characters.") %></p>
|
12
|
+
<p><%= f.text_area :description %></p>
|
13
|
+
<p><%= f.submit _("Create") %></p>
|
14
|
+
</p>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<p>
|
18
|
+
<%= link_to _('Back'), articles_path %>
|
19
|
+
</p>
|
20
|
+
|
@@ -0,0 +1,27 @@
|
|
1
|
+
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
|
2
|
+
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
3
|
+
|
4
|
+
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<%= locale.language %>" lang="<%= locale.language %>">
|
5
|
+
<head>
|
6
|
+
<meta http-equiv="content-type" content="text/html;charset=<%= GetText.output_charset %>" />
|
7
|
+
<title><%= _('GetText Sample Blog on RoR') %>: <%= controller.action_name %></title>
|
8
|
+
<%= stylesheet_link_tag 'scaffold' %>
|
9
|
+
<%= stylesheet_link_tag 'blog' %>
|
10
|
+
</head>
|
11
|
+
<body>
|
12
|
+
<div class = "main">
|
13
|
+
<p style="color: green"><%= flash[:notice] %></p>
|
14
|
+
|
15
|
+
<%= yield %>
|
16
|
+
|
17
|
+
<div class="copyright">
|
18
|
+
Copyright (C) 2005-2009 Masao Mutoh
|
19
|
+
</div>
|
20
|
+
|
21
|
+
</div>
|
22
|
+
|
23
|
+
<%= show_navigation %>
|
24
|
+
|
25
|
+
</body>
|
26
|
+
</html>
|
27
|
+
|
@@ -0,0 +1,109 @@
|
|
1
|
+
# Don't change this file!
|
2
|
+
# Configure your app in config/environment.rb and config/environments/*.rb
|
3
|
+
|
4
|
+
RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT)
|
5
|
+
|
6
|
+
module Rails
|
7
|
+
class << self
|
8
|
+
def boot!
|
9
|
+
unless booted?
|
10
|
+
preinitialize
|
11
|
+
pick_boot.run
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def booted?
|
16
|
+
defined? Rails::Initializer
|
17
|
+
end
|
18
|
+
|
19
|
+
def pick_boot
|
20
|
+
(vendor_rails? ? VendorBoot : GemBoot).new
|
21
|
+
end
|
22
|
+
|
23
|
+
def vendor_rails?
|
24
|
+
File.exist?("#{RAILS_ROOT}/vendor/rails")
|
25
|
+
end
|
26
|
+
|
27
|
+
def preinitialize
|
28
|
+
load(preinitializer_path) if File.exist?(preinitializer_path)
|
29
|
+
end
|
30
|
+
|
31
|
+
def preinitializer_path
|
32
|
+
"#{RAILS_ROOT}/config/preinitializer.rb"
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
class Boot
|
37
|
+
def run
|
38
|
+
load_initializer
|
39
|
+
Rails::Initializer.run(:set_load_path)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
class VendorBoot < Boot
|
44
|
+
def load_initializer
|
45
|
+
require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer"
|
46
|
+
Rails::Initializer.run(:install_gem_spec_stubs)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class GemBoot < Boot
|
51
|
+
def load_initializer
|
52
|
+
self.class.load_rubygems
|
53
|
+
load_rails_gem
|
54
|
+
require 'initializer'
|
55
|
+
end
|
56
|
+
|
57
|
+
def load_rails_gem
|
58
|
+
if version = self.class.gem_version
|
59
|
+
gem 'rails', version
|
60
|
+
else
|
61
|
+
gem 'rails'
|
62
|
+
end
|
63
|
+
rescue Gem::LoadError => load_error
|
64
|
+
$stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.)
|
65
|
+
exit 1
|
66
|
+
end
|
67
|
+
|
68
|
+
class << self
|
69
|
+
def rubygems_version
|
70
|
+
Gem::RubyGemsVersion rescue nil
|
71
|
+
end
|
72
|
+
|
73
|
+
def gem_version
|
74
|
+
if defined? RAILS_GEM_VERSION
|
75
|
+
RAILS_GEM_VERSION
|
76
|
+
elsif ENV.include?('RAILS_GEM_VERSION')
|
77
|
+
ENV['RAILS_GEM_VERSION']
|
78
|
+
else
|
79
|
+
parse_gem_version(read_environment_rb)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
def load_rubygems
|
84
|
+
require 'rubygems'
|
85
|
+
min_version = '1.3.1'
|
86
|
+
unless rubygems_version >= min_version
|
87
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.)
|
88
|
+
exit 1
|
89
|
+
end
|
90
|
+
|
91
|
+
rescue LoadError
|
92
|
+
$stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org)
|
93
|
+
exit 1
|
94
|
+
end
|
95
|
+
|
96
|
+
def parse_gem_version(text)
|
97
|
+
$1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/
|
98
|
+
end
|
99
|
+
|
100
|
+
private
|
101
|
+
def read_environment_rb
|
102
|
+
File.read("#{RAILS_ROOT}/config/environment.rb")
|
103
|
+
end
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
# All that for this:
|
109
|
+
Rails.boot!
|