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