Tuesday, June 30, 2009

I spoke too soon

Yesterday wasn't much fun. I was in bed with the flu, and so Monday passed and no code was uploaded to the repository. I am feeling a bit better today and have had a look at the code I wrote last week. I also noticed that my todo list was missing an important item. Item number 4, from the previous post, says:

I need to make sure that svn lock is used at the right places, and that the script also adds and commits the files before it's finished.

In addition to that, I also need to think about the small details when it comes to locking and unlocking. What should happen if the lock can't be aquired? What should happen when svn up results in conflicts or the commit doesn't work? To me, exiting and letting the next invocation handle it seems like a simple way of doing it.

Hopefully tomorrow will be a more productive day.

Wednesday, June 24, 2009

New and improved code

Today was spent rewriting old code into something much better. The code that will take new and updated wml files and convert/update the po files are done. I will be leaving for Oslo tomorrow, but I will continue working on Monday when I'm back in London. What remains is:

1. The script needs to know what languages are supported by Pootle. For now, this is done by reading a simple text file. In the future, this could be done by getting a list of directories in /var/lib/pootle/pootle (given that this directory still exists on the server where Pootle is set up).

2. The script needs to check svn up twice. Once to figure out which wml files are added/updated, and once to figure out which po files are updated. To deal with this, I plan on introducing a file, svnup.tmp, that the script will generate, read from and then delete.

3. I need to add the code that will take the updated po files and convert them back to wml. The code will not be much different from the code I wrote for the svn hooks, so this should be quick and easy.

4. I need to make sure that svn lock is used at the right places, and that the script also adds and commits the files before it's finished.

Thoroughly documented and fully working code will, hopefully, be committed to the tor svn repository on Monday.

Tuesday, June 23, 2009

If at first you don't succeed

I decided to look into po4a and its configuration file, hoping that it would be a better solution than svn hooks. Turns out it was a dead end. Using the configuration file will only help keep the translated documents updated (for example, the Norwegian version of gsoc.wml), but it doesn't do much for the pot and po files.

I have, however, received good feedback on the email I sent to the tor-gsoc mailing list last week, asking for suggestions and ideas regarding my solution with svn hooks. One of the suggestions was to have a script that one can run any number of times, and if the input hasn't changed it won't do anything.

So, my new and improved plan is to take the hooks that I have, clean up the code and, instead of checking for new files in a revision/transaction using svnlook, checkout/update a working copy of the HEAD and find out what files I need to update from svn up.

Some questions have been raised as to what should be done with Pootle. At the moment, Pootle needs to be restarted to learn about new files. The good news is that this will be improved in the next version, where one can tell Pootle to rescan for files from the admin interface. A possible, but not pretty, solution could be to have a cron job that runs the script and restarts Pootle once a day.

Thursday, June 18, 2009

The best solution?

So, I merged the first and second hook into one hook that will deal with both new and updated wml files. That hook will work like this:

* Bob commits a new wml file, lets call this tor.wml
* The SVN hook takes tor.wml and does three things:
- Converts to tor.po
- Sets the right encoding and charset in tor.po
- Commits tor.po

The "problem" with this solution is that the hook alters a transaction. When Bob thinks he's committing only one file (tor.wml), he is actually committing two files (tor.wml and tor.po). It may not be an ideal solution, but it works. That said, suggestions and ideas are always welcome.

Wednesday, June 17, 2009

More on SVN hooks

I managed to figure out the problem with the second and third hook, so everything is working just fine now. At the moment I have the following hooks (using the po4a framework):

1. New wml: using po4a-gettextize to convert the wml file to po
2. Updated wml: using po4a-updatepo to update the po files
3. Updated po; using po4a-translate to convert back to wml

Earlier I noticed that using po4a-updatepo will work in the case of the first hook as well, so I plan on merging the first and second hook tomorrow.

Monday, June 15, 2009

SVN hooks

I want to make sure that the wml and po files stay updated all the time, so I am writing svn hooks to take care of that. I have identified three cases where it would be useful to have pre-commit svn hooks:

1. If someone commits a new wml file: convert to po, copy to language directories and commit

2. If someone commits an updated wml file: update all the po files and commit

3. If someone commits an updated po file: convert back to wml, copy to language directories and commit

I finished the first hook last week, but I am having a few problems with the second and third one. I'm guessing it's something really simple and trivial.