PHP Gettext:设置域路径后如何更改默认的MO路径? [英] PHP Gettext: how to change the default MO path after setting the path of the domain?

查看:140
本文介绍了PHP Gettext:设置域路径后如何更改默认的MO路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用PHP Gettext扩展名对Web应用程序进行本地化.当您这样做时:

I use PHP Gettext extension for localizing a Web app. When you do:

bindtextdomain("example", "/locales");

如果将语言环境设置为fr_FR,它将在以下位置查找MO:

If you're setting the locale to fr_FR, it will look for the MO in:

/locales/fr_FR/LC_MESSAGES/example.mo

是否可以自定义该路径?例如,我想使用以下结构:

Is there a way to customize that path? For instance I would like to use the following structure:

/locales/example.fr_FR.mo

推荐答案

目录结构由gettext固定.

The directory structure is fixed by gettext.

因为必须存储许多不同软件包的许多不同语言,所以我们需要某种方式将这些信息添加到文件消息目录文件中.在Unix环境中通常使用的方法是在文件名中使用这种编码.这也可以在这里完成.在bindtextdomains第二个参数(或默认目录)中给定的目录名称,然后是语言环境的名称,语言环境类别和域名的连接:

Because many different languages for many different packages have to be stored we need some way to add these information to file message catalog files. The way usually used in Unix environments is have this encoding in the file name. This is also done here. The directory name given in bindtextdomains second argument (or the default directory), followed by the name of the locale, the locale category, and the domain name are concatenated:

dir_name/locale/LC_category/domain_name.mo

dir_name/locale/LC_category/domain_name.mo

这篇关于PHP Gettext:设置域路径后如何更改默认的MO路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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