Giter Club home page Giter Club logo

translate_routes's People

Contributors

cice avatar devsigner avatar enriclluelles avatar gonzoyumo avatar jaimeiniesta avatar kristianmandrup avatar raul avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

translate_routes's Issues

Plugin branch for Rails 2.1 and redirection issue

I have an old Rails 2.1.2 application. There are reasons why I don't want to upgrade it, so I must work with version metioned.

I have installed a plugin for routes translation (raul/translate_routes) from an old R2.1 branch. It works great, with one exception. When I switch my default language (pl) I'm losing all 'english' routes. It's a problem as the website is public and 'english' routes have been widely indexed by Google.

mysite.com/produkty -> works
mysite.com/products -> don't work

I tried to setup redirects in routes.rb. But:

map.connect 'blahblahblah', :controller => 'redirect', :action => 'index'

works, while

map.connect 'users', :controller => 'redirect', :action => 'index'

don't work.

It means: if I have resource :users in routes.rb and I use translation for routes, something blocks my attempts to redirect "not translated" route somewhere. I guess, translated_routes somehow "takes for themselves" this route ('users').

Do You see my problem and any solution for it?
Can I do something that will make '/users' route working even with :pl locale set (or make working a redirection for this route)?
(I am thinking even about redirects at Apache .htaccess level)

Rails 3 edit_xxx_path(xxx) error

Hi,

When using the plugin with rails 3.0.1, I encounter an error while showing the "link_to edit_model-name_path(instance). The plugin mistake the param instance for the param locale.

The workaround is using edit_model-name_path(:id => instance.id), but I don't think it is how it should be.

Regards

match "*url_match" does not work with this gem

I use match "*url_match" for catching all unrecognized URLs and then work on them in special controller.

I expect that including translate_routes gem will bring me such routes as ":locale/*url_match"

But error occured. Wrong argument type nil (expected Regexp) in /lib/route_translator.rb:223 in 'gsub'

root_path without locale

Hi!

I need some times the root_path helper without locale. Is there a possibility to get it with example root_path(:no_locale) or something else?

Bye

Action Caching doesn't work

I am using the gem in my work using Rails 3, and ruby 1.9.2 and it was working like a charm until I tried to include action caching, it gives me the following error:

Routing Error
No route matches {:format=>nil, :locale=>:en, :controller=>"pages", :action=>"show", :id=>"home"}

When I commented this line in routes.rb:
ActionDispatch::Routing::Translator.translate_from_file('config','i18n-routes.yml')

The Action caching worked fine...

map.namespace causes error

I'm getting this error when I rake routes in the console and it seems to be coming from my map.namespace

rake aborted!
private method `gsub' called for #Hash:0x1f1ca38

Here's the routing in question:

map.namespace :user do |user|
user.resources :articles do |articles|
articles.resources :comments
articles.resources :tags
end
end

Problem by routes without format

I have some routes without format parameter and that breakes the gem.

The problems lines in the lines 222 and 223 from the routes_translater.rb (as far as I can tell)

final_optional_segments = path.match(/(\(.+\))$/)[1] rescue nil   # i.e: (.:format)
path_segments = path.gsub(final_optional_segments,'').split("/")

When a routes doesn't have the format, the variable final_optional_segments is nil. Then the gsub in the next line fails.

Or do you see a different problem?

Remove default locale?

Is it somehow possible to remove the default locale? The plugin seems always to add a route for English.

Non-localized root, prefix on every translation.

27735f8

This commit removed option which I found very usefull. What was the logic behind this change.

What I need, is to use non-localized root to detect the locale, and use language prefix on every variation. How to acomplish this with never versions?

Error in console

Hi !
I have error in app console.
My steps for sample application:

  1. git clone git://github.com/raul/translate_routes_demo.git
  2. cd translate_routes_demo
  3. ./script/console
    Loading development environment (Rails 2.3.2)
  4. app
    NameError: undefined method root_path' for classActionController::Integration::Session'
    from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/integration.rb:98:in public' from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/integration.rb:98:inreset!'
    from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/integration.rb:98:in module_eval' from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/integration.rb:98:inreset!'
    from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/actionpack-2.3.2/lib/action_controller/integration.rb:69:in initialize' from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/console_app.rb:19:innew'
    from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/console_app.rb:19:in new_session' from /opt/ruby-enterprise-1.8.7-2009.10/lib/ruby/gems/1.8/gems/rails-2.3.2/lib/console_app.rb:11:inapp'
    from (irb):1

I get the same error in my application with 2.3.5 rails.

WBR,
atlancer

P.S.
ruby 1.8.7 (2009-06-12 patchlevel 174) [i686-linux], MBARI 0x8770, Ruby Enterprise Edition 2009.10

Side effect of rake task

In your lib/tasks/translate_routes_tasks.rake you were requiring 'environment' which had as consequence to require 'environment' in every task, because rails require plugins rakefiles and tasks automatically.

The problem is you do not always want to require the environment. When deploying for example, you may have rake task to copy database.yml.sample to database.yml which is not requiring environment because the environnment is not configured ( ie : database.yml is not present ). This is going to fail because of misconfigured environment, blocking you from deploying correctly.

This scenario can be reproduced when using both inploy and your plugin.

The solution is to make your rake task depending on the environment task instead of just requiring it which have a side effect as explained.

You can find in my fork a corrected version of your task, and in my pull request.

Regards,

Polymorphic routes not work

link_to [:admin, @my_object] or form_for [:admin, @my_object] not work in rails-3.1.rc4 and throw exception:

undefined method `hash_for_admin_my_object_path' for #<Module:0x617e050>

