Poedit xgettext parser setup reminder

i18n 7 Comments »

This is more or less a reminder to myself. Since there do not seem to be many sources about this exact issue and I had to search for it a couple of times already I thought it might be nice to have it up on my own blog.

Working on many international project I’ve been using Poedit for a while now. Poedit is an editor for gettext catalogs (.po files). To gether with PHP and the gettext extension it’s a great tool to implement multilingual web applications.

The issue is that you can set up a parsers in Poedit, basically definitions of file types and command line parameters for xgettext, which is executed fo find the parts in a file that should be translated. So there is a parser for PHP in there, but often, for example in the CakePHP framework, you have to deal with files that are PHP files, but that have a different extension, in the CakePHP case views end with .thtml … Just adding “*.thtml” to the list of extensions in the PHP parser setup does not cut the mustard and you end up getting an error message like this:

xgettext: warning: file ‘[…].thtml’ extension ‘thtml’ is unknown; will try C.

To solve this, you need to tell xgettext that it has to deal with PHP files by adding “–language=PHP” to the list of commandline options. This is done by opening Poedit’s preferences and navigating to the parsers section there. In the PHP parser under “Parser command” (btw. this is the MAC version of Poedit) I have now the following line:

xgettext --language=PHP --force-po -o %o %C %K %F

Voila, .thtml files or any file specified in the PHP parser is now treated as PHP and my translation sections are found.

Thanks to Vaclav for his answer here.

Linux on a Samsung R20 (with 3D and Atheros-WiFi)

Linux 6 Comments »

I have been playing around with various LiveCDs to figure out which Linux distribution would best work on my Samsung R20. The laptop is relatively cheap, but I had expected it to be better supported by the major distros at least. Using the currently available LiveCDs I could basically choose between openSUSE 10.3 and Mandriva 2008, because it were the only ones that actually were able to startx out of the box. The R20 has an integrated ATI Radeon Xpress 1250 graphics chip that seems to cause problems with many Linux distributions and I was especially disappointed by my previous Linux of choice: Ubuntu - it booted fine (7.10, also no luck with Kubuntu 7.10), but no X.

openSUSE works nicely out of the box, except for: correct screen size (forced me to 1024×768 in the beginning), 3D support (didn’t work out of the box, and I never touched it henceforth) and WiFi (major point and I had no luck of getting it up and running). So openSUSE was a good option for an install because with a little tweaking here an there it would probably work well.

Looking at the Mandriva homepage they claim to support 3D desktops, namely Metisse and Compiz Fusion. Looking at several YouTube videos I know I wanted to see this in reality. The Mandriva 2008 LiveCD behaves almost identical to the openSUSE one, maybe it boots a bit faster. Screen resolution also had to be changed, but Mandriva supported the ATI x1250 out of the box, so I was looking forward to decent WiFi suport as well…no such luck! I played around with Compiz Fusion too and it works like a charm and really looks stunning! Sound and peripherals seem to work too, even the SD card reader. So I went on installing Mandriva 2008 on my Samsung R20, keeping the Vista Partition.

Finally the last thing to get up and running was WiFi. And here it gets dirty. I think I googled about 10 hours during the last 2 days, without finding the solution. Many people seem to be happy using the MadWiFi drivers, some people seem to get it to work using NDISwrapper (you need the windows driver for the WiFi card). I started playing with both approaches, but since compiling new kernels and patching kernel modules are not really everyday tasks for me I kept on googling…and voila! I got it to work with changing only one boot option in GRUB (the boot manager).

The problem seems to be generally related to a broken MMCONFIG implementation on many systems. ACPI also seems to have related issues there, but luckily the solution is as easy as editing a single line in a file.

You basically just need to add “pci=nommconf” as one of the boot options to your GRUB menu file: /boot/grub/menu.lst

Here’s how my GRUB menu file looks now (line breaks inserted):
title linux
kernel (hd0,4)/boot/vmlinuz
BOOT_IMAGE=linux
root=/dev/sda5
resume=/dev/sda6
splash=silent
vga=788
pci=nommconf
initrd (hd0,4)/boot/initrd.img

