GithubHelp home page GithubHelp logo

i18n_routing's People

Contributors

dependabot[bot] avatar dominikgrygiel avatar fwalch avatar janjiss avatar jdcrutchley avatar kwi avatar mixr avatar sweed avatar toxxic 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

i18n_routing's Issues

Rails 3, default language slovenian, nested route, works sometimes

This is a weird one, translated routes work (when I look at rake routes), however in case I start server they fail to translate. Then, when I edit the gemfile while server is on, routes start working. If I restart it again they stop until gemfile is edited.

My route looks like:

localized do
  resources :nepremicnines do
    collection do
      get :obcino
    end
  end
end

And en.yml:

en:
  resources:
    nepremicnines: "real_estates"
  path_names:
    obcino: "municipality"

Since my production is on Heroku, with it's read-only fs, this is a bit of a problem for me.

collection route is not localized

According to the documentation, this should work. In config/routes.rb:

localized do
  resources :films do
    collection do
      get :all
    end
  end
end

The 'all' collection is not localized when I use this YAML:

nl:
  routes:
    films:
      as: "bios"
      path_names:
        all: "allemaal"

i18n_routing version 0.6.2 with Rails 3.2.9. The 'films' collection itself is localized properly.

How can I localize the collection path?

Rails 4.2 compatibility: parameters of LocalizedMapping initializer super(...) have changed

When trying out this gem in a new Rails 4.2 app, I get

$ rake routes
rake aborted!
ArgumentError: wrong number of arguments (6 for 3)
.../ruby/2.1.0/i18n_routing-16908a366e4f/lib/i18n_routing_rails4.rb:134:in `define_url_helper'
.../ruby/2.1.0/i18n_routing-16908a366e4f/lib/i18n_routing_rails4.rb:289:in `block (2 levels) in included'
.../ruby/2.1.0/i18n_routing-16908a366e4f/lib/i18n_routing_rails4.rb:227:in `match'
.../ruby/2.1.0/i18n_routing-16908a366e4f/lib/i18n_routing_rails4.rb:289:in `block (2 levels) in included'
$APPPATH/config/routes.rb:6:in `block (4 levels) in <top (required)>'
.../ruby/2.1.0/i18n_routing-16908a366e4f/lib/i18n_routing_rails4.rb:254:in `block (2 levels) in create_globalized_resources'
.../ruby/2.1.0/i18n_routing-16908a366e4f/lib/i18n_routing_rails4.rb:183:in `skip_localization'
.../ruby/2.1.0/i18n_routing-16908a366e4f/lib/i18n_routing_rails4.rb:252:in `block in create_globalized_resources'
.../ruby/2.1.0/i18n_routing-16908a366e4f/lib/i18n_routing_rails4.rb:99:in `set_localizable_route'
.../ruby/2.1.0/i18n_routing-16908a366e4f/lib/i18n_routing_rails4.rb:251:in `create_globalized_resources'
.../ruby/2.1.0/i18n_routing-16908a366e4f/lib/i18n_routing_rails4.rb:301:in `resources_with_i18n_routing'
$APPPATH/config/routes.rb:5:in `block (3 levels) in <top (required)>'
$APPPATH/config/routes.rb:4:in `block (2 levels) in <top (required)>'
$APPPATH/config/routes.rb:3:in `block in <top (required)>'
$APPPATH/config/routes.rb:1:in `<top (required)>'
$APPPATH/config/environment.rb:5:in `<top (required)>'

Any idea what this might be?

I'm using the rails4 branch of 'ncri' (which unfortunately doesn't have an issue tracker, so I post it here).

Nested ressources don't work (Rails 3.1, Ruby 1.9.2)

Given a nested route like this:

  localized do 
    resources :users do 
      resources :videos 
    end 
  end 

with a path_name translation key

locale: 
  routes: 
    users: 
      path_names: 
        new: translated_new

path_names.new is wrongly recognized as belonging to videos and the
new path segment for new_user_path is not translated.

Workaround: removing the nested resource and
adding an extra block:

localized do 
  resources :users 
end 

resources :users do 
  localized do 
    resources :videos 
  end 
end 

However, this is not very clean and I also don't know where to store
the translations for the nested videos resource.

changing language

Hello,

