Quick note to let you know that I updated mimetype_fu to actually get the mime type of a file using the file command on mac and linux. I still didn’t post an example since I’m planning on writing a patch for attachment_fu.
Quick note to let you know that I updated mimetype_fu to actually get the mime type of a file using the file command on mac and linux. I still didn’t post an example since I’m planning on writing a patch for attachment_fu.
I’ve been recently slightly annoyed by the lack of simple yet powerful internationalization/localization plugin for Rails.
It seems like the only real solution out there is Globalize
However, it’s a heavy, bloated, hard to setup plugin. I might seem to complain, but I’m actually glad that someone came up with a decent solution. Globalize is quite powerful but I would like to see something simpler, lighter and easier to use.
While I was looking for alternate solutions, Err released Gibberish a simple and nice localization plugin.
Looking at Chris’ code, I found a clean and nice solution but unfortunately too simple. The major problem I had with Giberrish was the lack of support for locales. That means that one cannot create an application supporting British English and American English. I lived in both America and the UK and believe me, I can never spell some words properly. How should I spell the following words: colours or colors, behaviour or behavior, aluminium or aluminum? On top of that, your UI might be slightly different based on the region your visitor is coming from. Localization is more than translation.
Anyway, I decided to come up with my own solution, a breed of the best features from my favorite i18n/l10n projects. This hybrid solution should, hopefully be useful for people not needing all the resources of Globalize. I called my new project Globa_lite_
Simple UI localization
Simple Rails Localization
Simple content i18n/l10n (coming soon)
fr.yml:
hello: bonjour
welcome: bienvenue
en-US.yml
hello: howdy
welcome: welcome
Declare the current locale or language
Globalite.current_language :fr
In your view (or anywhere else) localize a key
:hello.l
or
:hello.localize
you can also do
:unknown_key.l("this is the default text to display if the localization isn't found")
Also you can pass one or many variables to the localization(check the documentation)
Rails is automatically localized for you (meaning most helpers, including the currency converter are localized for the locale you declared).
You really easily add a new supported rails language/settings by adding a yml file or editing an existing one. (for now, I only create an English and a French localization file, but I’ll add plenty more very soon)
Globalite also saves the locale in the session allowing many users to see a site at the same time in different languages
I believe Globalite is/will be a good solution for most of my international projects. It still lacks the content i18n and l10n as well as support for pluralization but it should be added soon.
Give it a try and let me know what you think:
svn repository: svn checkout svn://rubyforge.org/var/svn/globalite/trunk globalite
ps: The project is still in beta and will change during the next few weeks, feel free to submit patches, ideas, suggestions…
3 days ago, Edge was patched to add a nicer syntax to our dear migrations.
Instead of doing:
create_table :people do |t|
t.column :name, :string
t.column :age, :integer
end
You can now do:
create_table :people do |t|
t.name :string
t.age :integer
end
While this is great, I found out that someone came up with an even nicer way of creating your migration, actually, a sexier way of doing migrations, and we all like sexy, don’t we? Otherwise we would not use Rails, would we?
Anyway thanks to this new plugin, your old Migration:
class UpdateYourFamily < ActiveRecord::Migration
create_table :updates do |t|
t.column :user_id, :integer
t.column :group_id, :integer
t.column :body, :text
t.column :type, :string
t.column :created_at, :datetime
t.column :updated_at, :datetime
end
def self.down
drop_table :updates
end
end
can look sexier than ever:
class UpdateYourFamily < ActiveRecord::Migration
create_table :updates do
foreign_key :user
foreign_key :group
text :body
string :type
timestamps!
end
def self.down
drop_table :updates
end
end
Note that I didn’t test the code above and the self.up method seems to be missing, for more information, check the official post to give it a try:
./script/plugin install svn://errtheblog.com/svn/plugins/sexy_migrations