Custom Resource Name plugin

Plugin details

The Custom Resource Name Plugin lets you add aliases for your routes. This is very useful if you are developing a software to a country that does not speak English and wants all URLs in the native language.

Websitehttp://www.nomedojogo.com/custom-resource-name-plugin/ Repositorygit://github.com/carlosbrando/custom_resource_name.git Author Carlos Brando Tags resource LicenseMIT

Documentation

Install the plugin:
ruby script/plugin install git://github.com/carlosbrando/custom_resource_name.git

To use it is simpler yet. Open the file routes.rb of your project and include the following lines BEFORE the routes that should be translated:

# translate resources
map.aliases :resources, :posts =>artigos‘, :comments =>comentarios‘

# translate actions
map.aliases :actions, :new =>novo‘, :edit =>editar‘, :logout =>sair‘

# translate namespaces
map.aliases :namespaces, :admin =>administrativo‘


If you have any english route that should stay untouched, put it before the aliases definition.

Ready!

You can add aliases for all its resources and actions.


New feature
===========

Added one more feature to plugin. Imagine the following case:

ActionController::Routing::Routes.draw do |map|
  map.aliases :resources, :houses => 'casas'
  map.aliases :actions, :new => 'novo'

  map.resources :houses
end


See that all actions :new will be replaced by 'novo', but this does not fit properly in resource :casas, which would correct be 'nova' and not 'novo' (is just one example).

In this case we can use the option :actions_as in the resources, like this:

map.resources :houses, :actions_as => {:new => 'nova'}


Problem solved. In all other cases the action :new will be called 'novo', but only in the resource :casas it will be 'nova'.

In addition we also have the option :as those who do the same thing with the name of the resource.

Further Documentation

There is currently no advanced documentation for this plugin.

New documentation

Edit plugin | (0 older versions) | Last edited by: hardway, about 1 month ago