本文整理汇总了PHP中LanguageManager类的典型用法代码示例。如果您正苦于以下问题:PHP LanguageManager类的具体用法?PHP LanguageManager怎么用?PHP LanguageManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LanguageManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: languages
/**
* Affiche une liste de tous les languages de la base de donnée.
* Selectionne par défaut une langue utilisée si elle est passée en paramètre
* @param LanguageManager $lang_manager
* @param int $spoken_language_id
*
*/
public static function languages(LanguageManager $lang_manager, $spoken_language_id = null)
{
$languages = $lang_manager->getLanguages();
echo '<option value="">' . _('Choose a Language') . '</option>';
foreach ($languages as $language) {
if ($language->id() == $spoken_language_id) {
$selected = 'selected';
} else {
$selected = '';
}
echo '<option value="' . $language->id() . '" ' . $selected . '>' . $language->name() . '</option>';
}
}
示例2: load
public function load()
{
if (isset($_GET['path'])) {
if (array_key_exists($_GET['path'], Config::getPageList())) {
$this->pageId = $_GET['path'];
} else {
$this->pageId = 'not_found';
}
}
if (isset($_GET['lang'])) {
if (array_key_exists($_GET['lang'], Config::getLanguageList())) {
$this->language = $_GET['lang'];
}
} else {
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
$langs = explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']);
$nblang = count($langs);
for ($i = 0; $i < $nblang; $i++) {
if (array_key_exists($langs[$i], Config::getLanguageList())) {
$this->language = $langs[$i];
break;
}
}
}
}
LanguageManager::loadLocales($this->language);
$pageList = Config::getPageList();
require_once $_SERVER["DOCUMENT_ROOT"] . '/page/' . $pageList[$this->pageId]['path'] . '.php';
$this->page = new CurrentPage();
}
示例3: load
public function load()
{
$this->setDescriptionTagValue('Build you computer (PC) using this tool and order it. We\'ll configure your PC and proceed your order!');
$this->setKeywordsTagValue('Build PC, Build Computer, Build Desktop Computer');
$this->setTitleTagValue('PC Configurator, build your computer!');
$pccm = PcConfiguratorManager::getInstance($this->config, $this->args);
$this->addParam('pccm', $pccm);
if (isset($this->args[0])) {
$edited_pc_cart_item_id = $this->args[0];
//if (!isset($this->customerEmail))
$this->initVars();
if (!isset($this->customerEmail)) {
exit;
}
$pcToBeEdit = $this->getPcToBeEdited($edited_pc_cart_item_id);
if ($pcToBeEdit != null) {
$this->setPcConfiguratorRequestParamsCorrespondingToEditedPcComponents($pcToBeEdit);
$this->addParam("configurator_mode_edit_cart_row_id", $edited_pc_cart_item_id);
}
}
$right_side_panel_width = $this->getCmsVar('pc_configurator_right_side_panel_width');
$width = intval($this->getCmsVar('whole_page_width')) - $right_side_panel_width;
$this->addParam('left_side_panel_width', $width);
$this->addParam('pcc_components_count', count(PcConfiguratorManager::$PCC_COMPONENTS));
$lm = LanguageManager::getInstance($this->config, $this->args);
$componentDisplayNames = array();
foreach (PcConfiguratorManager::$PCC_COMPONENTS_DISPLAY_NAMES_IDS as $pid) {
$componentDisplayNames[] = $pid;
}
$this->addParam("component_display_names", $componentDisplayNames);
}
示例4: getInstance
/**
* Returns an singleton instance of this class
*
* @param object $config
* @param object $args
* @return
*/
public static function getInstance($config, $args)
{
if (self::$instance == null) {
self::$instance = new LanguageManager($config, $args);
}
return self::$instance;
}
示例5: getInstance
/**
* Returns an singleton instance of this class
* @return
*/
public static function getInstance()
{
if (self::$instance == null) {
self::$instance = new LanguageManager();
}
return self::$instance;
}
示例6: service
public function service()
{
$languageManager = LanguageManager::getInstance($this->config, $this->args);
$phrase_id = $this->secure($_REQUEST["phrase_id"]);
$phrase_text = $_REQUEST["phrase_text"];
$languageManager->updatePhrase($phrase_id, $phrase_text);
$jsonArr = array('status' => "ok");
echo json_encode($jsonArr);
return true;
}
示例7: run
public function run()
{
if (empty($this->upgrader->config['js_lang_version'])) {
$this->upgrader->config['js_lang_version'] = 1;
} else {
$this->upgrader->config['js_lang_version'] += 1;
}
//remove lanugage cache files
require_once 'include/SugarObjects/LanguageManager.php';
LanguageManager::clearLanguageCache();
}
示例8: generateHeader
function generateHeader()
{
$this->content .= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="' . LanguageManager::getLanguage() . '" >
<head>
<title>' . _("Perroquet — Listening comprehension tutor — ") . $this->title . '</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" media="screen" type="text/css" title="Design" href="/style/default.css" />
<link rel="icon" type="image/png" href="/ressources/style/favicon.png" />
</head>
<body>';
}
示例9: loadLocales
static function loadLocales($lang)
{
bindtextdomain("perroquet-website", dirname($_SERVER['SCRIPT_FILENAME']) . '/locales');
bind_textdomain_codeset("perroquet-website", 'UTF-8');
textdomain("perroquet-website");
$languageList = Config::getLanguageList();
if (!$languageList[$lang]['choosable']) {
$lang = $languageList[$lang]['ref'];
}
setlocale(LC_ALL, $languageList[$lang]['key']);
LanguageManager::$lang = $lang;
}
示例10: display
/**
* @see SugarView::display()
*/
public function display()
{
global $mod_strings;
global $app_list_strings;
global $app_strings;
$languages = LanguageManager::getEnabledAndDisabledLanguages();
$this->ss->assign('APP', $GLOBALS['app_strings']);
$this->ss->assign('MOD', $GLOBALS['mod_strings']);
$this->ss->assign('enabled_langs', json_encode($languages['enabled']));
$this->ss->assign('disabled_langs', json_encode($languages['disabled']));
$this->ss->assign('title', $this->getModuleTitle(false));
echo $this->ss->fetch('modules/Administration/templates/Languages.tpl');
}
示例11: execute
function execute()
{
$this->language = "None";
if (isset($_GET['language'])) {
if (array_key_exists($_GET['language'], Config::getLanguageList())) {
LanguageManager::loadLocales($_GET['language']);
$this->language = $_GET['language'];
} else {
$this->language = "Invalid";
}
}
$this->title = _('Select language');
}
示例12: putAllPhrasesInSmarty
public function putAllPhrasesInSmarty()
{
$lm = LanguageManager::getInstance($this->config, $this->args);
$this->addParam("all_phrases_dtos_mapped_by_id", json_encode($lm->getAllPhrasesDtosMappedById()));
$this->addParam("langManager", $lm);
$ul = $_COOKIE['ul'];
if (!($ul === 'en' || $ul === 'ru' || $ul === 'am')) {
$ul = 'en';
}
if (!isset($_COOKIE['ul'])) {
$this->setcookie('ul', $ul);
}
$this->addParam("ul", $ul);
}
示例13: send
public function send($from, $recipients, $subject, $template, $params = array(), $separate = false)
{
//--proccessing the message
$smarty = new FAZSmarty();
$lm = LanguageManager::getInstance(null, null);
$params["all_phrases"] = $lm->getAllPhrases();
$ul = $_COOKIE['ul'];
if (!($ul === 'en' || $ul === 'ru' || $ul === 'am')) {
$ul = 'en';
}
$params["ul"] = $ul;
$smarty->assign("ns", $params);
$message = $smarty->fetch($template);
// To send HTML mail, the Content-type header must be set
$headers = "";
//'MIME-Version: 1.0' . "\r\n";
$headers .= "Reply-To: {$from}\r\n";
$headers .= "Return-Path: {$from}\r\n";
$headers .= "X-Priority: normal\r\n";
$headers .= 'MIME-Version: 1.0' . "\r\n";
$headers .= 'Content-type: text/html; charset=utf-8' . "\r\n";
$headers .= "X-Priority: 3\r\n";
$headers .= "X-Mailer: PHP" . phpversion() . "\r\n";
//$headers .= 'Content-type: text/plain; charset=utf-8' . "\n";
// Additional headers
// $headers .= 'To: Mary <mary@example.com>, Kelly <kelly@example.com>' . "\r\n";
$headers .= "From: {$from}\r\n";
// $headers .= 'From: Birthday Reminder <birthday@example.com>' . "\r\n";
// $headers .= 'Cc: birthdayarchive@example.com' . "\r\n";
// $headers .= 'Bcc: birthdaycheck@example.com' . "\r\n";
// multiple recipients
if ($separate) {
foreach ($recipients as $recipient) {
if (!empty($recipient)) {
mail($recipient, $subject, $message, $headers);
}
}
} else {
$to = "";
foreach ($recipients as $recipient) {
if (!empty($recipient)) {
$to .= $recipient . ',';
}
}
$to = substr($to, 0, -1);
mail($to, $subject, $message, $headers);
}
}
示例14: initialize
public function initialize($sessionManager, $loadMapper, $args)
{
parent::initialize($sessionManager, $loadMapper, $args);
$lm = LanguageManager::getInstance();
$this->addParam("lm", $lm);
$userLevel = $this->getUserLevel();
$customer = $this->getCustomer();
$this->addParam('DOCUMENT_ROOT', DOCUMENT_ROOT);
$this->addParam('customer', $customer);
$this->addParam('userLevel', $userLevel);
$this->addParam('userId', $this->getUserId());
$this->addParam('userGroupsGuest', UserGroups::$GUEST);
$this->addParam('userGroupsAdmin', UserGroups::$ADMIN);
$this->addParam('userGroupsCarwash', UserGroups::$CARWASH);
$this->addParam("page_name", isset($_REQUEST['page']) ? $_REQUEST['page'] : "");
}
示例15: createVardef
/**
* this method is called within a vardefs.php file which extends from a SugarObject.
* It is meant to load the vardefs from the SugarObject.
*/
function createVardef($module, $object, $templates = array('default'), $object_name = false)
{
global $dictionary;
//reverse the sort order so priority goes highest to lowest;
$templates = array_reverse($templates);
foreach ($templates as $template) {
VardefManager::addTemplate($module, $object, $template, $object_name);
}
LanguageManager::createLanguageFile($module, $templates);
$vardef_paths = array('custom/modules/' . $module . '/Ext/Vardefs/vardefs.ext.php', 'custom/Extension/modules/' . $module . '/Ext/Vardefs/vardefs.php');
//search a predefined set of locations for the vardef files
foreach ($vardef_paths as $path) {
if (file_exists($path)) {
require $path;
}
}
}