GetTextã«ããæ¥æ¬èªåã®æé
é常ã®æ¥æ¬èªåï¼ãã©ã°ã¤ã³ãé¤ãï¼
é¢é£ããè¨äº
rakeãã¡ã¤ã«
- lib/tasks/gettext.rake
- 以ä¸ã®rakeãã¡ã¤ã«ã追å ããã
desc "Update pot/po files." task :updatepo do require 'gettext/utils' GetText.update_pofiles( "softwarebook", #ããã¹ããã¡ã¤ã³å(init_gettextã§ä½¿ç¨ããåå) Dir.glob("{app,config,components,lib}/**/*.{rb,rhtml}"), #ã¿ã¼ã²ããã¨ãªããã¡ã¤ã« "softwarebook 1.0.0") #ã¢ããªã±ã¼ã·ã§ã³ã®ãã¼ã¸ã§ã³ end desc "Create mo-files" task :makemo do require 'gettext/utils' GetText.create_mofiles(true, "po", "locale") end
åãã¦ã®ç¿»è¨³
- 翻訳対象ã_()dã§å²ãã
- RadRailsã®ãRake ã¿ã¹ã¯ãã¿ãã§ãupdatepoãé¸æãã¦ãå®è¡ãã¿ã³ã
- po/softwarebook.potãã¡ã¤ã«ãä½æãããã
- poãã©ã«ãã®ä¸ã«jaãã©ã«ããä½æããã
- ã¿ã¼ããã«ã§ä»¥ä¸ã®ã³ãã³ããå®è¡ããã
cd ~/railsapp/softwarebook/po msginit -i softwarebook.pot -o ja/softwarebook.po
-
- po/ja/softwarebook.poãã¡ã¤ã«ãä½æãããã
- softwarebook.poãã¡ã¤ã«ã翻訳ããã
- RadRailsã®ãRake ã¿ã¹ã¯ãã¿ãã§ãmakemoãé¸æãã¦ãå®è¡ãã¿ã³ã
以éã翻訳ãã¡ã¤ã«ãæ´æ°ããå ´åã¯ã以ä¸ã®æé ãç¹°ãè¿ãã
- 翻訳対象ã_()dã§å²ãã
- RadRailsã®ãRake ã¿ã¹ã¯ãã¿ãã§ãupdatepoãé¸æãã¦ãå®è¡ãã¿ã³ã
- softwarebook.potãã¡ã¤ã«ã¨softwarebook.poãã¡ã¤ã«ãæ´æ°ãããã
- softwarebook.poãã¡ã¤ã«ã翻訳ããã
- RadRailsã®ãRake ã¿ã¹ã¯ãã¿ãã§ãmakemoãé¸æãã¦ãå®è¡ãã¿ã³ã
LoginEngineãUserEngineãæ¥æ¬èªåããå ´å
é¢é£ããè¨äº
rakeãã¡ã¤ã«
- vendor/plugins/user_engine/Rakefile
- 以ä¸ã®rakeãã¡ã¤ã«ã追å ãããï¼UserEngineã®å ´åï¼
desc "Create mo-files for L10n" task :makemo do require 'gettext/utils' GetText.create_mofiles(true, "po", "locale") end $: << "../../../" desc "Update pot/po files to match new version." task :updatepo do require 'gettext/utils' GetText::ActiveRecordParser.init(:db_yml => "../../../config/database.yml") GetText.update_pofiles("user_engine", Dir.glob("{app,lib}/**/*.{rb,rhtml}"), "user_engine 1.0.0") end
vendor/plugins/user_engine/app/controllers/*_controller.rbã¸ã®è¿½è¨
ä¸è¨ã®ããã«ãinit_gettext "user_engine"ã追è¨ãããï¼userãroleãpermissionã®ã³ã³ããã¼ã©ã¼ãã¹ã¦ã«è¿½è¨ãããï¼
class UserController < ApplicationController init_gettext "user_engine" ...ï¼ä»¥ä¸çç¥ï¼...
åãã¦ã®ç¿»è¨³
- 翻訳対象ã_()ã§å²ãã
- ã¿ã¼ããã«ã§ä»¥ä¸ã®ã³ãã³ããå®è¡ããã
cd ~/railsapp/softwarebook/vendor/plugins/user_engine updatepo
-
- vendor/plugins/user_engine/po/user_engine.potãã¡ã¤ã«ãä½æãããã
- poãã©ã«ãã®ä¸ã«jaãã©ã«ããä½æããã
- ã¿ã¼ããã«ã§ä»¥ä¸ã®ã³ãã³ããå®è¡ããã
cd ~/railsapp/softwarebook/vendor/plugins/user_engine/po msginit -i user_engine.pot -o ja/user_engine.po
-
- vendor/plugins/user_engine/po/ja/user_engine.poãã¡ã¤ã«ãä½æãããã
- user_engine.poãã¡ã¤ã«ã翻訳ããã
- ã¿ã¼ããã«ã§ä»¥ä¸ã®ã³ãã³ããå®è¡ãã¦å®äºã
cd ~/railsapp/softwarebook/vendor/plugins/user_engine makemo
以éã翻訳ãã¡ã¤ã«ãæ´æ°ããå ´åã¯ã以ä¸ã®æé ãç¹°ãè¿ãã
- 翻訳対象ã_()ã§å²ãã
- ã¿ã¼ããã«ã§ä»¥ä¸ã®ã³ãã³ããå®è¡ããã
cd ~/railsapp/softwarebook/vendor/plugins/user_engine updatepo
-
- user_engine.potãã¡ã¤ã«ã¨user_engine.poãã¡ã¤ã«ãæ´æ°ãããã
- user_engine.poãã¡ã¤ã«ã翻訳ããã
- ã¿ã¼ããã«ã§ä»¥ä¸ã®ã³ãã³ããå®è¡ãã¦å®äºã
cd ~/railsapp/softwarebook/vendor/plugins/user_engine makemo