After rebooting I could select the WiFi card in Mandriva Linux Control Center. Apparently it’s an “Atheros Communications, Inc. AR5006EG 802.11 b/g Wireless PCI Express Adapter (rev 01)” - I thought it would be an AR5006X, but as long as it works I couldn’t care less.

I hope this helps somebody. For me as a non-Linux-geek, the problem would still have been easy to solve with my first search many hours ago if people that know what they’re talking about would take into consideration that this might not be the case for everybody else: the search basically led me here (I was googling for “Samsung R20 Linux”) and the 2nd comment by Albert just says: “Load kernel with option pci=nommconf” - that’s like telling a Linux geek to just “change the float gauge in the carb of a car” or something.

Anyways it works and I think I can recommend the Samsung R20 as a Linux machine.

SSH vs. Putty private key files (.ppk) on MAC OS X

Servers 4 Comments »

I had some problems lately trying to connect to a customer’s server via SSH on my mac running Mac OS X 10.4.11. I was trying to use the provided .ppk file in mac’s OpenSSH command line tool, which didn’t work and just told me: “Permission denied (publickey).” after promting me to “Enter passphrase for key ‘[keyfile.ppk]’”… so I looked around a bit and after a while came across a great little article on the topic right here.

So in order to use the private key file for putty.exe (the .ppk file) you need to convert it to a OpenSSH file first. The tool you need is called PuTTYgen and only runs in Windows. I have not come across a mac app to do that (too bad). Anyways, the only thing you have to do after launching puttygen.exe is to open the .ppk file, enter your passphrase and go to “Conversions” in the menu. Then save the file as an OpenSSH file.

Finally, after you put the .ssh file on your mac, you need to restrict the .ssh file’s permissions (”Get Info”, then under “Ownership & Permissions”->”Details” set “No Access” for both “Group” and “Others”). Otherwise OpenSSH won’t let you use the file. Now you can connect to the server using this command line:

comp:~ your$: ssh -2 -i /path/sshfilename.ssh user@server.domain

Option “-2″ is not required, at least for me and in this case. It forces ssh to protocol version 2, but it works without. This depends on the protocol the server requires and you need to try this. Also check out the ssh manual (type “man ssh”).

New Gig

General No Comments »

I’m doing some freelancing for Studio9 at the moment. Nice people there, lots of interesting work too, mostly Typo3, but also jQuery, HTML/CSS. So I am going to Munich a couple days a week…boy am I glad I got a new car last year.

Safari-Bug or Not? DOM Exception 7

JavaScript 4 Comments »

Here’s what happened: I was working on the Frost Ajax Library and using Safari Version 3.0.4 (523.12) for testing things.

The document, index.php, was serverd to the browser using this content-type header: “application/xhtml+xml” and the DOCTYPE was “-//WAPFORUM//DTD XHTML Mobile 1.0//EN”.

Now in Frost here’s a simple function that can put some text or HTML to a container, basically using simple innerHTML like this:

//id and cont are passed to the function
var ob = document.getElementById(id);
ob.innerHTML = cont;

The strange behavior appeared when cont was empty. In this case Safari throws an exception: NO_MODIFICATION_ALLOWED_ERR: DOM Exception 7.
There is no exception thrown if cont is not empty though.

If you serve the document with content-type headers as “text/html” there is no exception and everything works as it should.

The consclusion so far is that Safari has a bug and rejects to see an empty string as a valid value for a container, apparently only when the document is pure XML.

A quick search produces some similar issues floating around the web since a couple of years.

As a workaround my current solution is to encapsulate cont with proper tags like this:

//id and cont are passed to the function
var ob = document.getElementById(id);
cont = "<_span_>"+cont+"<_/span_>";
ob.innerHTML = cont;
(<_span_> should be <span> really - needed for showing this code)

Could make sense in one way, because documents served as real XML should be handled more restrictive and modifications should produce valid XML documents again. However if I just want to put some text in a tag and if this text happens to be empty this should work too. So why is Safari making a difference if the value filled into a tag with innerHTML is empty or not - is this a bug?

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS