Drupal core has a powerful gettext Portable Object (Template) creation and parsing framework, but it is unfortunately not possible to use from the outside, because it is so much tied to the internal import/export code. Now with my Google Summer of Code project, I am involved with producing solutions for a web based translation service with PO imports and exports, and it is just logical to reuse what we already have. The attached patch does the following:
1. Fix translation exports with multiple plural forms. The Czech translation exported with a bad PO file for example, because @count[2] type of indexes are exposed in the output, which should only be used internally by Drupal. This is a little bug fix, and will be backported to Drupal 5, once we have this in.
2. Refactor the monolithic PO export function into three steps: (a) generate the array of strings to export (b) generate the PO file (c) output the PO file via HTTP. I took most of Bruno Massa's good ideas for this part of the patch from here: http://drupal.org/node/147915 (his patch does include a lot of other stuff). Although I did offer more features here, allowing the PO file header to be customized and I also modified the default PO header to be less strong with attributing all the strings to the single user who exports the translations (the user is not mentioned as last translator, translation team and he does not marked to be the copyright holder of the strings).
This refactoring allows contributed modules to generate PO files out of arbitrary string sets, not only what comes out directly from the default database tables, and it also allows contributed modules to take that PO file and send it by email, save it to the file system, or do whatever they wish. So the process of database string collection, PO assembly and HTTP download is decoupled to be versatile.
I hope we can get this in soon, so it is possible to move on to refactoring the import (PO parser) process, which is even more interesting :)
| Comment | File | Size | Author |
|---|---|---|---|
| locale_refactor_export_01.patch | 12.15 KB | gábor hojtsy |
Comments
Comment #1
meba commentedthis seems to fix the bug with exporting plural forms
Comment #2
gábor hojtsyIt is great that you did have time to test it. Committed.
Comment #3
(not verified) commented