如何在php中使用gettext? [英] how to use gettext in php?

查看:76
本文介绍了如何在php中使用gettext?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Webdir文件夹lang中有一个文件dk.podk.mo.

I have a file dk.po and dk.mo in folder lang in my webdir.

如何使用此文件?我已经尝试了所有,但无法正常工作.

How can I use this file? I have tried all, but I can not get it to work.

// Lang
putenv('LC_ALL=dk');
setlocale(LC_ALL, 'dk');

// Specify location of translation tables
bindtextdomain("dk", ROOT .'lang');

// Choose domain
textdomain("dk");

推荐答案

我已经在使用它:

setlocale(LC_ALL, 'ar_LY.utf8');
bindtextdomain("trans", $_SERVER["DOCUMENT_ROOT"].'/trans/locale');
textdomain("trans"); 

语言文件路径:

/var/www/trans/locale/ar_LY/LC_MESSAGES/trans.mo

我认为(不确定)您必须使用相同的路径!

and I think (not sure) that you have to use the same paths!

这篇关于如何在php中使用gettext?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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