&pgid;

** railsÊÙ¶¯²ñ°ìÍ÷ [#dd041670]
#ls2(rails)

** Âè7²óÊÙ¶¯²ñ¤Î¥Í¥¿ [#jeadb044]
¥Í¥¿¤â¤È¤Ï²¼µ­¤Ç¤¹¡£

-Ruby on Rails¤ÇÆüËܸ줷¤«»È¤ï¤Ê¤¤¾ì¹ç¤Ç¤âRuby-GetText-Package¤ò»È¤¦Íýͳ
http://www.yotabanana.com/lab/20060505.html
-Ruby-GetText-Package¤È¤Ï¡©
http://www.yotabanana.com/hiki/ja/ruby-gettext.html
-GetText¤Îrdoc
http://www.yotabanana.com/gettextapi/
-Rails API ¥É¥­¥å¥á¥ó¥È ActionView::Helpers::ActiveRecordHelper
http://railsapi.masuidrive.jp/module/ActionView%3A%3AHelpers%3A%3AActiveRecordHelper

** Æü»þ [#g4f8ac7b]
- 2006/11/24(¶â) 

** »²²Ã¼Ô [#u5cc1f6d]
-[[»ÖÅÄ]](ȯɽ¼Ô)
-[[Ãݼ]]¤µ¤ó
-[[¿ÊÃÏ]]¤µ¤ó
-[[¾®¾Â]]¤µ¤ó
-[[¥Õ¥é¥Ã¥Äµ×Ëö¤µ¤ó:http://flatz.jp]]

µ×Ëö¤µ¤ó¡¢¤É¤¦¤â¤¢¤ê¤¬¤È¤¦¤´¤¶¤¤¤Þ¤¹¡ª¤Þ¤¿»²²Ã¤·¤Æ¤Í¡¼¡¼¡£ &bigsmile;
#blikimore

** Æ°²è [#g3db69c1]

** gettext¤È¤Ï [#hff6572b]
- [[WikiPedia.ja:Gettext]]
- po¥Õ¥¡¥¤¥ë
 #: app/controllers/application.rb:11
 msgid "The errors are:"
 msgstr "¥¨¥é¡¼¤¬¤¢¤ê¤Þ¤¹¡£"

** Ruby-GetText¤È¤Ï? [#s344a8af]
- GetText::Rails
- gem
 gem install gettext

**ºî¶È¤Î¤Ê¤¬¤ì [#b2fda889]
-¥³¡¼¥Ç¥£¥ó¥°¤¹¤ë
 echo _("The errors are:")
- msgid¤Ï¥½¡¼¥¹¥³¡¼¥É¤«¤é¼«Æ°Åª¤ËÃê½Ð¡£
http://www.yotabanana.com/gettextapi/classes/GetText.html#M000045
 #: app/controllers/application.rb:11
 msgid "The errors are:"
 msgstr ""
- msgstr¤òËÝÌõ
 #: app/controllers/application.rb:11
 msgid "The errors are:"
 msgstr ""
-mo¤òÀ¸À®
http://www.yotabanana.com/gettextapi/classes/GetText.html#M000049
- ¥³¡¼¥Ç¥£¥ó¥°¤ò³¤±¤ë
- poºÆÀ¸À®
updatepo
http://www.yotabanana.com/gettextapi/classes/GetText.html#M000050
- msgstr¤òËÝÌõ¤·¤Æmo¤òÀ¸À®
- ¥³¡¼¥Ç¥£¥ó¥°¤ò³¤±¤ë...

** Ruby-GetText¤Îrails¤Ø¤ÎÁȤ߹þ¤ß [#n87bb105]
-GetText::Rails
http://www.yotabanana.com/gettextapi/classes/GetText/Rails.html
+config/environment.rb¤ÎÀèƬ¤Ë
 $KCODE = 'u'            # UTF-8¤Î¾ì¹ç¡£'s' = SJIS, 'e' = EUC-JP¤Ê¤É
 require 'jcode'         # String¥¯¥é¥¹¤Î¥á¥½¥Ã¥É¤Ê¤É¤ò$KCODE¤Ë»ØÄꤷ¤¿
                         # ʸ»ú¥³¡¼¥É¤ÇŬÀÚ¤ËÆ°ºî¤¹¤ë¤è¤¦¤ËÃÖ¤­´¹¤¨¤Þ¤¹
+config/environment.rb¤ÎËöÈø¤Ë
 require 'gettext/rails' # Ruby-GetText-Package¤ò»È¤¦Àë¸À¤Ç¤¹¡£
+app/controllers/application.rb¤Ë
 class ApplicationController < ActionController::Base
  init_gettext "sample"
 end
http://www.yotabanana.com/gettextapi/classes/ActionController/Base.html#M000016
+

** msgid¤ò»ØÄꤷ¤Ê¤¬¤é¥³¡¼¥Ç¥£¥ó¥° [#h267444f]
***¥³¥ó¥È¥í¡¼¥é [#r5f7b8d1]
http://www.yotabanana.com/hiki/ja/ruby-gettext-howto-ror.html#Controller
-¡Ö_¡×¤Þ¤¿¤Ï¡Ön_¡×
***¥Ó¥å¡¼ [#t39429f0]
http://www.yotabanana.com/hiki/ja/ruby-gettext-howto-ror.html#Views/ActionMailer

-¡Ö_¡×¤Þ¤¿¤Ï¡Ön_¡×
***¥â¥Ç¥ë [#d4afe481]
http://www.yotabanana.com/hiki/ja/ruby-gettext-howto-ror.html#Models
- validates_xxx_of ¤Ç¤Î¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
--¡ÖN_¡×¤Þ¤¿¤Ï¡ÖNn_¡×
- validate¤Ç¤Î¥¨¥é¡¼¥á¥Ã¥»¡¼¥¸
--¡Ö_¡×¤Þ¤¿¤Ï¡Ön_¡×
 errors.add("title", _("%{fn} is not correct: %{title}") % {:title => title}) 
:%{fn}|¥Õ¥£¡¼¥ë¥É̾
:%{d}|Ťµ¥Á¥§¥Ã¥¯¤Ê¤É¤Î¶­³¦ÃÍ
:%{title}|¥¿¥¤¥È¥ë̾

***error_messages_for¤Î¥¿¥¤¥È¥ë¤ÎÆüËܸ첽 [#p4c95ce4]
[[http://www.yotabanana.com/hiki/ja/ruby-gettext-howto-ror.html#%A5%A8%A5%E9...:http://www.yotabanana.com/hiki/ja/ruby-gettext-howto-ror.html#%A5%A8%A5%E9%A1%BC%A5%E1%A5%C3%A5%BB%A1%BC%A5%B8%A4%CE%A5%BF%A5%A4%A5%C8%A5%EB%C9%F4%CA%AC%A4%F2%A5%AB%A5%B9%A5%BF%A5%DE%A5%A4%A5%BA]]
  ActionView::Helpers::ActiveRecordHelper::L10n.set_error_message_title(
    N_("An error was found in %{record}"),
    N_("%{num} errors were found in %{record}"))
  ActionView::Helpers::ActiveRecordHelper::L10n.set_error_message_explanation(
    N_("The error is:"), 
    N_("The errors are:"))

*** pot¥Õ¥¡¥¤¥ë¤ÎÀ¸À® [#b3af82b6]
- lib/tasks/gettext.rake¤Ëtask¤òÄɲÃ
 desc "Update pot/po files."
 task :updatepo do
   require 'gettext/utils'
   GetText.update_pofiles(
     "blog", 
     #¥Æ¥­¥¹¥È¥É¥á¥¤¥ó̾(init_gettext¤Ç»ÈÍѤ·¤¿Ì¾Á°)
     Dir.glob("{app,config,components,lib}/**/*.{rb,rhtml}"),  #¥¿¡¼¥²¥Ã¥È¤È¤Ê¤ë¥Õ¥¡¥¤¥ë
     "blog 1.0.0"  #¥¢¥×¥ê¥±¡¼¥·¥ç¥ó¤Î¥Ð¡¼¥¸¥ç¥ó)
 end
 
 desc "Create mo-files"
 task :makemo do
   require 'gettext/utils'
   GetText.create_mofiles(true, "po", "locale")
 end
- rake¤«¤éupdatepo¥¿¥¹¥¯¤ò¼Â¹Ô 
 $ rake updatepo
 $ ls po/sample.pot
- ÆüËܸìÍѤÎpo¥Õ¥¡¥¤¥ë¤ÎÀ¸À® 
 $ mkdir po/ja
 $ cp po/sample.pot po/ja/sample.po

** mo¥Õ¥¡¥¤¥ë¤ÎÀ¸À® [#wab7e3d1]
 $ rake makemo
 $ ls locale/ja/LC_MESSAGES/sample.mo

#blikifooter(»ÖÅÄ)

tag: [[rails>tag/rails]], [[gettext>tag/gettext]], [[ÊÙ¶¯²ñ>tag/ÊÙ¶¯²ñ]]


¥È¥Ã¥×   ¿·µ¬ °ìÍ÷ ñ¸ì¸¡º÷ ºÇ½ª¹¹¿·   ¥Ø¥ë¥×   ºÇ½ª¹¹¿·¤ÎRSS

¥¢¡¼¥¯¥¦¥§¥Ö¤Î¥µ¡¼¥Ó¥¹¤ä¥½¥ê¥å¡¼¥·¥ç¥ó¤Ï¤³¤Á¤é