.po转换为.mo在PHP中的转换器? [英] .po to .mo convertor in php?

查看:92
本文介绍了.po转换为.mo在PHP中的转换器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想要一个可以将 .po (便携式对象)转换为 .mo (机器对象)文件的PHP脚本吗? PHP中有可用的脚本吗?

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  <-----------------'
              |                                          |
               ...                                    ...
              |                                          |
              +------------------------------------------+

我可以根据这些信息制作一个mo文件吗?

can i make a mo file from these information?

推荐答案

我没有尝试过,但是看起来像这样

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?

如果您可以阅读Python,那么可以尝试转换msgfmt.py 脚本到PHP.只有200行左右.

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.

这篇关于.po转换为.mo在PHP中的转换器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