2007-05-04
Beast 中文化成功

介紹完怎麼安裝 Beast ,我們廢話不多說,直接進入 Beast 中文化。Beast 的 I18N 是採用 GETTEXT 來做的,意思就是只要寫一個 po 檔即可處理大部份的中文化東西。不過還是有很多小地方沒有中文化,依舊需要一一 check。右圖就是成品,這裡就是 po檔下載點。實做方式以及po檔均參考 JavaEye 的 Suninny 先生撰寫的 [分享]Beast中文Gettext PO档,感謝他的付出。
中文化方式如下
- 採用之前說好的方式安裝 beast。
- 安裝 GETTEXT GEM
gem i gettext - 撰寫轉換rake file,新增一個檔案叫做 lib/tasks/gettext.rake,內容是
desc "Create mo-files for L10n"
task :makemo do
require 'gettext/utils'
GetText.create_mofiles(true, "po", "locale")
end - 新增一個資料夾 po/zh_tw/ ,將這個po檔放入這個資料夾裡面
- 產生相對應的 mo 檔,請打入
rake makemo - config/enviroment.rb 裡面,下面這一段 gettext 的部份要註解起來,我也不確定為什麼,反正會產生 error
begin
require 'gettext/rails'
GetText.locale = "zh" # Change this to your preference language
puts "GetText found!"
rescue MissingSourceFile, LoadError
puts "GetText not found. Using English."
class ActionView::Base
def _(s)
s
end
end
end - app/controllers/application.rb 部份加上
class ApplicationController < ActionController::Base
#init_gettext "beast" if Object.const_defined?(:GetText)
require 'gettext/rails'
init_gettext "beast" if Object.const_defined?(:GetText)
GetText.locale = 'zh_tw'
end
裡面 zh_tw 就是你指定的語系 - 重起 server 即可
发表评论
- 浏览: 85334 次

- 详细资料
搜索本博客
最近加入圈子
最新评论
-
Net::HTTP 使用方式
https可以作吗?
-- by jerry -
用 JRuby 來連接 Oracle
能不能具体点? 这个Config文件在那啊?
-- by thinhair -
Another Ruby IDE:Interl ...
就是希望少占资源。
-- by dearsuper -
AK47 與 M16
奇怪你怎么能上网,而我那个朋友说是不能接触到电脑。。。
-- by blackanger -
AK47 與 M16
楼主用的AK是正版的吗???呵呵咋一看题目我还以为你在研究CS,我有个朋友也在台 ...
-- by blackanger






评论排行榜