accessing ruby I18n locale messages from the web client

I like to keep my client-side code completely decoupled from the server-side but I still want to keep one message source for localization.

The ruby stack I use includes Sinatra, Sinatra::I18n and the I18n gem for localization and this is the simplest and most effective way (that I’ve found) of accomplishing this:

The Sinatra route:
get '/locales/:locale_name/messages.js' do |locale_name|
    locale = locale_name.to_sym
    if I18n.available_locales.include? locale then
        messages = I18n.backend.send(:translations)
        "var m = " + messages[locale].to_json 
                    + "; t = function(k){ return eval('m.' + k); }";

This way the yml locale file is loaded and served and wrapped for quick use.

In the client just request the messages script and then when you need a message call t(‘message key’) just like you’d do it in ruby :)

var message = t('message.key');

new endeavours – things to avoid

When you want to start something new,  be it a business or a new product you always start up with an idea or, if you don’t have one you come up with one (by who care what process… brainstorming, calling a friend, stealing).

There’s no better idea than yours. I mean, it’s a pot of gold. What am I saying… it’s the motherload, the ultimate cash cow.

Well, before the money starts rolling in, you may want to analyse it a little further, especially regarding the intersection between your new idea, the boundary of your knowledge and the actual demand for a product such as the one you’re envisioning.

Here’s a diagram describing where you don’t want to be.

2014-01-26 Venn - Intersection - 1

cause and effect – more testing doesn’t necessarily improve software quality

A short story about cause and effect I had in my backlog.

Jim works for a software company or, why not, he may even own it.

Jim realizes that the quality of the software that gets built in his company decreases year-by-year, all over the board. He’s been seeing it for some time now but it seemed like the guys have it under control. You know, the guys know what they’re doing.

After awhile things seem to slip even further….

Continue reading cause and effect – more testing doesn’t necessarily improve software quality

competing for your time

If there’s any single thing that you’ll never get back, it’s time.

Time is the most valuable resource that you posses. It’s your currency.

Things and people are in a never-ending race, competing for your time, but ultimately, if you respect your time, you should decide who receives it.

Lao Tzu said “Time is a created thing. To say ‘I don’t have time,’ is like saying, ‘I don’t want to.” and that’s… well, deep and true.

Only give your time to the people who respect it and to the things that given time, will give it back to you.

Because the people who respect your time will use it wisely while the rest will just waste it.

Saying that you don’t have time for something is lying to yourself and others. Give it some time tomorrow, or if you think that it really doesn’t deserve your time… don’t do it.


Back when I was green and naive I thought that real physical things are valuable.

I thought that people work together based on common interest, as opposed to working together based on the intersection of personal interests. I know, it seems like a semantic difference… it’s not.

Once you realize that this is a fact, not just some philosophical gibberish your whole collaboration mindset will change.

Nobody actually wants to work toward a distant goal that will benefit us all, without searching for a personal benefit. You’ll find people who swear their allegiance, ready to do anything to prove their pure intentions. That’s just their subconscious pulling tricks on them. They’re internal subconscious radar is scanning for gain 24/7.

“Help me help you” wins every time, it’s a better, more sincere strategy.


a little product management

Even if you’re just a developer, a little product management will open your eyes.

I know, you think it’s all about marketing, and it is, sort of, but from time to time an article series like Practical Rules for Product Management makes it fun, even for non marketers. So, enjoy: