Michal Čihař - Blog Archives for Django

Improvements in Weblate master

As there is still some development ongoing in Weblate, it's time to share information about some of the features you can expect in upcoming release.

Recently, Weblate gained ability to display changes which caused string to be fuzzy. This currently only works with Gettext PO files as no other format provides this information. If this is available Weblate shows differences between current and previous string, what allows translator to easily spot what has been changed. Example can be seen on Uzbek translation of phpMyAdmin (until somebody translates that).

While working on this feature, I've realized, that Django does not include this information in PO files. Fortunately it was pretty easy to fix and I've created a pull request to implement this. Looking at this file made me fix another thing which annoyed me since I've used translations in Django for first time - it generates POT file for every language, making the updates really slow. Fortunately it was also easy to fix and pull request is here. So if you feel makemessages is too slow, this is patch for you.

But back to Weblate as there are more changes. For example automatic locking now works more fine grained and uses AJAX to update lock period. This means translation will be unlocked much faster if you close browser with Weblate.

Also searching for messages has been updated to include substring search as well as it is sometimes more useful than fulltext search.

New job, new challenges

Starting next week, I'll start at new job. I will still stay at SUSE, so it's not that big change, but still it is new challenge for me.

I'll be moving out of L3 department, where I've spend almost four years. L3 is really a great team where man can learn basically anything, simply because you can meet there anything from broken swap on S390 up to wrong icons in LibreOffice :-).

The new position is inside Security team, still I'll be mostly focused on writing some internal tools, rather than doing security work (at least for first year or so). The current plan is base on work I've done for L3 tools and use Django for the web interface, but that's just a plan for now and might change in the future.

Anyway looking forward to new challenges at new job.

Announcing Weblate

After about week of (not so heavy) development, I can announce availability of Weblate - web based translation tool with tight Git integration.

The project was started because I was not happy with existing solutions (see my blog post) as all of them was missing some features I find useful. I started with quite simple definition:

Minimalistic web based translation with direct commit to git on each translation made. There is no plan in heavy conflict resolution as these should be primarily handled on git side.

Also the project started with defined list of features:

  • Easy web based translation
  • Propagation of translations across sub-projects (for different branches)
  • Tight git integration
  • Usage of Django's admin interface
  • Upload and automatic merging of po files
  • Links to source files for context

Pretty much all of that is completed right now, however there will be definitely some issues which will need fixing.

All important information about the project are available on it's website, the code is hosted on Github. If you are curious how it looks, you can try it out on demo server. You can login there with demo account using demo password or register your own user.

Please give it some testing as I plan to deploy it on http://l10n.cihar.com/ pretty soon.

Fixup of historical data

This blog consists not only of posts created in it, but also older posts written elsewhere. The vast majority of them comes from older blog engine I used here (Nanoblogger), but almost same amount are posts written in Czech originally posted on abclinuxu.cz.

It turned out that when I was doing import of those, I somehow forgot (or rather did not care) to fix links between them and links to rest of abclinuxu.cz website. With few lines script and huge help of BeautifulSoup these should be now fixed. So you can properly navigate over almost seven years of my blogging history.

While looking at other failing URLs here, I've also added number of redirects, so that most people end up on pages where they expect :-).

Tiny blog improvements

Finally, I've found some time to do some improvements on this blog engine.

First thing which was more and more missing is reasonable content for description in HTML headers. This lead to sites like Google+ always fetch the constant text and that did not look that. So now, there is something really relevant to the content, either first paragraph (what is the case for all old entries) or something I can manually edit (in case I won't be too lazy).

For automatic extraction I tried several approaches. First attempt was simply extracting first paragraph from Markdown, however I quickly remembered that quite a lot of older posts were written directly in HTML, which made this big failure. Later trying BeautifulSoup on rendered HTML, what lead to missing spaces around text which was originally in links. Finally I discovered html2text, which worked pretty easily and does what I need.

In the end the code looks like following:

def get_auto_summary(self):
    h2t = html2text.HTML2Text()
    h2t.body_width = 0
    h2t.ignore_images = True
    h2t.ignore_links = True
    h2t.ignore_emphasis = True
    text = h2t.handle(self.body.rendered)
    return text.splitlines()[0]

Other change affects Flattr, as providing Flattr links for each posts is now possible even without javascript (it's called Auto-submit URL), I've decided to implement them this way. Let's see how many things will get on Flattr this way (at least it will give me better indication what somebody considered being useful). Thanks for commenters on my older blog post for hints.

Adding API to Django application

One of Django applications I maintain is our internal tool used at SUSE used for managing incoming L3 requests. Recently request to add some API arose (read only for now). Looking at available solutions, I came to conclusion that django-piston should be the best choice for me.

Adding simple model based API with it is indeed quite simple, all basic information you need is written in getting started part of their documentation.

On the other side, things can never go without problems, so I was hit by well known bug. Fortunately fix exists, though it is not yet merged upstream. While digging so deep into problem anyway, I've submitted a request to include this patch in devel:languages:python OBS repo.

Changed website

After last fixes during yesterday evening, I've decided to put new website online today. It matches layout of my blog, uses same technology underneath (Django).

The biggest change is probably simplification of the structure and also cleanup of old unused stuff. I tried not to miss anything, but I'm sure something will be discovered in next days.

With this change, I've also shutdown my SVN server as all things has been migrated either elsewhere (usually Debian's collab-maint SVN repository) or are now using Git either on Gitorious or repo.or.cz.

Cleaning up the web

After recent switch of this blog to Django, I've also planned to switch rest of my website to use same engine. Most of the code is already written, however I've found some forgotten parts, which nobody used for really a long time.

As most of the things there is free software, I don't like idea removing it completely, however it is quite unlikely that somebody will want to use these ancient things. Especially when it quite lacks documentation and I really forgot about that (most of them being Turbo Pascal things for DOS, Delphi components for Windows and so on). Anyway it will probably live only on dl.cihar.com in case anybody is interested.

Comments on blog

One of reasons of recent move my blog to custom Django based application was use of comments. Today I've finally found time to enable support for them, so you can provide me feedback directly without mailing me or reposting on some planet where my blog is syndicated.

I hope it will not turn into fight with spam bots, for now I'm using only protection Django has built-in.