言語ネゴシエーション のバックアップ差分(No.1)
更新- バックアップ一覧
- 現在との差分 を表示
- ソース を表示
- バックアップ を表示
- ソフトウェア/rails/言語ネゴシエーション へ行く。
- 追加された行はこの色です。
- 削除された行はこの色です。
[[公開メモ]] #contents * Rails で言語ネゴシエーション(Language Negotiation) [#h05f99dd] http://blog.omdb-beta.org/ を見ながら、ブラウザの Language Negotiation の機能を使って rails アプリケーションの多言語化する方法を調べてみた。 やりたい内容としては - views/*/*.html.ja.erb と views/*/*.html.en.erb とを両方作っておき、 自動的に切り替えて読み込む - appache のネゴシエーション機能を使ってキャッシュされたページも 自動で切り替わるようにする rails アプリの多言語化については他にも、 -- ネゴシエーションっぽいもの - [[ロケールによるテンプレート切り替え>http://www.yotabanana.com/lab/?date=20060224#p01]] - ネゴシエーションではなく Ruby-GetText を使った方法やネゴシエーションとの比較 -- [[Railsで日本語を使う時に必須のパッケージ Ruby-GetText>http://blog.masuidrive.jp/articles/2006/07/03/gettext]] -- [[Ruby on RailsでRuby-GetText-Packageを使う>http://www.yotabanana.com/hiki/ja/ruby-gettext-howto-ror.html]] -- [[ruby-gettext>http://tech.feedforce.jp/ruby-gettext.html]] -- [[Rails で行こう! - Ruby on Rails を学ぶ>http://d.hatena.ne.jp/elm200/20070719/1184856941]] -- [[Rails のためのものぐさな Web アプリケーションの国際化手法>http://d.hatena.ne.jp/secondlife/20070207/1170835130]] - rails エラーメッセージの日本語化 -- [[RubyOnRails を使ってみる 【第 5 回】 ActiveHeart>http://jp.rubyist.net/magazine/?0012-RubyOnRails]] などがあるみたい。 以下手順。 * negotiation という名前のアプリケーションの作成 [#vb4e8dd6] LANG:console $ rails negotiation $ cd negotiation * 開発用サーバーの起動と環境の確認 [#s35cbbb4] LANG:console $ script/server & $ wget -qO- http://localhost:3000/ | html2text ... ****** Welcome aboard ****** ***** You’re riding Ruby on Rails! ***** **** About_your_application’s_environment **** ... $ wget -qO- http://localhost:3000/rails/info/properties | html2text Ruby version 1.8.7 (i486-linux) RubyGems version 1.3.2 Rails version 2.2.2 Active Record version 2.2.2 Action Pack version 2.2.2 Active Resource version 2.2.2 Action Mailer version 2.2.2 Active Support version 2.2.2 Edge Rails revision unknown Application root /home/samba/www/rails/negotiation Environment development Database adapter sqlite3 Database schema version 0   * test コントローラとビューの作成 [#k0a5e25a] LANG:console $ script/generate controller Test exists app/controllers/ exists app/helpers/ create app/views/test exists test/functional/ create app/controllers/test_controller.rb create test/functional/test_controller_test.rb create app/helpers/test_helper.rb $ jed app/controllers/test_controller.rb class TestController < ApplicationController def index end end $ echo "Test" > app/views/test/index.html.erb $ wget -qO- http://localhost:3000/test Test * 多言語化したビューの作成 [#b2db2fc3] 今作ったビューを削除して、日本語版と英語版を作成。 まだ rails に手を入れていないので、そのままではエラーになる。 LANG:console $ rm app/views/test/index.html.erb $ echo "Test" > app/views/test/index.html.en.erb $ echo "テスト" > app/views/test/index.html.ja.erb $ wget -O- http://localhost:3000/test 500 Internal Server Error これを正しく表示できるようにするのが目標。 * [#w47da434]
Counter: 9573 (from 2010/06/03),
today: 2,
yesterday: 0