Taking Your Application International

Many clients develop their applications with only one language in mind. Recently one of our clients after we had developed two different applications for them decided that the applications needed to be translated into seven different languages. At first the client said, “We’ll just make seven copies of it, and update each one separately.” While this may at first seem the be a quick simple solution, think of the long term affects of this. First, if the application is large, you are going to be wasting much space. Second, and most important, using this approach you are going to be stuck trying to maintain seven different copies of the same application; every update for each each application will have to be made seven times. Not only is this error prone, but it is inefficient.

Our solution? Use a common practice called internationalization (i18n) and localization (l10n). i18n and l10n is text translation (from page content to form labels to error message) and localizing of content ( displaying dates, currency, numbers, etc. in a specific format). For many applications this is not an easy process, and often could require one to go back and rewrite much of the code. However, we use Symfony which makes the task much easier. Symfony allows you to use dictionary files and the database to handle this. Symfony can scan your entire project looking for specific markup(__(“Text here”)) and pull the strings out into a simple XML file which you can enter the translations for. The file looks like the following:

    <?xml version=”1.0″ encoding=”UTF-8″?>
    <!DOCTYPE xliff PUBLIC “-//XLIFF//DTD XLIFF//EN” “http://www.oasis-open.org/committees/xliff/documents/xliff.dtd”>
    <xliff version=”1.0″>
    <file source-language=”en_US” target-language=”en_US” datatype=”plaintext” original=”messages” date=”2009-05-28T17:27:02Z” product-name=”messages”>
    <header/>

    <body>

    <trans-unit id=”1″>
    <source>My String To Be Converted</source>
    <target/>
    </trans-unit>

    </trans-unit>
    </body>
    </file>
    </xliff>

With file all you need to do is to modify the <target /> to <target>My Translated Text</target> When the string “My String To Be Converted” is output in the application it will be converted to “My Translated Text”. You’d save this file for example as messages.es.xml if it was the Spanish translation file.

To read more on internationalization with Symfony visithttp://www.symfony-project.org/book/1_2/13-I18n-and-L10n. We use Symfony because of situations like this it allows us to quickly adapt our products to our customer needs.

Always think ahead when developing your applications. Planning for the future work on an application can save you hours of rewriting.

GIT Ignores and Symfony

We use GIT for version control at Setfive.  However often with our Symfony projects creating all the ignore files in all the plugins model/base’s and other locations throughout the project get very tiresome.  Since on some larger projects you can end up with 10-20 plugins, having to create an ignore for the autogenerated model, forms, and filters takes a long time.  Today we really quickly just wrote a plugin that allows you to quickly just run symfony util:generate-ignores git –add-ignores and it will automatically place the .gitignore file throughout your project in the correct locations and add them into your next commit.  You can also just have it place them throughout the project, but not add them to the next commit if you drop the –add-ignores option.  The plugin also accepts “cvs” instead of git for cvs based projects.

The reason you do not want the base, om, etc. directories in your repository is because every time a person rebuilds the model they will be updating those files(many times just changing the timestamp at the top of the autogenerated files), which causes uncessarily large commits.

You can get the plugin via http://www.symfony-project.org/plugins/sfSCMIgnoresTaskPlugin">http://www.symfony-project.org/plugins/sfSCMIgnoresTaskPlugin or install it via symfony plugin:install sfSCMIgnoresTaskPlugin.

If you have any questions/requests shoot us an email.

Merry Christmas and Happy Holidays

Setfive would like to wish everyone a merry Christmas and happy holidays.  We hope everyone has a great holiday season.  We’ll be bringing in the new year with a bang, and look forward to working with you.

Happy Holidays All!

Importance of Having Technical Knowledge Onboard

Today I want to take the chance to stress the importance of having someone onboard that knows some technology. Through our experience we’ve often had clients who were mislead or taken advantage of by other technology firms. Whether it is being given poor advice or being overcharged for simple tasks, we’ve seen it quite a bit. In many of these situations a person with some technological knowledge would have saved them money and time.

What can a person with technical knowledge do?

  • Know what questions to ask - "Do you provide documentation for your code? Do you use a framework? Is your code MVC compliant? etc."
  • Know when you are being taken advantage of - We've seen in the past many clients purchased servers and functionality they just don't need. A technical person can make sure that you aren't purchasing five servers when one will do, that you aren't overpaying for simple hosting, etc.
  • To help choose your development firm. It is very difficult to tell whether a firms code is good. If you do not have knowledge in the area, good code and bad code appear to be the same. Choosing the development firm for your project can make or break the project. If the firm chosen produces messy, inefficient code, it dooms your product before it is even launched.
  • To monitor code quality. Once you've picked your development firm, it is important to check in now and then to make sure the quality of the code is of the caliber you are paying for. It is crucial to catch poor code in the beginning, to make sure the firm doesn't continue to use the same coding style.
What if you don't want to have a technical person on staff full time? Hire a consulting firm. Many firms provide assistance with choosing your development team and to monitor most of the technical aspects of the product. We offer these services.

Moral: Having technical knowledge onboard prevents your company from being taken advantage of and will often pay for itself in saved time and a quality delivered product.

Guestimating the election with twitter

We were sitting around tonight and decided to whip something together to leverage twitter to get some real time election information.

It is ugly and open to bias but we’re hopping it might show something interesting.

We’re also planning to take snapshots of the map and assemble a time lapse for Wednesday.

See the map live at: http://election.setfive.com">http://election.setfive.com

Update at 4.40 EST:

So we’ve captured about 6000 tweets and the map is basically all blue. Just to clarify - we never intended this to be a serious vizualization or estimation of how the election is progressing. The project was soley meant to be a fun peak at how information spreads across Twitter.

Anyway, a couple of people have been asking about our methodoly so I’ll try and explain a bit.

We are using the Twitter Search API to run searches that we thought would indicate that someone just voted or intends to vote for either John McCain or Barrack Obama. Next, we apply some heuristics to the tweets to make sure they really are “just voted” tweets. If the tweet passes through the heuristics we record it for whichever candidate and then record the “from_user_id” to ensure a single user can’t blow up the vote totals.

In order to geolocate a user we are using the twittervision API I get the impression that the twittervision API just scrapes user profiles but I can’t verify this. We probably could have avoided using their API and just scraped ourselves but one less thing to deal with at 4am is always good.

The graph colors are calculated by taking the larger vote total (red vs blue) and then determining in percent, how much larger this is than the total number of votes for that state:

$totalScore=$state[‘redscore’]+$state[‘bluescore’]; $percentage=($state[‘redscore’]-$state[‘bluescore’])/$totalScore;

Anyway, there are defitley other entertaining things to do with twitter - we just haven’t thought of them yet. - Ashish