Merge pull request #1032 from Krugloff/patch-1
It maybe worth load pluralizations rules before compile?
This commit is contained in:
commit
e603c85fa0
|
@ -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}))")
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue