Skip to content

Commit

Permalink
Remove localized engine support
Browse files Browse the repository at this point in the history
The current engine implementation is buggy and incomplete.

We are going to drop the whole feature, waiting for a new contributor

Close: #166, #172
  • Loading branch information
tagliala committed Nov 14, 2017
1 parent 88f7ca4 commit 936e7a2
Show file tree
Hide file tree
Showing 7 changed files with 9 additions and 80 deletions.
10 changes: 0 additions & 10 deletions lib/route_translator/extensions/mapper.rb
Expand Up @@ -41,16 +41,6 @@ def add_route(action, controller, options, _path, to, via, formatted, anchor, op
@set.add_localized_route(mapping, ast, as, anchor, @scope, path, controller, default_action, to, via, formatted, options_constraints, options)
end
# rubocop:enable Lint/UnderscorePrefixedVariableName

private

def define_generate_prefix(app, name)
return super unless @localized

RouteTranslator::Translator.available_locales.each do |locale|
super(app, "#{name}_#{locale.to_s.underscore}")
end
end
end
end
end
18 changes: 9 additions & 9 deletions lib/route_translator/translator.rb
Expand Up @@ -9,6 +9,15 @@ module Translator
class << self
private

def available_locales
locales = RouteTranslator.available_locales
# Make sure the default locale is translated in last place to avoid
# problems with wildcards when default locale is omitted in paths. The
# default routes will catch all paths like wildcard if it is translated first.
locales.delete I18n.default_locale
locales.push I18n.default_locale
end

def locale_from_args(args)
args_hash = args.detect { |arg| arg.is_a?(Hash) }
args_hash[:locale] if RouteTranslator.config.host_locales.present? && args_hash
Expand Down Expand Up @@ -50,15 +59,6 @@ def translate_path(path, locale, scope)

module_function

def available_locales
locales = RouteTranslator.available_locales
# Make sure the default locale is translated in last place to avoid
# problems with wildcards when default locale is omitted in paths. The
# default routes will catch all paths like wildcard if it is translated first.
locales.delete I18n.default_locale
locales.push I18n.default_locale
end

def translations_for(route)
RouteTranslator::Translator::RouteHelpers.add route.name, route.route_set.named_routes

Expand Down
9 changes: 0 additions & 9 deletions test/dummy/app/controllers/blorgh/posts_controller.rb

This file was deleted.

8 changes: 0 additions & 8 deletions test/dummy/app/controllers/dummy_controller.rb
Expand Up @@ -12,12 +12,4 @@ def native
def suffix
render plain: params[:id]
end

def engine_es
render plain: blorgh_es.posts_path
end

def engine
render plain: blorgh.posts_path
end
end
11 changes: 0 additions & 11 deletions test/dummy/config/initializers/blorgh.rb

This file was deleted.

6 changes: 0 additions & 6 deletions test/dummy/config/routes.rb
@@ -1,8 +1,6 @@
# frozen_string_literal: true

Rails.application.routes.draw do
mount Blorgh::Engine, at: '/blorgh'

localized do
get 'dummy', to: 'dummy#dummy'
get 'show', to: 'dummy#show'
Expand All @@ -11,14 +9,10 @@
get 'prefixed_optional(/p-:page)', to: 'dummy#prefixed_optional', as: :prefixed_optional

get ':id-suffix', to: 'dummy#suffix'

mount Blorgh::Engine, at: '/blorgh'
end

get 'partial_caching', to: 'dummy#partial_caching'
get 'native', to: 'dummy#native'
get 'engine_es', to: 'dummy#engine_es'
get 'engine', to: 'dummy#engine'

root to: 'dummy#dummy'
end
27 changes: 0 additions & 27 deletions test/integration/engine_test.rb

This file was deleted.

0 comments on commit 936e7a2

Please sign in to comment.