From ab2f37d2e64ba3cb50cb4c082938f1c7bb7240f1 Mon Sep 17 00:00:00 2001 From: Thomas Reynolds Date: Mon, 22 Apr 2013 22:09:33 -0700 Subject: [PATCH] make I18n optional in core --- .../lib/middleman-core/core_extensions/rendering.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/middleman-core/lib/middleman-core/core_extensions/rendering.rb b/middleman-core/lib/middleman-core/core_extensions/rendering.rb index 3b6e966a..cae0f430 100644 --- a/middleman-core/lib/middleman-core/core_extensions/rendering.rb +++ b/middleman-core/lib/middleman-core/core_extensions/rendering.rb @@ -129,9 +129,10 @@ module Middleman # Store last engine for later (could be inside nested renders) @current_engine, engine_was = engine, @current_engine - old_locale = ::I18n.locale - - I18n.locale = opts[:lang] if opts[:lang] + if defined?(::I18n) + old_locale = ::I18n.locale + ::I18n.locale = opts[:lang] if opts[:lang] + end # Use a dup of self as a context so that instance variables set within # the template don't persist for other templates. @@ -169,7 +170,7 @@ module Middleman ensure # Pop all the saved variables from earlier as we may be returning to a # previous render (layouts, partials, nested layouts). - ::I18n.locale = old_locale + ::I18n.locale = old_locale if defined?(::I18n) @current_engine = engine_was @content_blocks = nil @current_locs = nil