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

Fixes #166, fixes #172, fixes #173 and fixes #178
  • Loading branch information
tagliala committed Jan 19, 2019
1 parent c7afccb commit 1958db2
Show file tree
Hide file tree
Showing 8 changed files with 10 additions and 80 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## 6.0.0 / unreleased

* [BUGFIX] Verify host path consistency by default ([#91](https://github.com/enriclluelles/route_translator/issues/91), [#171](https://github.com/enriclluelles/route_translator/issues/171))
* [FEATURE] Remove Engine support ([#166](https://github.com/enriclluelles/route_translator/issues/91), [#166](https://github.com/enriclluelles/route_translator/issues/172))
* [FEATURE] Remove the option to verify host path consistency
* [ENHANCEMENT] Avoid duplicate routes when using host_locales ([#87](https://github.com/enriclluelles/route_translator/issues/87), [#171](https://github.com/enriclluelles/route_translator/issues/171))

Expand Down
10 changes: 0 additions & 10 deletions lib/route_translator/extensions/mapper.rb
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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 @@ -51,15 +60,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
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,6 @@ 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

def slash
render plain: request.env['PATH_INFO']
end
Expand Down
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
Original file line number Diff line number Diff line change
@@ -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 @@ -13,14 +11,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 1958db2

Please sign in to comment.