本文整理匯總了PHP中i18n::load方法的典型用法代碼示例。如果您正苦於以下問題:PHP i18n::load方法的具體用法?PHP i18n::load怎麽用?PHP i18n::load使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類i18n
的用法示例。
在下文中一共展示了i18n::load方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: get
/**
* Returns translation of a string. If no translation exists, the original
* string will be returned.
*
* @param string text to translate
* @return string
*/
public static function get($string)
{
// Load the translation table
$table = i18n::load(i18n::$lang);
// Return the translated string if it exists
return isset($table[$string]) ? $table[$string] : $string;
}
示例2: action_main
/**
* Parses the $_FILES superglobal for uploaded files. An event is triggered for each file. Handlers
* can then decide whether to keep the uploaded file. The action result is filled with the properties
* of the $_FILES superglobal storing the corresponding result - whether the respective file was
* removed or has been accepted.
*/
protected function action_main($skipPermsCheck = false)
{
if (!$skipPermsCheck and !Permissions::has('sys_upload')) {
return $this->redirectForbidden();
}
$lang = i18n::load('diamondmvc');
$result = array();
$success = true;
if (!empty($_FILES)) {
foreach ($_FILES as $prop => $file) {
// Skip this file if not desired.
if (!empty($this->filters) and !in_array($prop, $this->filters)) {
continue;
}
// Attempt to save the file.
if (!$this->handleUpload($prop, $file)) {
$this->addMessage(str_replace('%name%', $file['name'], $lang->get('ERROR_TITLE', 'ControllerUpload')), $lang->get('ERROR_MESSAGE', 'ControllerUpload'), 'error');
$result[$prop] = false;
$success = false;
} else {
$result[$prop] = true;
}
}
}
$this->result = array('success' => $success, 'details' => $result);
}
示例3: generateDocsMenu
protected function generateDocsMenu($ctrl)
{
$lang = i18n::load('diamondmvc');
$result = new ModuleNavbar($ctrl);
$result->addLinkLeft($lang->get('HOME'), DIAMONDMVC_URL . '/docs')->addMenuLeft($lang->get('GUIDES'))->addLink($lang->get('GETTING_STARTED'), DIAMONDMVC_URL . '/docs/getting-started')->addLink($lang->get('CONTROLLERS'), DIAMONDMVC_URL . '/docs/controllers')->addLink($lang->get('VIEWS'), DIAMONDMVC_URL . '/docs/views')->addLink($lang->get('MODELS'), DIAMONDMVC_URL . '/docs/models')->addLink($lang->get('INTERNATIONALIZATION'), DIAMONDMVC_URL . '/docs/i18n')->addLink($lang->get('PERMISSIONS'), DIAMONDMVC_URL . '/docs/permissions')->addLink($lang->get('EXTENSIONS'), DIAMONDMVC_URL . '/docs/extensions')->back();
return $result;
}
示例4: action_main
protected function action_main()
{
$this->title = 'Error!';
$lang = i18n::load('diamondmvc');
$errors = array();
if (isset($_SESSION['errors'])) {
$errors = $_SESSION['errors'];
unset($_SESSION['errors']);
} else {
if (isset($_SESSION['error'])) {
$errors[] = $_SESSION['error'];
unset($_SESSION['error']);
} else {
if (isset($_REQUEST['msg'])) {
$error = array();
$error['title'] = isset($_REQUEST['title']) ? htmlspecialchars(urldecode($_REQUEST['title'])) : $lang->get('GENERIC_ERROR');
$error['msg'] = htmlspecialchars(urldecode($_REQUEST['msg']));
// Prevent XSS attacks on our beloved clients
$error['level'] = isset($_REQUEST['level']) ? $_REQUEST['level'] : 'warn';
// The addMessage method automatically sanitizes this
$errors[] = $error;
}
}
}
foreach ($errors as $error) {
$this->addMessage($error['title'], $error['msg'], $error['level']);
}
}
示例5: defined
* - files: List of files to be shown in the filebrowser.
*
* Each item in the files array ought to provide the following data:
* - is_dir: Whether the item represents a directory or a regular file
* - name: Name of the item
* - id: Unique ID. This is passed to the AJAX callback upon clicking the item.
* - size: Size in bytes
* - perms: File permissions
*/
defined('DIAMONDMVC') or die;
if (isset($this->controller)) {
$data = $this->controller->getResult();
} else {
$data = $this->getData();
}
$lang = i18n::load('diamondmvc');
$this->addStylesheet('filebrowser.css');
$this->addStylesheet('/assets/dropzone/dropzone.min.css');
$this->addScript('./filebrowser');
$this->addScript('dropzone');
?>
<div class="view view-filebrowser">
<?php
if (isset($data['controls']) and !empty($data['controls'])) {
?>
<div class="filebrowser-controls pull-right">
<?php
if (isset($data['controls']['custom']) and !empty($data['controls']['custom'])) {
?>
<?php
echo $data['controls']['custom'];
示例6:
<?php
/**
* @package DiamondMVC
* @author Zyr <zyrius@live.com>
* @version 1.0
* @license CC-SA 4.0 (https://creativecommons.org/licenses/by-sa/4.0/)
*
* Extension installation mask. Provides a modal to choose an extension ZIP archive for upload.
*/
$lang = i18n::load('diamondmvc-backend');
// $this->addStylesheet('install.css');
$this->addScript('dropzone');
$this->addScript('./install');
$data = $this->controller->getResult();
$snippet = $data['filebrowser'];
foreach ($snippet->getStylesheets() as $sheet) {
$this->addStylesheet($sheet);
}
foreach ($snippet->getScripts() as $script) {
$this->addScript($script);
}
?>
<div class="view view-install" id="view-system">
<a href="<?php
echo DIAMONDMVC_URL;
?>
/system/installations" class="btn btn-primary pull-right"><?php
echo $lang->get('RETURN_TO_OVERVIEW', 'ControllerSystem.Install');
?>
</a>
示例7: read
/**
* Reads the HTML template of this view into memory. The template is searched
* based on the view's name.
* Template parameters ought to be set prior to the invokation of this method.
* @return View Diese Instanz zur Methodenverkettung.
*/
public function read()
{
ob_start();
$path = $this->getPath();
if (!empty($path)) {
include $path;
} else {
$lang = i18n::load('diamondmvc');
echo $lang->get('VIEW_NOT_FOUND');
}
$this->buffer = ob_get_contents();
ob_end_clean();
return $this;
}
示例8: redirectForbidden
protected function redirectForbidden()
{
$lang = i18n::load('diamondmvc-backend');
$_SESSION['error'] = array('title' => $lang->get('ERROR_RESTRICTED_ACCESS'), 'msg' => $lang->get('ERROR_INSUFFICIENT_PERMISSIONS'), 'level' => 'error');
redirect(DIAMONDMVC_URL . '/error');
}
示例9: bind
/**
* load localized strings for one module
*
* @param string module name
*/
public static function bind($module)
{
global $context;
// sanity check
if (!isset($context['language'])) {
return;
}
// initialization
if (!isset($context['l10n_modules'])) {
$context['l10n_modules'] = array();
}
// ensure all cached modules are accurate on development machine
if ($context['with_debug'] == 'Y') {
i18n::load('en', $module);
i18n::load('fr', $module);
}
// this module has already been loaded
if (isset($context['l10n_modules'][$module])) {
return;
}
// avoid further loading
$context['l10n_modules'][$module] = TRUE;
// load strings according to surfer localization
i18n::load($context['language'], $module);
// load strings according to community localization
if ($context['preferred_language'] != $context['language']) {
i18n::load($context['preferred_language'], $module);
}
}