i would like make links to change language of website
But currently i can't have url translated by language in these links
all links are in the same language (the current of course

how force to use a other language than current

I18n.available_locales.each do |locale|
new_params = params.merge(:locale => locale)
content += content_tag(:li, link_to(locale.to_s.upcase, new_params))
end

tx

Translate action name

I would like to translate the name of action like new, edit etc.. At this time I could not find any posibilities how do that.
When I try something like this :


resources:
    enquiries: 
         new: poptavky/nova

The result is newpoptavky/nova.
Thanks a lot
PS: Im using rails 2.3.5

No localized path when the translation is the same as english

I have a resource called "kits" that is the same in both english and portuguese. The plugin doesn't create the localized paths like pt_kits, new_pt_kit, etc. This is an issue because I want localized path_names, like this:

English: /kits/new and /kits/1/edit
Portuguese: /kits/criar and /kits/1/editar

Any ideas?

Doesnt work in beta 4

I have tried everything that wiki explain...

But doesnt work in rails3 beta : /

I`m with Ruby 1.9.2 and Rails 3 beta4

routes.rb
localized(['pt'], :verbose => true) do
namespace :user do
match 'logout' => 'user_sessions#destroy'
match 'login' => 'user_sessions#new'
resource :session, :controller => "user_sessions"
resource :account, :controller => "users"
end
end

pt.yml
pt:
path_names:
new: 'adicionar'
edit: 'editar

Redirect route results in error

Hi,

I have the following in config/routes.rb:

match "test" => redirect("/test2"), :as => :test

This results in the following error:

/Library/Ruby/Gems/1.8/gems/i18n_routing-0.6.1/lib/i18n_routing_rails32.rb:200:in `dump': no marshal_dump is defined for class Proc (TypeError)
    from /Library/Ruby/Gems/1.8/gems/i18n_routing-0.6.1/lib/i18n_routing_rails32.rb:200:in `match'
    from /Users/xx/app/config/routes.rb:63

Without the redirect route it works fine, and also when using other localized routes.

Hope you can help.

/Lasse

Issue when wrapping localized block in scope (Rails 3.1, Ruby 1.9.2)

When I do

scope "(:locale)", :locale => /(fr-CH)/ do
  localized do
      match '/inserieren' => 'site#advertise', :as => :advertise
  end
end

and then go to /fr-CH/inserieren

I get this error:

NoMethodError: undefined method `locale' for #ActionDispatch::Request:0x007fc222715bb0


rack-mount (0.8.3) lib/rack/mount/code_generation.rb:543:in `optimized_each'
rack-mount (0.8.3) lib/rack/mount/code_generation.rb:95:in `recognize'
rack-mount (0.8.3) lib/rack/mount/route_set.rb:141:in `call'
actionpack (3.1.0) lib/action_dispatch/routing/route_set.rb:531:in `call'
oa-core (0.2.6) lib/omniauth/strategy.rb:44:in `call!'
oa-core (0.2.6) lib/omniauth/strategy.rb:30:in `call'
oa-core (0.2.6) lib/omniauth/builder.rb:30:in `call'
newrelic_rpm (3.1.1) lib/new_relic/rack/browser_monitoring.rb:18:in `call'
sass (3.1.7) lib/sass/plugin/rack.rb:54:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/best_standards_support.rb:17:in `call'
rack (1.3.2) lib/rack/etag.rb:23:in `call'
rack (1.3.2) lib/rack/conditionalget.rb:25:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/head.rb:14:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/params_parser.rb:21:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/flash.rb:243:in `call'
rack (1.3.2) lib/rack/session/abstract/id.rb:195:in `context'
rack (1.3.2) lib/rack/session/abstract/id.rb:190:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/cookies.rb:326:in `call'
activerecord (3.1.0) lib/active_record/query_cache.rb:62:in `call'
activerecord (3.1.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:477:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/callbacks.rb:29:in `block in call'
activesupport (3.1.0) lib/active_support/callbacks.rb:392:in `_run_call_callbacks'
activesupport (3.1.0) lib/active_support/callbacks.rb:81:in `run_callbacks'
actionpack (3.1.0) lib/action_dispatch/middleware/callbacks.rb:28:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/reloader.rb:68:in `call'
rack (1.3.2) lib/rack/sendfile.rb:101:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/remote_ip.rb:48:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/show_exceptions.rb:47:in `call'
railties (3.1.0) lib/rails/rack/logger.rb:13:in `call'
rack (1.3.2) lib/rack/methodoverride.rb:24:in `call'
rack (1.3.2) lib/rack/runtime.rb:17:in `call'
activesupport (3.1.0) lib/active_support/cache/strategy/local_cache.rb:72:in `call'
rack (1.3.2) lib/rack/lock.rb:15:in `call'
rack-rewrite (1.0.2) lib/rack/rewrite.rb:19:in `call'
actionpack (3.1.0) lib/action_dispatch/middleware/static.rb:53:in `call'
railties (3.1.0) lib/rails/engine.rb:455:in `call'
railties (3.1.0) lib/rails/rack/content_length.rb:16:in `call'
railties (3.1.0) lib/rails/rack/log_tailer.rb:14:in `call'
thin (1.2.11) lib/thin/connection.rb:84:in `block in pre_process'
thin (1.2.11) lib/thin/connection.rb:82:in `catch'
thin (1.2.11) lib/thin/connection.rb:82:in `pre_process'
thin (1.2.11) lib/thin/connection.rb:57:in `process'
thin (1.2.11) lib/thin/connection.rb:42:in `receive_data'
eventmachine (0.12.10) lib/eventmachine.rb:256:in `run_machine'
eventmachine (0.12.10) lib/eventmachine.rb:256:in `run'
thin (1.2.11) lib/thin/backends/base.rb:61:in `start'
thin (1.2.11) lib/thin/server.rb:159:in `start'
rack (1.3.2) lib/rack/handler/thin.rb:13:in `run'
rack (1.3.2) lib/rack/server.rb:265:in `start'
railties (3.1.0) lib/rails/commands/server.rb:70:in `start'
railties (3.1.0) lib/rails/commands.rb:54:in `block in <top (required)>'
railties (3.1.0) lib/rails/commands.rb:49:in `tap'
railties (3.1.0) lib/rails/commands.rb:49:in `<top (required)>'
script/rails:6:in `require'
script/rails:6:in `<top (required)>'
-e:1:in `load'
-e:1:in `<main>'

Doesn't parse (.:format) ?

Hi,

I have a route that looks like this:
match ":city_id/:venue_id/reviews(.:format)" => "reviews#index", :as => :city_venue_reviews

In my translation file (nl.yml), i've got this (short version):
nl:
named_routes_path:
":city_id/:venue_id/reviews(.:format)" : ":city_id/:venue_id/recensies(.:format)"

Output of rake routes:
city_venue_reviews /:city_id/:venue_id/reviews(.:format) {:controller=>"reviews", :action=>"index"}

Others paths translate just fine. Examples that work:
":city_id/:venue_id/reserve" : ":city_id/:venue_id/online-reserveren"
":city_id/:venue_id/order" : ":city_id/:venue_id/online-bestellen"

localized NoMethodError

got error when trying to run "rake routes" or "rails s"

............./config/routes.rb:1: undefined method `localized' for main:Object (NoMethodError)

rails 3.0.7, i18n_routing 0.4.7

Namespace

Hi,

I have a route that looks like this:

namespace :shop do
resources :orders
end

Is any way to translate namespace "shop" ?? I will try translate this in many ways in my locale.yml, but nothing changes.

root :to => 'home#index', :as => :home

I cannot figure out why this isn't working. Where am i wrong?

Routes.rb

localized do
    root :to => 'home#index', :as => :home
  end

en.yml

en:
  routes:
    home_path: this-is-my-homepage

Bug with named routes in Rails 3

When using named routes in Rails 3, there's an error when initializing (translating the routes):

lib/i18n_routing_rails3.rb:281:in `initialize': wrong number of arguments (4 for 3) (ArgumentError)

In my routes.rb I have:

localized([:es, :en], :verbose => true) do
match 'home' => 'home#show', :as => :home
end

I fixed the problem (4 arguements were sent to the Parent class), you can see my solution in a note in this commit:
http://github.com/kwi/i18n_routing/commit/4ecdea43564ec7d732bab6e00e32e0139103c129#comments

Thanks!

no route matches on route_paths with special charaters

Hi all,

i have a problem with the correct translation of some words with special characters.
Example in my routes.rb:
localized(I18n.available_locales, :verbose => false) do
...
match 'land/:id' => 'land#index', :as => :land
...
end

In my YML file for Spain the translation for "land" is "país".
named_routes_path:
'land/:id': "país/:id"
...
You see the special character "í".

So when i start my rails application and switch the language to spanish and click on a link like (país/at-austria) that leads me to this error message:
"No route matches "/pa%C3%ADs/at-austria" "
All other routes without a special character in it, works correctly.
Any suggestions or solutions?

P.S.: I'm using ruby 1.9.2p0 and Rails 3.0.3

Thanks!
Christian

Translation of scopes

I didn't find a way to translate scopes in Rails 3. Something like:

scope "national" do
  resources :events
end
scope "international" do
  resources :events
end

The "national" and "international" parts in the url don't get translated.

en: /national/events
pt: /national/eventos
en: /international/events
pt: /international/eventos

Is there anything I'm missing, or the gem can't handle it yet?

Broken with Rails 3.2

This (excellent) gem is broken with the freshly released Rails 3.2.

Due to require 'rack/mount' in lib/i18n_routing_rails3.rb.
Indeed, Rails 3.2 use Journey for the routing.

Does not work with '-' or '/' in named route

Given this route:

ActionDispatch::Routing::SEPARATORS << "-" unless ActionDispatch::Routing::SEPARATORS.include?("-")
match '/product-:name-:id' => 'products#show'

i18n_routing will throw an error

compile error /Library/Ruby/Gems/1.8/gems/actionpack-3.0.4/lib/action_dispatch/routing/route_set.rb:161: syntax error, unexpected '-', expecting '\n' or ';' 

I suspect this is because I am using different parameter separators than the default '/' and '.' (for SEO optimization).

How would I be able use this plugin in combination with such routes?

Thanks!

missing slash?

Hi,
my routes.rb
scope "(:locale)" , :locale => /pt|en/ do
localized(['en','pt'], :verbose => true) do
match 'about' => "home#about",:as => :about
end
end

my translation
pt.yml
pt:
named_routes_path:
about: "pt_about"
rake routes
[I18n] > localize route : about (pt) => /(:locale)pt-about

where is slash?

Having hard time trying to get it to work

I'm using ruby 1.9.2dev (2010-05-28 revision 28049) [x86_64-darwin10]
Rails is -> gem 'rails', :git => 'http://github.com/rails/rails.git'
And I have this in my Gemfile gem 'i18n_routing'

I have this in my routes.rb
localized([:en, :fi], :verbose => true) do
match 'about' => 'contents#about', :as => :about
end

and locale files are following
en:
named_routes_path:
about: 'a-propos'

fi:
named_routes_path:
about: 'fi-propos'

rake routes prints these
[I18n] > localize route : about (en) => /a-propos
[I18n] > localize route : about (fi) => /fi-propos

but when i hit localhost:3000/a-propos or fi-propos i get No route matches "/a-propos" or No route matches "/fi-propos"

Also the <%= link_to 'about', about_path %> prints out just about

Could you help me debug this, I really don't know what to do next.

Thanks.

Be aware of empty translations

When using non default i18n backends like activerecord, it's not unusual to have translations for keys with an empty values. In my case I was using that to keep track of untranslated sentences.

However, this causes some really weird behaviour in the rails application using i18n_routing, due to empty routes generated like:

                 en_products        /(:locale)                                                           {:action=>"products", :controller=>"static", :i18n_locale=>"en"}
                 ca_products        /(:locale)                                                           {:action=>"products", :controller=>"static", :i18n_locale=>"ca"}
                 es_products        /(:locale)/productos                                                 {:action=>"products", :controller=>"static", :i18n_locale=>"es"}
                    products        (/:locale)/products(.:format)                                        {:action=>"products", :controller=>"static"}

May it be possible to do a check for empty translations, and avoid generte the routes in that case?

Invalid route name: 'en_/'

Hello, I have a "Invalid route name: 'en_/'" after updated the plugin today. Can you help me please ?, I don't want to clarify a

  :as => 'home'
  localized I18n.available_locales do
    scope '/:i18n_locale', :constraints => { :i18n_locale => /en|fr/ } do
       match "/", :to => "home#index"
    end
  end

Rails 4.0 compatibility

Great plugin. But it doesn't work in the newly released Rails 4.0.0.beta1:

LoadError: cannot load such file -- journey
~/.rvm/gems/ruby-2.0.0-p0/gems/i18n_routing-0.6.2/lib/i18n_routing_rails32.rb:2:in `require'
~/.rvm/gems/ruby-2.0.0-p0/gems/i18n_routing-0.6.2/lib/i18n_routing_rails32.rb:2:in `<top (required)>'
~/.rvm/gems/ruby-2.0.0-p0/gems/i18n_routing-0.6.2/lib/i18n_routing.rb:7:in `require'
~/.rvm/gems/ruby-2.0.0-p0/gems/i18n_routing-0.6.2/lib/i18n_routing.rb:7:in `<top (required)>'
~/.rvm/gems/ruby-2.0.0-p0/gems/bundler-1.3.0/lib/bundler/runtime.rb:72:in `require'

Thanks.

Mute the output

Am I the only one who finds it extremely annoying that i18n_routing prints all the routes every time? Is there an easy way to disable that thats not mentioned on the wiki?

Otherwise I love it ;)

Localize and scope

Hi, it's possible add some new features?

If is possible generate routes like this:

/pages
/pages/1-rails
/de/seiten
/de/seiten/1-rails

I found this gist: https://gist.github.com/1229107
but I think it would be great make it as default option called scope_localized without additional settings

match to translate

mainly i would use i18n_routing gem i will be happy if i will translate match 'vlk' under dashboard resource, trying everything around, and no success. Resources are translated successfully also new action...whats wrong?

routes.rb

MyApp::Application.routes.draw do
root :to => 'home#index'

localized do
resources :cars
resource :admin, :controller => :admin
resource :dashboard do
member do
match 'vlk', :as => :vlk
end
end
end
end

routes.yml

cs:
cars: 'auta'
admin: 'admincesky'
routes:
dashboard:
as: 'novy'
path_names:
new: 'cesky_member'
vlk: 'tzz_cesky'
named_routes_path:
vlk: 'tzz_cesky'
caa

Rails 3.1.1 support in overall

It seems many of the functions died in 3.1.1. I could make work only the basics. Only "routes:" translations works for me. And the url helpers url generation gives back the normal default rails url, witch is just not good.

I am not absolutely sure about the problems - can you check the overall rails 3.1 compatibility? It would be great! It is a really cool project!

Both original and translated routes exist: Duplicate Content

Hello,

when I use your plugin, both the original and the translated routes exist. This is a problem because it creates duplicate content, which is bad for SEO.

Is it possible to have only the translated routes, and remove the original routes, when the locale is set to a language other than the default?

Thanks!

Named routes do not translate in Rails 2.3.8

All of my resources are translated with no problems.

However, the named_routes_path namespace gives me no results in my app.

Here is the freaky part though. When I go to script/console it works fine:

console > app.welcome_path
=> "/welcome" 
console > I18n.locale = 'es'
 => "es" 
console > app.welcome_path
 => "/bienvenido"

But if I call es_welcome_path in my app its undefined, and when I rake routes I dont see it anywhere (or any named route for that matter)

Here is a look inside config/locales/es.yml:
es:
named_routes_path:
sidi: "sidi-8"
sidi_info: "sidi-8-sobre-nosotros"
sidi_contact: "sidi-8-contacto"
sidi_thanks: "sidi-8-gracias"
studio: "estudio-de-arquitectura"
studio_contact: "estudio-de-arquitectura-contacto"
studio_thanks: "estudio-de-arquitectura-gracias"
studio_team: "estudio-de-arquitectura-equipo"
tech: "tecnicas-de-rehabilitacion"
tech_contact: "tecnicas-de-rehabilitacion-contacto"
tech_thanks: "tecnicas-de-rehabilitacion-gracias"
tech_team: "tecnicas-de-rehabilitacion-equipo"
welcome: "bienvenido"

Here is how I'm setting the locale in application_controller:

before_filter :set_current_locale
private
def set_current_locale
  I18n.locale = params[:locale] ? params[:locale] : :en
end

Any idea why named routes are being ignored by this gem?

FWIW I'm running on 1.8.7-head via RVM

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.