mirror of
https://github.com/discourse/discourse.git
synced 2025-01-18 17:02:45 +08:00
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)
|
def self.compile_message_format(locale, format)
|
||||||
ctx = V8::Context.new
|
ctx = V8::Context.new
|
||||||
ctx.load(Rails.root + 'lib/javascripts/messageformat.js')
|
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 = new MessageFormat('#{locale}');")
|
||||||
ctx.eval("mf.precompile(mf.parse(#{format.inspect}))")
|
ctx.eval("mf.precompile(mf.parse(#{format.inspect}))")
|
||||||
|
|
||||||
|
|
|
@ -79,4 +79,9 @@ describe JsLocaleHelper do
|
||||||
ctx.eval('I18n.messageFormat("simple_MF", {})').should =~ /COUNT/ # error
|
ctx.eval('I18n.messageFormat("simple_MF", {})').should =~ /COUNT/ # error
|
||||||
end
|
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
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user