get i18n's hands out of app too

This commit is contained in:
Thomas Reynolds 2014-07-05 16:50:19 -07:00
parent 0ca6c37e5d
commit c94470d33f
2 changed files with 4 additions and 18 deletions

View file

@ -7,9 +7,9 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
option :mount_at_root, nil, 'Mount a specific language at the root of the site'
option :data, 'locales', 'The directory holding your locale configurations'
def initialize(app, options_hash={}, &block)
super
def_delegator :@app, :logger
def after_configuration
# TODO
# If :directory_indexes is already active,
# throw a warning explaining the bug and telling the use
@ -23,10 +23,6 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
app.config.define_setting :locales_dir, 'locales', 'The directory holding your locale configurations'
app.send :include, LocaleHelpers
end
def after_configuration
file_watcher.reload_path(app.config[:locales_dir] || options[:data])
@locales_glob = File.join(app.config[:locales_dir] || options[:data], '**', '*.{rb,yml,yaml}')
@ -52,8 +48,6 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
end
end
def_delegator :@app, :logger
def langs
@langs ||= known_languages
end
@ -168,12 +162,4 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
::I18n.locale = old_locale
p
end
module LocaleHelpers
# Access the list of languages supported by this Middleman application
# @return [Array<Symbol>]
def langs
extensions[:i18n].langs
end
end
end

View file

@ -204,10 +204,10 @@ module Middleman
# @param [String] path
# @return [String]
def strip_away_locale(path)
if @app.respond_to? :langs
if @app.extensions[:i18n]
path_bits = path.split('.')
lang = path_bits.last
return path_bits[0..-2].join('.') if @app.langs.include?(lang.to_sym)
return path_bits[0..-2].join('.') if @app.extensions[:i18n].langs.include?(lang.to_sym)
end
path