Posts for: #I18n

Rails: Unobtrusive and i18n Javascript confirm

How many times do you heard you should separate content from behavior? Never? Hmmm don’t try to cheat me.. So, why do you still use :confirm option for link_to helper?

Here a little snippet to archive our goal, and as extra bonus, you get it i18n:


<script type="text/javascript">
window._authenticity_token = "";
</script>

t(:’asset.destroy’),
:class => “delete”,
:’data-confirm’ => t(:’asset.destroy_confirm’) %>


$(document).ready(function(){
$(".delete").bind("click", function() {
if(window.confirm($(this).attr("data-confirm"))) {
$.ajax({
url: $(element).attr("href"),
data: {
_method: "delete",
authenticity_token: window._authenticity_token
},
type: 'post',
dataType: 'script'
});
}
return false;
});
});

[]

Click To Globalize for Rails 2.3

For all of you who don’t know what I’m talking about, **Click to Globalize** is a Rails plugin for in-place translations. Now it’s compatible with Rails 2.3 and It’s also the most clean and polish version of ever, let me explain what’s changed.

Engine

Yes, **Click to Globalize** is now an [engine](http://rails-engines.org/), this means all the controllers, the helpers, the routes and the other stuff, now lives in `vendor/plugins`. No more clutter with flying files, except for one javascript and one stylesheet.

I18n

The [i18n team](http://i18n-rails.org/) (myself included) worked hard to build a **consistent API** for i18n. Starting from Rails 2.2 we have bundled a gem for this purpose, and now my plugin is totally compliant with this system, this **agnosticism** allow you to use whatever i18n backend you want. Click to Globalize is **no longer a Globalize extension!!**

RESTful

The plugin now bundles two **full RESTful** controllers: `TranslationsController` and `LocalesController`, respectively `/translations` and `/locales`.

Lightweight

I replaced the annoying `around_filter` system, with a more lightweight one, based on the observation of `ActionView#render`.

Formatting

I removed the support for **Markdown** and **Textile**, personally I never used so much, and don’t think they are so related with i18n.

Deprecations

The old `globalize?` method is deprecated in favor of `in_place_translations?`.

You can find all the new instructions to the [project page](http://lucaguidi.com/projects/click-to-globalize) or on [GitHub](http://github.com/jodosha/click-to-globalize).
Enjoy!

[]

Click To Globalize: Ready for Rails 2.1!

Click to Globalize is ready for Rails 2.1!

I spent a lot of time to make this release the best of ever! I know that a lot of time has passed since the latest Rails major release, and I apologize for this. The official Globalize it seems dead, but the great work of Nate Clark (aka heythisisnate) has made it compatible with Rails 2.1. Thanks Nate! The Rails Edge now includes a basic support for i18n!

[]

Click to Globalize: rewritten and moved to GitHub

Click to Globalize has been rewritten, in order to use all instance methods of the JavaScript class, instead of class methods.

I also fixed some tiny issues:

  • The form_authentication_token method is called only if the application is protected against the CSRF attacks (protect_against_forgery? returns true)
  • It uses as parameter key what request_forgery_protection_token returns, instead of the hard-coded authenticity_token
  • The JavaScript class uses Prototype’s dom:loaded custom event.

I also migrated the plugin GitHub. The new repo is http://github.com/jodosha/click-to-globalize/tree/master, so the oldest one is deprecated. Have a nice globalization!

[]