Ruby on Rails
Click To Globalize (Version #12)

Click To Globalize is an extension for Globalize Plugin, it allows to edit in place globalized labels. With this plugin you don’t have to create a globalization back-end, but just edit your interface in place!!

If you have a previous globalization experience, you probably noticed that the main problem of dedicated back-ends is the lack of the context where the string will be placed in. It isn’t a trivial issue: you’ll never know if the meaning of your string is harmonious with other labels and how your string will be rendered, until the page load.

Now you can forget this issues, you can directly globalize in place!!

Getting Started

  1. Install Globalize, if you don’t already done.
  2. Install Click To Globalize:

    $ ./scripts/plugin install <a href="http://dev.23labs.net/svn/rails/plugins/click_to_globalize/trunk">http://dev.23labs.net/svn/rails/plugins/click_to_globalize/trunk</a>
  3. Run the setup task:
    $ rake click:setup
  4. Add at the end of your layout the following code:
    <%= click_to_globalize -%>
  5. Put in your view:
    <%= 'hello_world'.t %>
  6. Start the server and click to globalize.

Prerequisites

  • Globalize plugin: www.globalize-rails.org.
  • Prototype 1.5.1.1, this version is provided by Click To Globalize installation.
  • RedCloth gem (optional) for textile formatting.
  • BlueCloth gem (optional) for markdown formatting.

Install

  1. Install Globalize, if you don’t already done.
  2. Install Click To Globalize:
    Rails 2.0 $ ./scripts/plugin install <a href="http://dev.23labs.net/svn/rails/plugins/click_to_globalize/trunk">http://dev.23labs.net/svn/rails/plugins/click_to_globalize/trunk</a> Rails 1.2.x $ ./scripts/plugin install <a href="http://dev.23labs.net/svn/rails/plugins/click_to_globalize/branches/for-1.2">http://dev.23labs.net/svn/rails/plugins/click_to_globalize/branches/for-1.2</a>
  1. Run the setup task:
    $ rake click:setup
  2. Run the tests (optional):
    $ rake click:test
  3. Choose your languages, they will be used to create a picker menu.

    class ApplicationController < ActionController::Base
    self.languages = { :english => 'en-US', :italian => 'it-IT' }
    end
  4. If you like to use wiki-formatting styles, you could use textile (RedCloth) or markdown (BlueCloth).

    class ApplicationController < ActionController::Base
    self.formatting :textile
    end
  5. Customize the access to the globalization features, overriding #globalize:
    class ApplicationController < ActionController::Base
    def self.globalize?
    current_user.admin?
    end
    end
    NOTICE: #globalize? is method to turn on/off all the Click To Globalize features.
  6. Add at the end of your layout the following code:
    <%= click_to_globalize -%>

Uninstall

$ ./script/plugin remove click_to_globalize

Features

  • In-place editing for each globalized string.
  • Easy and painless plug-in/plug-out process.
  • Unobtrusive Javascript.
  • Auto transformation from input text to textarea for long strings.

Common Issues

  • The install process upgrades your Prototype version to 1.5.1.1 only if needed, but it’s advisable to backup your scripts.
  • Since the Globalize plugin creates folders like for-1.2, be sure to rename the folder to globalize.
  • Due to unobtrusive nature of the plugin, each page is parsed by javascript to find the right element and bind to it an Ajax.InPlaceEditor. Be sure your (X)HTML is wellformed. NOTICE: If you use the Rails 1.2.3 scaffold system, Click To Globalize doesn’t works. Cleanup the code before to use.
  • If you use a wiki-formatting style it could be advisable to use #h to avoid security problems (i.e. XSS).
    <%= textilize(h('some_text'.t)) %>

Contribute

  • Check out the code and test it:
    $ svn co <a href="http://dev.23labs.net/svn/rails/plugins/click_to_globalize/trunk">http://dev.23labs.net/svn/rails/plugins/click_to_globalize/trunk</a>
    $ rake click:test
  • Create tickets at the project Trac.
  • Create a patches and add as attachement to the tickets.

Repository

http://dev.23labs.net/svn/rails/plugins/click_to_globalize/

Credits

Javascript tests are based on Prototype test libs.

Copyright

Copyright© 2007 Luca Guidi23 Labs, released under the MIT license.

Video Tutorials

Click To Globalize is an extension for Globalize Plugin, it allows to edit in place globalized labels. With this plugin you don’t have to create a globalization back-end, but just edit your interface in place!!

If you have a previous globalization experience, you probably noticed that the main problem of dedicated back-ends is the lack of the context where the string will be placed in. It isn’t a trivial issue: you’ll never know if the meaning of your string is harmonious with other labels and how your string will be rendered, until the page load.

Now you can forget this issues, you can directly globalize in place!!

Getting Started

  1. Install Globalize, if you don’t already done.
  2. Install Click To Globalize:

    $ ./scripts/plugin install <a href="http://dev.23labs.net/svn/rails/plugins/click_to_globalize/trunk">http://dev.23labs.net/svn/rails/plugins/click_to_globalize/trunk</a>
  3. Run the setup task:
    $ rake click:setup
  4. Add at the end of your layout the following code:
    <%= click_to_globalize -%>
  5. Put in your view:
    <%= 'hello_world'.t %>
  6. Start the server and click to globalize.

Prerequisites

  • Globalize plugin: www.globalize-rails.org.
  • Prototype 1.5.1.1, this version is provided by Click To Globalize installation.
  • RedCloth gem (optional) for textile formatting.
  • BlueCloth gem (optional) for markdown formatting.

Install

  1. Install Globalize, if you don’t already done.
  2. Install Click To Globalize:
    Rails 2.0 $ ./scripts/plugin install <a href="http://dev.23labs.net/svn/rails/plugins/click_to_globalize/trunk">http://dev.23labs.net/svn/rails/plugins/click_to_globalize/trunk</a> Rails 1.2.x $ ./scripts/plugin install <a href="http://dev.23labs.net/svn/rails/plugins/click_to_globalize/branches/for-1.2">http://dev.23labs.net/svn/rails/plugins/click_to_globalize/branches/for-1.2</a>
  1. Run the setup task:
    $ rake click:setup
  2. Run the tests (optional):
    $ rake click:test
  3. Choose your languages, they will be used to create a picker menu.

    class ApplicationController < ActionController::Base
    self.languages = { :english => 'en-US', :italian => 'it-IT' }
    end
  4. If you like to use wiki-formatting styles, you could use textile (RedCloth) or markdown (BlueCloth).

    class ApplicationController < ActionController::Base
    self.formatting :textile
    end
  5. Customize the access to the globalization features, overriding #globalize:
    class ApplicationController < ActionController::Base
    def self.globalize?
    current_user.admin?
    end
    end
    NOTICE: #globalize? is method to turn on/off all the Click To Globalize features.
  6. Add at the end of your layout the following code:
    <%= click_to_globalize -%>

Uninstall

$ ./script/plugin remove click_to_globalize

Features

  • In-place editing for each globalized string.
  • Easy and painless plug-in/plug-out process.
  • Unobtrusive Javascript.
  • Auto transformation from input text to textarea for long strings.

Common Issues

  • The install process upgrades your Prototype version to 1.5.1.1 only if needed, but it’s advisable to backup your scripts.
  • Since the Globalize plugin creates folders like for-1.2, be sure to rename the folder to globalize.
  • Due to unobtrusive nature of the plugin, each page is parsed by javascript to find the right element and bind to it an Ajax.InPlaceEditor. Be sure your (X)HTML is wellformed. NOTICE: If you use the Rails 1.2.3 scaffold system, Click To Globalize doesn’t works. Cleanup the code before to use.
  • If you use a wiki-formatting style it could be advisable to use #h to avoid security problems (i.e. XSS).
    <%= textilize(h('some_text'.t)) %>

Contribute

  • Check out the code and test it:
    $ svn co <a href="http://dev.23labs.net/svn/rails/plugins/click_to_globalize/trunk">http://dev.23labs.net/svn/rails/plugins/click_to_globalize/trunk</a>
    $ rake click:test
  • Create tickets at the project Trac.
  • Create a patches and add as attachement to the tickets.

Repository

http://dev.23labs.net/svn/rails/plugins/click_to_globalize/

Credits

Javascript tests are based on Prototype test libs.

Copyright

Copyright© 2007 Luca Guidi23 Labs, released under the MIT license.

Video Tutorials