Friday, December 19, 2008

Paste Ninja Goes Multilingual

Chris Cornutt was nice enough to give Paste Ninja (the premier PHP-powered pastebin app) some exposure by highlighting it on a week or so ago. Thanks, Chris! As a result of the extra publicity, the site saw an increase in traffic as people came to check it out. I hope they liked what they saw... but stay tuned, because there's more features to come!

It was interesting to look through the access logs afterward. There are a lot of pastebins available on the Internet, but the feature set and usability of the application is what will help differentiate it from the rest. The list of countries from which various people visited and the values of their browser's Language-Accept headers peeked my interest, and I realized that I needed to offer Paste Ninja's interface in multiple languages so people could use my service in whichever language they may find the most comfortable. So, Paste Ninja is now multilingual!

The goal is to translate PasteNinja's interface into the top 10 or so languages. I'm obviously not not going to be able to accurately translate all of the necessary text into each language myself, so I've started enlisting some help.

Years ago I studied French and Esperanto, so those were the first two languages I targeted. I then searched out people who were willing to review my work and correct any grammar deficiencies and the like. With the help of Babelfish, Google Translate, and some very creative Internet searching, I was able to produce rough translations in other languages.

If you ever need a professional French translator, Sophie Vialaneix is unbelievably good in every way and comes with my highest recommendation. She was so friendly and professional that it made me wish I had more text for her to review (thanks, Sophie)! Remi Woler from #phpc was wonderful and offered to correct my Dutch (thanks, Remi). My friend and co-worker Bobby Mladenov graciously provided a Bulgarian translation (thanks, Bobby), and Dr. Wing Ming Chan is also graciously providing a Chinese translation (thanks, Wing). Keep their efforts in mind as well when you see text that doesn't read "Grandmother your password here."

The interface is available in other languages as well, such as German, Italian, Polish, Portuguese, Russian, and Spanish. These were produced with translation software and some creative Internet searching, so expect them to be less-than-perfect. I will revise the translations as I find people proficient in them who are willing to review them. If you'd like to volunteer your skills, just leave a comment and let me know!

Oh, and the interface is also available in Pig Latin just for fun. I'm sure Ben Ramsey will be happy to take all the credit for that idea. ;)

Update 12/21/08: David Z├╝lke was kind enough to review the German translation. Thanks, David!

Update 12/23/08: Sacha Poznyak was kind enough to review the Russian translation, Ali Curtis was kind enough to review the Spanish translation, and David Cole was kind enough to review the Portuguese. Thanks, Sacha, Ali and David!

Update 12/31/08: Shahar Fisher was gracious enough to donate his time to review the Hebrew translation. Thank you, Shahar!

Friday, December 12, 2008

PHP != Perl

People irk me when they expect PHP to behave like <insert your favorite language here>. Most recently, I ran across this blog entry Perl vs PHP: Variable Scoping via the help of I'm sure Leonid is a great fellow and really smart... but he just happened to trip my irk-wire.

The post is an innocent enough "here's a problem that I ran into, so I'll blog it in case someone else has the same issue." Reading between the lines though, I get the feeling his underlying belief is that because PHP and Perl are similar that they should have the same variable scoping rules, and that since PHP's doesn't correspond to Perl's that PHP is wrong and this should be documented as such.

Each language is different. If PHP were so similar to Perl, it wouldn't be called PHP... it'd be called Perl. Or maybe a dialect, like PHPerl. I really wish people would stop comparing the two. Quite frankly, I don't see much similarity between the two languages at all.

Maybe I can get away with saying PHP and Lisp are similar because I can do the same thing in both languages!
$a = 2 + 2 * 4;
echo $a;

(setq a (* (+ 2 2) 4))
Update 12/20/2008: Luke Wellington wrote a brief article entitled PHP Is Not Java for the PHP Advent 2008 project. I'm glad to see I'm not the only one who gets irked by such things (though he is much more eloquent about it than I am).

Sunday, December 7, 2008

JavaScript Keyboard Widget

Have you ever done something stupid just so you don't have to do whatever it is you're supposed to be doing because you feel like procrastinating?  I found myself doing that this evening by programming a keyboard widget in JavaScript.

Right now it's just sloppy code without any real functionality, but feel free to take a look at it at

Theoretically, one could add a couple of state variables to monitor the ctrl, shift, alt and caps lock keys, check those variables in the keys' onclick callback, and have a fully functional keyboard widget.  Since the key characters are defined in a mapping object, it should be relatively easy to internationalize it just by changing the mapping definitions.

I may clean up the code in the future depending if someone actually sees a viable use for it or if I find myself needing to procrastinate again.

Thursday, December 4, 2008

Dialog and Paste Ninja

I'd like to share with everyone two projects that I've been working on in what little spare time I've had lately-- Dialog and Paste Ninja.

Dialog is a lightweight JavaScript-based dialog window. Why does the world need another dialog widget, you ask? It probably doesn't, but I couldn't find a freely available one that was as flexible as I wanted so I wrote my own. Flexibility and portability were key design features, so Dialog is written completely in JavaScript and CSS, and its appearance is fully CSS driven.

Dialog supports multiple dialog types by default, such as confirmation, information, warning, and error, and can further be customized with a custom dialog type. It can even display modal dialogs and block input to the page until the prompt is dismissed!

You can learn more about it and get the code at its project page, from my JavaScript Experiments repository at GitHub.

Paste Ninja
Paste Ninja is a pastebin application that lets you to share code snippets with others. Instead of flooding an IRC channel or your Instant Messenger conversations with lines of source code, you can paste it online for public viewing.

The world probably doesn't need another pastebin app, either, but there are several features in store that other pastebins don't have. The goal is to revolutionize how people use pastebins and make internet debugging a truly collaborative experience.

The back-end of Paste Ninja is written in PHP and uses a MySQL database to store pastes, comments, and the application's configuration information. The front-end is written in JavaScript.

I haven't decided yet if I'm going to opensource the code for Paste Ninja-- or under which license it would be released under if I did so-- but I'm not adverse to the idea if there is enough demand. Regardless, it's free to use, so be the "master of your pastebin" and give Paste Ninja a try at