Merge pull request #1032 from Krugloff/patch-1

It maybe worth load pluralizations rules before compile?
This commit is contained in:
Sam 2013-06-16 16:58:16 -07:00
commit e603c85fa0
2 changed files with 7 additions and 0 deletions

View File

@ -73,6 +73,8 @@ module JsLocaleHelper
def self.compile_message_format(locale, format)
ctx = V8::Context.new
ctx.load(Rails.root + 'lib/javascripts/messageformat.js')
path = Rails.root + "lib/javascripts/locale/#{locale}.js"
ctx.load(path) if File.exists?(path)
ctx.eval("mf = new MessageFormat('#{locale}');")
ctx.eval("mf.precompile(mf.parse(#{format.inspect}))")

View File

@ -79,4 +79,9 @@ describe JsLocaleHelper do
ctx.eval('I18n.messageFormat("simple_MF", {})').should =~ /COUNT/ # error
end
it 'load pluralizations rules before precompile' do
message = JsLocaleHelper.compile_message_format('ru', 'format')
message.should_not match 'Plural Function not found'
end
end