Click to Globalize
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
- Install Globalize 1, if you don't already done.
- Install Click to Globalize:
$ ./scripts/plugin install git://github.com/jodosha/click-to-globalize.git - Run the setup task:
$ rake click:setup - Edit
config/click.yml - Add at the end of your layout the following code:
<%= click_to_globalize -%> - Put in your view:
<%= 'hello_world'.t %> - Start the server and click to globalize.
Prerequisites
- Globalize 1 plugin: www.globalize-rails.org.
- Prototype >= 1.5.1.1, this version was bundled in the outdated versions.
- RedCloth gem (optional) for textile formatting.
- BlueCloth gem (optional) for markdown formatting.
Install
NOTE the following instructions are for Click to Globalize v0.4.0 (Rails 2.1.x), for older version, please check your README.
- Install Globalize 1, if you don't already done.
- Install Click to Globalize:
Rails 2.1.x
Rails 2.0.x$ ./script/plugin install git://github.com/jodosha/click-to-globalize.git
Rails 1.2.x$ ./script/plugin install http://dev.23labs.net/svn/rails/plugins/click_to_globalize/trunk$ ./script/plugin install http://dev.23labs.net/svn/rails/plugins/click_to_globalize/branches/for-1.2.x - Run the setup task:
$ rake click:setup - Run the tests (optional):
$ rake click:test - Edit
config/click.yml , adding your locales (including the default one), and, optionally, the formatting style: - Personalize the access to the globalization features, overriding #globalize:
class ApplicationController < ActionController::Base def self.globalize? current_user.admin? end end
NOTE:#globalize?is method to turn on/off all the Click to Globalize features. - Add at the end of your layout the following code:
<%= click_to_globalize -%>
locales:
english: en-US
italian: it-IT
#optional
default: :english
# optional
formatting: textileNOTE: Make sure to choose a default locale before the app starts.
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 (for Rails 1.2.x) upgrades your Prototype version to 1.5.1.1 only if needed, but it's advisable to backup your scripts.
- 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.x 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)) %> - The official Globalize repository is still not compatible with Rails 2.1, use the heythisisnate's fork instead.
Contribute
- Check out the code and test it:
$ git clone git://github.com/jodosha/click-to-globalize.git $ rake click - Create tickets at the Sushistar Lighthouse Page.
- Create a patches and add as attachement to the tickets.
Repository
http://github.com/jodosha/click-to-globalize/tree/master
Credits
Javascript tests are based on Prototype test libs.
Vote
If you find it useful feel free to add to your favs on agilewebdevelopment.com.
Copyright
Copyright © 2007 - 2008 http://lucaguidi.com, released under the MIT license.
Tutorials
![Click to Globalize: Getting Started [High Resolution]](http://lucaguidi.com/assets/2008/1/26/click_to_globalize_getting_started.png)
