phPo Translator – Online PO Translator

One of the great things about being a programmer is that when I have a problem, it’s pretty easy to solve it myself1.

I recently began to seriously support i18n (internationalization) in the Countdown Timer. It’s actually a pretty slick system. Everywhere I have some text that’s output in the plugin, I wrap it in a WordPress defined function that handles the translation. Then I generate a PO file using poEdit and make a MO (which is just a binary/machine object file of the PO file, which is human readable).

The issue is, if someone wanted to translate the PO file, they’d have to download poEdit, figure out how to use it, grab the PO file, translate it, make the MO file, and then send the MO file to me. This works pretty well if the users is a computer guru. But that’s not often the case.

I was hoping there would be an online PO translator, but I couldn’t find one. So I decided to make my own. Thus I present, in the form of clever titles that mash two words together, phPo Translator (or just phPo for short).

I basically wrote the code over lunch today and then decided that I should version control it. So I threw it up on Google Code, which I knew about but had never, up until this point, actually used.

Google Code is simply amazing. It took less then a minute to register and it uses SVN, which I already have installed on my computer. So I upload the code, create the tag, and away we go!

In any event, you can:

See it in action: Translate afdn_countdownTimer.po
Download phPo Translator v0.1.1
View phPo Translator Google Code page

  1. Granted, most of my problems are probably caused because I am a programmer 

Automating SVN Tagging

I’ve been using the SVN version control system for a couple years now to maintain the code for the WordPress plugins I write. Using a version control system is a fantastic tool that allows me to write and release great code. However, this post is not about how SVN is spectacular and everyone should use it whenever they write code of any sort (although they should). This post is about automating SVN tagging.

But first, a quick overview of SVN and how things are done. There are three main directories for each plugin that I write: trunk, tag, branch.

‘Trunk’ is the main code area and is where all primary and active development of code occurs. The latest version of any plugin can be found in the Trunk folder.

‘Branch’ is similar to Trunk, however it’s mostly used for side development. It’s actually exactly the same as Tag, except that development continues in a Branch.

‘Tag’ is where copy of milestones are kept. For me, this means versions of plugins that I release. You can browse the tag folder and find all the versions of a plugin I’ve created and download them if you wanted. It’s similar to a Branch, but development is not continued.

I rarely create branches. I think this is mostly because I’m the only official contributor and there are not other developers working on them at the same time. So other then committing changes to the trunk, the only other operation I perform on a regular basis is tagging. The issue with tagging, though, is that it’s a tedious and repetitive process that should be automated in SVN for large sets of files, but isn’t.

This annoys me.

So I created a solution. I downloaded the SVN command line version and then wrote the following Batch file:

set TAG=
set /P TAG=Version Tag: %=%
if "%TAG%"=="" goto input
echo Creating the version %TAG%
svn mkdir %BASEURL%/tags/%TAG%/ -m "Version %TAG% tag"
set FILE=afdn_countdownTimer.php
svn copy %BASEURL%/trunk/%FILE% %BASEURL%/tags/%TAG%/%FILE% -m "Version %TAG% tag"
set FILE=afdn_countdownTimer.po
svn copy %BASEURL%/trunk/%FILE% %BASEURL%/tags/%TAG%/%FILE% -m "Version %TAG% tag"
set FILE=afdn_countdownTimer.po
svn copy %BASEURL%/trunk/%FILE% %BASEURL%/tags/%TAG%/%FILE% -m "Version %TAG% tag"
svn copy %BASEURL%/trunk/%FILE% %BASEURL%/tags/%TAG%/%FILE% -m "Version %TAG% tag"
set FILE=afdn_countdownTimer-es_ES.po
svn copy %BASEURL%/trunk/%FILE% %BASEURL%/tags/%TAG%/%FILE% -m "Version %TAG% tag"
svn copy %BASEURL%/trunk/%FILE% %BASEURL%/tags/%TAG%/%FILE% -m "Version %TAG% tag"
set FILE=afdn_countdownTimer-sv_SE.po
svn copy %BASEURL%/trunk/%FILE% %BASEURL%/tags/%TAG%/%FILE% -m "Version %TAG% tag"
set FILE=fergcorp_countdownTimer_java.js
svn copy %BASEURL%/trunk/%FILE% %BASEURL%/tags/%TAG%/%FILE% -m "Version %TAG% tag"
set FILE=readme.txt
svn copy %BASEURL%/trunk/%FILE% %BASEURL%/tags/%TAG%/%FILE% -m "Version %TAG% tag"
set FILE=screenshot-1.png
svn copy %BASEURL%/trunk/%FILE% %BASEURL%/tags/%TAG%/%FILE% -m "Version %TAG% tag"
set FILE=screenshot-2.png
svn copy %BASEURL%/trunk/%FILE% %BASEURL%/tags/%TAG%/%FILE% -m "Version %TAG% tag"

It’s not terribly pretty, in fact I’d argue that it’s downright ugly. But. It does get the job done. One of the things that I want to do is figure out a better way to do the “svn copy” part of the operation since it’s repetitive. However, Batch files don’t appear to handle arrays at all. Although they do handle loops (I believe) and I could just pass the file names in as parameters. I may end up converting the thing to VBScript or write little C++, although it’s been ages since I’ve done either.