get i18n's hands out of app too
This commit is contained in:
parent
0ca6c37e5d
commit
c94470d33f
|
@ -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 :mount_at_root, nil, 'Mount a specific language at the root of the site'
|
||||||
option :data, 'locales', 'The directory holding your locale configurations'
|
option :data, 'locales', 'The directory holding your locale configurations'
|
||||||
|
|
||||||
def initialize(app, options_hash={}, &block)
|
def_delegator :@app, :logger
|
||||||
super
|
|
||||||
|
|
||||||
|
def after_configuration
|
||||||
# TODO
|
# TODO
|
||||||
# If :directory_indexes is already active,
|
# If :directory_indexes is already active,
|
||||||
# throw a warning explaining the bug and telling the use
|
# 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.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])
|
file_watcher.reload_path(app.config[:locales_dir] || options[:data])
|
||||||
|
|
||||||
@locales_glob = File.join(app.config[:locales_dir] || options[:data], '**', '*.{rb,yml,yaml}')
|
@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
|
||||||
end
|
end
|
||||||
|
|
||||||
def_delegator :@app, :logger
|
|
||||||
|
|
||||||
def langs
|
def langs
|
||||||
@langs ||= known_languages
|
@langs ||= known_languages
|
||||||
end
|
end
|
||||||
|
@ -168,12 +162,4 @@ class Middleman::CoreExtensions::Internationalization < ::Middleman::Extension
|
||||||
::I18n.locale = old_locale
|
::I18n.locale = old_locale
|
||||||
p
|
p
|
||||||
end
|
end
|
||||||
|
|
||||||
module LocaleHelpers
|
|
||||||
# Access the list of languages supported by this Middleman application
|
|
||||||
# @return [Array<Symbol>]
|
|
||||||
def langs
|
|
||||||
extensions[:i18n].langs
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -204,10 +204,10 @@ module Middleman
|
||||||
# @param [String] path
|
# @param [String] path
|
||||||
# @return [String]
|
# @return [String]
|
||||||
def strip_away_locale(path)
|
def strip_away_locale(path)
|
||||||
if @app.respond_to? :langs
|
if @app.extensions[:i18n]
|
||||||
path_bits = path.split('.')
|
path_bits = path.split('.')
|
||||||
lang = path_bits.last
|
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
|
end
|
||||||
|
|
||||||
path
|
path
|
||||||
|
|
Loading…
Reference in a new issue