diff --git a/lib/js_locale_helper.rb b/lib/js_locale_helper.rb index 61847405c..d8d9bb831 100644 --- a/lib/js_locale_helper.rb +++ b/lib/js_locale_helper.rb @@ -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}))") diff --git a/spec/components/js_locale_helper_spec.rb b/spec/components/js_locale_helper_spec.rb index ceab7ff6e..c3a8060ab 100644 --- a/spec/components/js_locale_helper_spec.rb +++ b/spec/components/js_locale_helper_spec.rb @@ -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