agl/more-locale

该软件包已被废弃且不再维护。未建议替代软件包。

AGL框架 / I18n模块。

dev-master 2014-04-21 15:22 UTC

This package is not auto-updated.

Last update: 2020-12-19 09:34:38 UTC


README

AGL框架提供额外的I18n模块。

安装

在您的AGL应用程序根目录下运行以下命令

php composer.phar require agl/more-locale:*

配置

配置文件

编辑app/etc/config/more/locale/main.php以配置模块。

Gettext文件

为要使用的每种语言创建Gettext文件,例如

app/etc/locale/en_GB.utf8/LC_MESSAGES/default.mo app/etc/locale/en_GB.utf8/LC_MESSAGES/default.po

app/etc/locale/fr_FR.utf8/LC_MESSAGES/default.mo app/etc/locale/fr_FR.utf8/LC_MESSAGES/default.po

用法

选择语言

如果您不按语言使用域名,请从您想使用的语言代码开始您的URL。例如: http://domain.tld/en/http://domain.tld/fr/

显示i18n字符串(GetText语法)

echo _("String");

获取当前语言

Agl::getSingleton('more/locale')->getLanguage();

获取接受的语言

Agl::getSingleton('more/locale')->getAcceptedLanguages();

创建具有特定语言的URL

而不是调用Agl::getUrl(),它使用当前语言,请使用带有$pLang参数的以下方法。

Agl::getSingleton('more/locale')->getUrl($pPath, $pParams, $pRelative, $pLang);

例如

Agl::getSingleton('more/locale')->getUrl('game/upload', array(), true, 'fr');