Archive for the ‘development’ Category

Speed Scrabble Notifier for Firefox

Wednesday, September 28th, 2011

Firefox
If you’re a Speed Scrabble player and running Firefox, then you might be interested in trying the new Speed Scrabble Extension.

The add-on helps you keep track of who is currently online so you can easily drop in for a game. Try it out!.

Speed Scrabble is a fast, fun and free online multiplayer word game. If you’ve not played it before then check it out!

If you aren’t a Firefoxer, there are similar extensions for Safari and Chrome.

If you’re a software developer interested in seeing how the extension works, the source code is freely available and can be used for any purpose.

If you have any thoughts on the new extension, feel free to get in touch!

Python localization made easy

Friday, September 16th, 2011

Python
Here’s a set of simple steps to localize a Python application for different translations. This tutorial provides a clear set of steps with sample code.

Step 1: Initialize your application

Here is the code to initialize your application with localization enabled:


If you can’t see the source code try here.

This snippet looks for a resource file based on the users locale. For instance, “res/messages_en.mo” for English. If it fails to open the appropriate translation file, it falls back to NullTranslations, which simply performs no translation.

Step 2: Prepare your application for translation

trans.install() generates a global function available to all modules in your application: _().

Find all the strings in your application that you wish to translate, and wrap them with the _() function.

i.e. “Hello” becomes _(“Hello”).

This applies to parameterized strings as well. e.g. “Hello %s” % name becomes _(“Hello %s”) % name.

Step 3: Generate the pot

That’s messages.pot.

Run the command xgettext *.py or pygettext *.py. Under Windows, you might have to look for this tool. Under the Python installation directory, try Tools/i18n.

This command looks for all strings inside the _() function, and generates the file messages.pot.

Step 4: Translate

Send your generated pot file to your translator. They will replace the empty strings with the appropriate translations and return the file to you.

Step 5: Generate the mo

Save the returned file to reflect the new language that your application has been translated to. e.g. messages_De.po

Run the command msgfmt -o res/messages_De.mo messages_De.po to generate the required .mo file.

As with pygettext, if your system doesn’t find this command, look in Tools/i18n under the Python installation directory.

After running this command, the translation file required by the application will be in the res directory. When you’re distributing the application, make sure the res directory goes too.

Step 6: Test

On Windows XP, you can change your locale with the following steps:

  • Start->Control Panel->Regional and Language Options;
  • Under “Regional Options”, choose the locale for the translation file you have created and click “Apply”;
  • Start the Python application;
  • (Hopefully) enjoy your translated application!

In summary…

It’s straightforward to setup localization with Python once you know how.

JavaScript Task Queue – Hack it #9

Sunday, July 17th, 2011

Suppose you have a lot of tasks with completion callbacks to complete in the browser, but you want to do them sequentially. For instance, you might have a list of AJAX requests to make to your server.

This JavaScript demonstrates a simple solution:

If you can’t see the source code, look here.

Real-Time Auctions with HTML5, PayPal, and Google App Engine

Tuesday, June 28th, 2011

Google App EngineSupernifty’s latest series of technical articles demonstrates the use of Google App Engine and PayPal to build a real-time auction site.

We also show off some HTML5 and discuss some of the issues associated with designing a site suitable for mobile devices.

All pretty interesting if you’re into this kind of stuff. Check it out:

Or go straight to the source code.

Regular expression and Javascript Text Transformation Library

Tuesday, March 8th, 2011

Regex LibrarySupernifty has a new resource – Text Transformer. It’s a handy place to keep JavaScript text transformations and regular expressions.

If you’ve ever spent time building a complicated regular expression or transformation, check out this new page. Building regular expressions is tricky enough that you should only have to do it once, or not at all.

If someone hasn’t already built a regex that does what you want, submit yours to the site so that you can use it again later.

The site uses JavaScript to build the transformations, full source code for each transformation is available for perusal and modification – a useful learning resource.

You can also chain transformations together. For example, chain Extract Text from HTML with Word count to get the word count of a HTML page. Handy!

Keep track of new transformations with the rss feedRSS feed

We also have an API available so potentially the tool could be integrated into other applications. If you have ideas, or want to learn more, please contact us.

This will increasingly become a useful resource for JavaScript developers and regex writers, as well as anyone needing to do tricky text transformations – watch this spacesmile