PHP Gettext: how to change the default MO path after setting the path of the domain?

霸气de小男生 提交于 2019-12-10 14:26:00

问题


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

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

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

回答1:


The directory structure is fixed by gettext.

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



来源:https://stackoverflow.com/questions/9515863/php-gettext-how-to-change-the-default-mo-path-after-setting-the-path-of-the-dom

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!