本文整理汇总了PHP中OC_L10N::forceLanguage方法的典型用法代码示例。如果您正苦于以下问题:PHP OC_L10N::forceLanguage方法的具体用法?PHP OC_L10N::forceLanguage怎么用?PHP OC_L10N::forceLanguage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OC_L10N
的用法示例。
在下文中一共展示了OC_L10N::forceLanguage方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testFirstWeekDay
/**
* @dataProvider firstDayDataProvider
* @param $expected
* @param $lang
*/
public function testFirstWeekDay($expected, $lang)
{
$l = new OC_L10N('test');
$l->forceLanguage($lang);
$this->assertSame($expected, $l->l('firstday', 'firstday'));
}
示例2: getDisclaimerForm
/**
* Renders the template for the login page
*
* @return TemplateResponse The response for the login template
*/
public function getDisclaimerForm()
{
$container = $this->getContainer();
$session = $container->query('OCP\\IUserSession');
$templateResponse = null;
if (!$session->isLoggedIn()) {
$userLang = $this->l10n->getLanguageCode();
//Fix it: No way of getting rid of this static call. There is no
//class method on OwnCloud that does this
if (!\OC_L10N::languageExists($this->appName, $userLang)) {
//It can be that some language dialects hasn't being translated,
//so, a suitable language will be searched. ie: if 'de_CH' isn't
//available, then 'de_DE' (formal german) will be used. In case
//that 'de_DE' isn't available, then 'de' (informal german will
//be used). If no fallback language is found, then the defined
//default language will be used. In case nothing is found, then
//ownCloud will decide which language to use, which in most
//cases is 'en'.
$langFallbacks = $this->utils->getFallbackLang($userLang);
$defaultLang = $this->config->getDefaultLang();
if ($defaultLang !== $userLang) {
$langFallbacks[] = $defaultLang;
}
foreach ($langFallbacks as $langCode) {
//Fix it: again, no way of getting rid of this static calls;
//the ownCloud library doesn't have any other way
if (\OC_L10N::languageExists($this->appName, $langCode)) {
$userLang = $langCode;
\OC_L10N::forceLanguage($userLang);
break;
}
}
}
$data = ['appName' => $this->appName];
$templateResponse = new TemplateResponse($this->appName, 'login', $data, 'blank');
}
return $templateResponse;
}
示例3: OC_OCS_Result
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU AFFERO GENERAL PUBLIC LICENSE for more details.
*
* You should have received a copy of the GNU Affero General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*
*/
require_once '../lib/base.php';
if (\OCP\Util::needUpgrade() || \OCP\Config::getSystemValue('maintenance', false) || \OCP\Config::getSystemValue('singleuser', false)) {
// since the behavior of apps or remotes are unpredictable during
// an upgrade, return a 503 directly
OC_Response::setStatus(OC_Response::STATUS_SERVICE_UNAVAILABLE);
$response = new OC_OCS_Result(null, OC_Response::STATUS_SERVICE_UNAVAILABLE, 'Service unavailable');
OC_API::respond($response, OC_API::requestedFormat());
exit;
}
use Symfony\Component\Routing\Exception\ResourceNotFoundException;
use Symfony\Component\Routing\Exception\MethodNotAllowedException;
try {
// load all apps to get all api routes properly setup
OC_App::loadApps();
// api calls always will return English
\OC_L10N::forceLanguage('en');
OC::$server->getRouter()->match('/ocs' . OC_Request::getRawPathInfo());
} catch (ResourceNotFoundException $e) {
OC_API::setContentType();
OC_OCS::notFound();
} catch (MethodNotAllowedException $e) {
OC_API::setContentType();
OC_Response::setStatus(405);
}
示例4: foreach
#It can be that some language dialects hasn't being translated, so, a
#suitable language will be searched. ie: if 'de_CH' isn't available, then
#'de_DE' (formal german) will be used. In case that 'de_DE' isn't available,
#then 'de' (informal german will be used). If no fallback language is found,
#then the defined default language will be used. In case nothing is found,
#then ownCloud will decide which language to use, which in most cases is
#'en'.
$langFallbacks = \OCA\AgreeDisclaimer\Utils::getFallbackLang($userLang);
$defaultLangProp = $appId . 'DefaultLang';
$defLang = \OCA\AgreeDisclaimer\Controller\SettingsController::getSetting($defaultLangProp, 'en');
if ($defLang !== $userLang) {
$langFallbacks[] = $defLang;
}
foreach ($langFallbacks as $langCode) {
if (\OC_L10N::languageExists($appId, $langCode)) {
\OC_L10N::forceLanguage($langCode);
\OCP\Util::writeLog($appId, "The language: {$userLang} hasn't been " . "yet translated, falling back to: {$langCode}", \OCP\Util::WARN);
break;
}
}
}
/**
* Adds the javascript utilities to the login page
*/
script($appId, 'utils');
/**
* Adds the javascript to the login page
*/
script($appId, 'login');
/**
* Adds the style sheets file to the login page