After four long months of waiting (due to my being busy with sekrit work), script.aculo.us 1.6.2 is now out!
It’s a mostly-bug-fix-only release, so don’t expect any major oohs! and aahs! here, but sure get it. It’s recommended for all users, and addresses various more-or-less cosmetically issues, besides a memory leak bug with Draggables and an endless loop in the Slider code.
Anyway, big, big thanks to all contributors who continue to do patches and bug reports! Hopefully the trac will be up to speed soon (new server is coming!). If you should have any issues, please report it to the rails-spinoffs mailing list.
Updates and fixes:
There are also some updated functional and unit tests (use these links to get to live online versions of these).
Also, this version of script.aculo.us is now included with Edge Rails (as of changeset 4765), and should be part of the upcoming (as in “when it’s ready”) Rails 1.2 release.
Next up: Planning the script.aculo.us 2 release… ;)
The next release of Apple’s operating system Mac OS X 10.5 will ship with Ruby on Rails installed (read more on this at Riding Rails).
Cool stuff indeed.
Along with fellow core team members and other railsers, I’m going to be one of the Judges for Rails Day 2006.
With lots of cool prizes around, we’re probably going to have a tough time on deciding what’s best (and I do hope some serious freakin’ hot stuff will be developed!).
I’m going to hang out at the campfire tomorrow, and maybe I can even answer a question or two if you’re using script.aculo.us (or just hit #prototype on freenode.net).
Rails Day 2006 is coming soon and we here at wollzelle will add some cool stuff to the already very nice prize list.
I’ll give a quick update here, as soon as it’s official on the Rails Day site. Update: We’re giving away 5 fluxiom Pro accounts to Rails Day winners, read more on that at the offical Rails Day blog.
And for you Rails developers: I want to see some cool uses of script.aculo.us, so please don’t let me down! :)
Sebastian Gräßl is doing a Workshop on Ruby on Rails in Graz, Styria on January 21 and 22.
It’s cheap too, so if you want to start with Ruby on Rails, there’s no excuse now…
Put this in application_helper.rb:
def u(html)
h(html).gsub(/([^\x00-\x9f])/u) { |s|
"&#x%x;" % $1.unpack('U')[0] }
end
This will automatically output 香-style HTML entities where needed.
I’m using it for escaping HTML inside of Edge Rails .rjs templates, to ensure compatibility across browsers (especially Safari seems to be a bit buggy here with support for UTF-8 in Ajax calls).
The presentation on Ruby on Rails that I did last Tuesday, is now available for download at the site of the Austrian Computer Society
It’s just a few overview slides on Rails, nothing special. But I got a few oohs and aahs from the folks there, which were mainly Java developers.
Update: Some nice guy Ichigo (who is a nice guy), who attended the whole thing recorded audio (while the presentation itself is in English, the audio is in German). :)
The Austrian Computer Society holds a one-afternoon presentation on Open source web development frameworks on November 29 here in Vienna, Austria.
All presentations will be in German (but the presentation slides will probably be available in English).
Participation is free (registration is required!). I’ll do a talk on Ruby on Rails which will “compete” with some Java-based frameworks (Cocoon/JSF/Struts). Hopefully I can lure some Java developers to Rails :)
I’ve updated my pragmatic i18n/l10n library for Ruby on Rails and released it as a plugin.
With the latest edge rails, a simple script/plugin install localization should get you going.
For more information, see the included README flie!
Still rough warning, so expect more tomorrow or so.
Having a requirement for both internationalization and per-instance customizability of translations in our soon to be revealed application, I wanted to go with an as-simple-as-possible pure Ruby solution for translating strings.
While gettext based approaches might have some advantages over this (some tools available, possibly faster speed with C-based variants) I didn’t want to go with a sledgehammerized solution (I’ve very few strings in the app, and I really only need to support a handful of languages), so I’ve come up with this:
# .rb files to define l10ns in (lang/ and lang/custom/)
Localization.define('de_DE') do |l|
l.store "blah", "blub"
l.store "testing %d", ["Singular: %d", "Plural: %d"]
end
# Call from anywhere (extension to Object class):
_('blah')
_('testing %d', 5)
# in .rhtml
<%=_ 'testing %d', 1 %>
# current language is a class var in class
# Localization, so set e.g. in application.rb
Localization.lang = 'de_DE'
# in environment.rb (rails 0.13.1)
Localization.load
All you need to include for this is the following localization.rb file, which you stick in your lib directory:
module Localization
mattr_accessor :lang
@@l10s = { :default => {} }
@@lang = :default
def self._(string_to_localize, *args)
translated =
@@l10s[@@lang][string_to_localize] || string_to_localize
return translated.call(*args).to_s if translated.is_a? Proc
translated =
translated[args[0]>1 ? 1 : 0] if translated.is_a?(Array)
sprintf translated, *args
end
def self.define(lang = :default)
@@l10s[lang] ||= {}
yield @@l10s[lang]
end
def self.load
Dir.glob("#{RAILS_ROOT}/lang/*.rb"){ |t| require t }
Dir.glob("#{RAILS_ROOT}/lang/custom/*.rb"){ |t| require t }
end
end
class Object
def _(*args); Localization._(*args); end
end
It should be easy to alter or extend that for your own purposes, or just use it as-is.
Update: Changed to module; and here’s a very quick hack to extract a nice pre-generated guesstimation of a l10n file:
# Generates a best-estimate l10n file from all views by
# collecting calls to _() -- note: use the generated file only
# as a start (this method is only guesstimating)
def self.generate_l10n_file
"Localization.define('en_US') do |l|\n" <<
Dir.glob("#{RAILS_ROOT}/app/views/**/*.rhtml").collect do |f|
["# #{f}"] << File.read(f).scan(/<%.*[^\w]_\s*[\"\'](.*?)[\"\']/)
end.uniq.flatten.collect do |g|
g.starts_with?('#') ? "\n #{g}" : " l.store '#{g}', '#{g}'"
end.uniq.join("\n") << "\nend"
end
To use that, call up script/console and do a puts Localization.generate_l10n_file.
Update 2: I’ve added support for using nice lambda blocks of code for those “speciality” translations. The block gets passed the *args given to the _ method, so you can basically do anything:
Localization.define do |l|
l.store '(time)', lambda { |t| t.strftime('%I:%M%p') }
end
Localization.define('de_DE') do |l|
l.store '(time)', lambda { |t| t.strftime('%H:%M') }
end
_ '(time)', Time.now =>"10:13PM"
Localization.lang = 'de_DE'
_ '(time)', Time.now => "22:13"