如何在不完全依赖setlocale/locales的情况下解析PHP4中的gettext .mo文件? [英] How could I parse gettext .mo files in PHP4 without relying on setlocale/locales at all?

查看:62
本文介绍了如何在不完全依赖setlocale/locales的情况下解析PHP4中的gettext .mo文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了几个相关的话题,但这是我正在寻找答案的一个直接问题.如果PHP版本是5,我的框架将使用Zend_Translate,否则我必须模仿4的功能.

I made a couple related threads but this is the one direct question that I'm seeking the answer for. My framework will use Zend_Translate if the php version is 5, otherwise I have to mimic the functionality for 4.

似乎几乎每个gettext的实现都依赖于setlocale或语言环境,我知道整个系统之间存在很多不一致之处,这就是为什么我不想依赖它的原因.

It seems that pretty much every implementation of gettext relies on setlocale or locales, I know there's a LOT of inconsistency across systems which is why I don't want to rely upon it.

我已经尝试过几次才能使textdomainbindtextdomaingettext函数正常工作,但是我一直需要调用setlocale.

I've tried a couple times to get the textdomain, bindtextdomain and gettext functions to work but I've always needed to invoke setlocale.

顺便说一下,所有.mo文件都将是UTF-8.

By the way, all the .mo files will be UTF-8.

推荐答案

好吧,据我所知,基本上我最终基于Zend的Gettext Adapter编写了一个mo文件解析器,据我所知gettext很大程度上依赖于语言环境,因此手动解析.mo文件将避免在setlocale区域设置问题的情况下遇到麻烦的麻烦.我还计划解析以xml文件形式提供的Zend Locale数据.

Ok, I basically ended up writing a mo file parser based on Zend's Gettext Adapter, as far as I know gettext is pretty much reliant upon the locale, so manually parsing the .mo file would save the hassle of running into odd circumstances with locale issues with setlocale. I also plan on parsing the Zend Locale data provided in the form of xml files.

这篇关于如何在不完全依赖setlocale/locales的情况下解析PHP4中的gettext .mo文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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