Home

kwi edited this page Sep 14, 2010 · 8 revisions
Clone this wiki locally

I18nAutoScoping

I18nAutoScoping has been made in order to keep i18n translations for Rails, simple and ordered around scopes.

i18n_auto_scoping supports :

  • Default scoping on controller action through the controller’s name.
  • Default scoping on view through the view path.

That’s all, the plugin does not support intensionaly auto-scoping for models or helpers.

Default controller scoping

By default, the plugin add current controller’s name as scope when rendering an action.
Example :

class ProductsController < ApplicationController
  def show
    flash[:alert] = I18n.t('Product created') # Will have auto scope : 'products'
  end
end

ActionView auto scopping

Scope change automatically through the current rendered view’s path.

When rendering :

  • “layouts/front.html” => Scope will be ‘layouts/front’
  • “products/_product.html” => Scope will be ‘products/_product’
  • “products/index.haml.html” => Scope will be ‘products/index.html’
  • “products/index.haml.iphone” => Scope will be ‘products/index.iphone’
  • “back/products/new.html” => Scope will be ‘back/products/new’