Git Product home page Git Product logo

i18n_controller_namespaces's Introduction

I18nControllerNamespaces

This plugin extends the I18n translations in controllers to behave the same way as views. This means, that each translation call beginning with a dot '.' will be prefixed with a namespace. This automatic scoping takes into account the modules, class name, and method name. So a call in Admin::UsersController.index will be prefixed with 'admin.users.index'.

This plugin only works with calls to t() and translate() within controllers which inherit from ActionController::Base. Calls to I18n.t() and I18n.translate() are not touched and keys will not be prefixed.

Note: This plugin has only been tested with rails3 and has a very limited test coverage. So please run your test suite before using it in production. I hope I will find time to extend it. Or just fork and add it yourself.

Example

class UserController < ApplicationController

POST: /users

def create # your app logic redirect_to :index, :notice => t('.success') end

end

After creating a new user, this controller would redirect you to the users index and would show a flash notice message with the key

users.create.success


Copyright (c) 2010 Maximilian Schulz (kulturfluss.de) released under the MIT license

i18n_controller_namespaces's People

Contributors

namxam avatar

Watchers

 avatar  avatar

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.