本文整理汇总了PHP中PhabricatorEnv::getLocaleCode方法的典型用法代码示例。如果您正苦于以下问题:PHP PhabricatorEnv::getLocaleCode方法的具体用法?PHP PhabricatorEnv::getLocaleCode怎么用?PHP PhabricatorEnv::getLocaleCode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PhabricatorEnv
的用法示例。
在下文中一共展示了PhabricatorEnv::getLocaleCode方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testLocaleScopeGuard
public function testLocaleScopeGuard()
{
$original = PhabricatorEnv::getLocaleCode();
// Set a guard; it should change the locale, then revert it when destroyed.
$guard = PhabricatorEnv::beginScopedLocale('en_GB');
$this->assertEqual('en_GB', PhabricatorEnv::getLocaleCode());
unset($guard);
$this->assertEqual($original, PhabricatorEnv::getLocaleCode());
// Nest guards, then destroy them out of order.
$guard1 = PhabricatorEnv::beginScopedLocale('en_GB');
$this->assertEqual('en_GB', PhabricatorEnv::getLocaleCode());
$guard2 = PhabricatorEnv::beginScopedLocale('en_A*');
$this->assertEqual('en_A*', PhabricatorEnv::getLocaleCode());
unset($guard1);
$this->assertEqual('en_A*', PhabricatorEnv::getLocaleCode());
unset($guard2);
$this->assertEqual($original, PhabricatorEnv::getLocaleCode());
// If you push `null`, that should mean "the default locale", not
// "the current locale".
$guard3 = PhabricatorEnv::beginScopedLocale('en_GB');
$this->assertEqual('en_GB', PhabricatorEnv::getLocaleCode());
$guard4 = PhabricatorEnv::beginScopedLocale(null);
$this->assertEqual($original, PhabricatorEnv::getLocaleCode());
unset($guard4);
$this->assertEqual('en_GB', PhabricatorEnv::getLocaleCode());
unset($guard3);
$this->assertEqual($original, PhabricatorEnv::getLocaleCode());
}
示例2: __construct
public function __construct($code)
{
// If this is the first time we're building a guard, push the default
// locale onto the bottom of the stack. We'll never remove it.
if (empty(self::$stack)) {
self::$stack[] = PhabricatorEnv::getLocaleCode();
}
// If there's no locale, use the server default locale.
if (!$code) {
$code = self::$stack[0];
}
// Push this new locale onto the stack and set it as the active locale.
// We keep track of which key this guard owns, in case guards are destroyed
// out-of-order.
self::$stack[] = $code;
$this->key = last_key(self::$stack);
PhabricatorEnv::setLocaleCode($code);
}