Translation using both default and non-default routes

Hi

First off; thanks for the awesome open source.

I really have no way of knowing if this is an issue or expected behaviour, though it seems strange.

In my production log I see the following repeated frequently, always in succession.

      Translating routes (default locale: en)
      Translating routes (default locale: es)

It would seem expected behaviour not to translate the routes using the non-default and I worry that google might find duplicate content. Please advise and thanks again.

Mark

Rails 3: translate routes + meta_search (no route matches on sort_helper)

Hey,

I'm porting an application to Rails 3, I dumped search_logic in favor of meta_search. I'm having some problems with the sort helpers generated by meta_search in combination of translated_routes, if I don't set the before_filter :set_locale_from_url in application controller everything seems to be working ok, but if is set (even if it returns the same default language set in application.rb) the meta_search helper brokes up telling it can find the route used in the helper:

No route matches {:search=>{"meta_sort"=>"name.asc"}, :locale=>:es, :controller=>"users"}

I took a look to the before_filter method and the problem seems to be in:

default_url_options.merge! RouteTranslator::LOCALE_PARAM_KEY => I18n.locale

If instead of the merge! I use:

default_url_options = {RouteTranslator::LOCALE_PARAM_KEY => I18n.locale}

The :locale => :es is also set correctly and everything works as expected, I don't know about translate_routes internals so, is there any other options being used in default_url_options requiring to use the merge?

I've created a sample app https://github.com/francesc/TranslateRoutesMetaSearchBug in case anynone wants to try it out (uncomment the before_filter to see the error).

rails 3.1 support?

Hey,

I was playing around with Ruby 1.9.2+Rails 3.1 and noticed that translate_routes doesn't work with this version. It gives the following error:

route_translator.rb:223:in `gsub': wrong argument type nil (expected Regexp) (TypeError)

Anyone got it working with 3.1? Any plans to bring support for the new version?

I get 404 on creating new Redmine wiki pages/issues

Hello,

I am testing translate_routes with Redmine. I translated 'projects' to 'proiecte' and now I get 404 when submiting a new wiki page.

My modified files are config/routes.rb[1], locales/i18n-routes.yml[2] and app/controllers/application_controller.rb[3], as indicated on this wiki.

I also tried the solution to avoid applying prefix[4](I thought this might be the problem).

I don't have a clue why this is not working. Can you help me?

Thanks,
Tibi

[1] http://pastebin.com/f1247f18

[2] http://pastebin.com/f1f20e975

[3] http://pastebin.com/f4b02946c

[4] http://github.com/raul/translate_routes/issues#issue/3

I18n Route Translation without prefix

Hi,

In my app I'm not using a prefix in the urls. The current language come from the HTTP_ACCEPT_LANGUAGE var in the request header or from my user logic.

I did have a check but I could not see a way to turn this off.

To fix this I simply created a new flag in translate_routes.rb and wrapped the prefix logic and all worked :)

translate_routes.rb

mattr_accessor :apply_prefix
@@apply_prefix = true

def self.locale_segments(orig, locale)
  ...
    if @@apply_prefix
      if add_prefix?(locale) # initial prefix i.e: /en-US
        divider = DividerSegment.new(orig.segments.first.value, :optional => false) # divider ('/')
        static = StaticSegment.new(locale, :optional => false) # static ('en-US')
        segments += [divider, static]
      end
    end
  ...
end

and then in my case to turn it off I simply set the apply_prefix to false in my routes.rb:

ActionController::Routing::Translator.apply_prefix = false

Not sure if this is a feature you would consider.

Cheers,
Nick

Problem with Cucumber

When you try write some scenarios in Cucumber, there are issues related with ActionController::Integration::Session (name error).

Rspec can't find routes when testing controllers

When running rspec against my controllers, I get "no route matches" errors for all the actions.

If I comment out the line that does the translation at routes.rb, everything is back to normal.

Curiously enough, this bug doesn't happen on my integration tests with Steak, it's only happening on the controller specs.

I've created a sample app to reproduce the problem:

https://github.com/jaimeiniesta/rspectransbug

Thanks!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.