views:

590

answers:

3

i want a PHP script which can convert .po(Portable Object) as .mo(Machine Object) file? is any script available in PHP?

             byte
              +------------------------------------------+
           0  | magic number = 0x950412de                |
              |                                          |
           4  | file format revision = 0                 |
              |                                          |
           8  | number of strings                        |  == N
              |                                          |
          12  | offset of table with original strings    |  == O
              |                                          |
          16  | offset of table with translation strings |  == T
              |                                          |
          20  | size of hashing table                    |  == S
              |                                          |
          24  | offset of hashing table                  |  == H
              |                                          |
              .                                          .
              .    (possibly more entries later)         .
              .                                          .
              |                                          |
           O  | length & offset 0th string  ----------------.
       O + 8  | length & offset 1st string  ------------------.
               ...                                    ...   | |
 O + ((N-1)*8)| length & offset (N-1)th string           |  | |
              |                                          |  | |
           T  | length & offset 0th translation  ---------------.
       T + 8  | length & offset 1st translation  -----------------.
               ...                                    ...   | | | |
 T + ((N-1)*8)| length & offset (N-1)th translation      |  | | | |
              |                                          |  | | | |
           H  | start hash table                         |  | | | |
               ...                                    ...   | | | |
   H + S * 4  | end hash table                           |  | | | |
              |                                          |  | | | |
              | NUL terminated 0th string  <----------------' | | |
              |                                          |    | | |
              | NUL terminated 1st string  <------------------' | |
              |                                          |      | |
               ...                                    ...       | |
              |                                          |      | |
              | NUL terminated 0th translation  <---------------' |
              |                                          |        |
              | NUL terminated 1st translation  <-----------------'
              |                                          |
               ...                                    ...
              |                                          |
              +------------------------------------------+

can i make a mo file from these information?

+3  A: 

You could run msgfmt using exec() or similar. I don't know if there is a PHP-only way to do it.

Tom Haigh
I think that this should be the best approach if you want to be sure you do the right thing. Other solutions may bring you new bugs that could drop your productivity.
Sorin Sbarnea
+2  A: 

I have not tried it, but it looks like this PEAR package might help you. It is unmaintained, but maybe you can be the new maintainer?

If you can read Python, then you can take a stab at converting their msgfmt.py script to PHP. It's only 200 lines or so.

Martin Geisler
great man, its realy helpful...thank you let me check.
coderex
A: 

i need this one too.. thanks..

N-designs