本文整理汇总了PHP中LanguageManager类的典型用法代码示例。如果您正苦于以下问题:PHP LanguageManager类的具体用法?PHP LanguageManager怎么用?PHP LanguageManager使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了LanguageManager类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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>';
}
}
开发者ID:MarionCrp,项目名称:Projet,代码行数:20,代码来源:Form.php
示例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();
}
开发者ID:niavok,项目名称:perroquet-website,代码行数:30,代码来源:HtmlPageLoader.php
示例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);
}
开发者ID:pars5555,项目名称:pcstore,代码行数:31,代码来源:PcConfiguratorLoad.class.php
示例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;
}
开发者ID:pars5555,项目名称:pcstore,代码行数:14,代码来源:LanguageManager.class.php
示例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;
}
开发者ID:pars5555,项目名称:photobooth,代码行数:11,代码来源:LanguageManager.class.php
示例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;
}
开发者ID:pars5555,项目名称:pcstore,代码行数:10,代码来源:UpdateLanguagePhraseAction.class.php
示例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();
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:11,代码来源:3_RebuildJS.php
示例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>';
}
开发者ID:niavok,项目名称:perroquet-website,代码行数:12,代码来源:HtmlPage.php
示例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;
}
开发者ID:niavok,项目名称:perroquet-website,代码行数:12,代码来源:LanguageManager.php
示例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');
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:16,代码来源:view.languages.php
示例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');
}
开发者ID:niavok,项目名称:perroquet-website,代码行数:13,代码来源:select.php
示例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);
}
开发者ID:pars5555,项目名称:pcstore,代码行数:14,代码来源:GuestLoad.class.php
示例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 <[email protected]>, Kelly <[email protected]>' . "\r\n";
$headers .= "From: {$from}\r\n";
// $headers .= 'From: Birthday Reminder <[email protected]>' . "\r\n";
// $headers .= 'Cc: [email protected]' . "\r\n";
// $headers .= 'Bcc: [email protected]' . "\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);
}
}
开发者ID:pars5555,项目名称:pcstore,代码行数:48,代码来源:MailSender.class.php
示例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'] : "");
}
开发者ID:pars5555,项目名称:photobooth,代码行数:16,代码来源:BaseValidLoad.class.php
示例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;
}
}
}
开发者ID:klr2003,项目名称:sourceread,代码行数:21,代码来源:VardefManager.php
示例16: generateContent
function generateContent()
{
$content = '
<h1>' . _('Select language') . '</h1>';
$langs = Config::getLanguagelist();
$content .= '<form action="' . RessourceManager::getInnerUrl('special/language/select') . '" method="GET">';
$content .= '
<label for="language">' . _('Choose the new language : ') . '</label>
<select name="language" id="language">';
foreach ($langs as $lang) {
if ($lang['choosable']) {
$content .= '
<option value="' . $lang['code'] . '" ' . ($lang['code'] == LanguageManager::getLanguage() ? 'selected="selected"' : '') . '>' . $lang['label'] . '</option>';
}
}
$content .= '</select><br /><input type="submit" value="' . _("Select") . '"></form>';
return $content;
}
开发者ID:niavok,项目名称:perroquet-website,代码行数:18,代码来源:choose.php
示例17: __construct
/**
* Constructs a new class instance.
*
* @param array $values
* An array of property values, keyed by property name, used to construct
* the language.
*/
public function __construct(array $values = array())
{
// Set all the provided properties for the language.
foreach ($values as $key => $value) {
$this->{$key} = $value;
}
// If some values were not set, set sane defaults of a predefined language.
if (!isset($values['name']) || !isset($values['direction'])) {
$predefined = LanguageManager::getStandardLanguageList();
if (isset($predefined[$this->id])) {
if (!isset($values['name'])) {
$this->name = $predefined[$this->id][0];
}
if (!isset($values['direction']) && isset($predefined[$this->id][2])) {
$this->direction = $predefined[$this->id][2];
}
}
}
}
开发者ID:davidsoloman,项目名称:drupalconsole.com,代码行数:26,代码来源:Language.php
示例18: 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.
*
* @param string $module
* @param string $object
* @param array $templates
* @param bool $object_name
*/
static function createVardef($module, $object, $templates = ['default'], $object_name = false)
{
global $dictionary;
include_once 'modules/TableDictionary.php';
//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);
if (isset(VardefManager::$custom_disabled_modules[$module])) {
$vardef_paths = ['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;
}
}
}
}
开发者ID:butschster,项目名称:sugarcrm_dev,代码行数:29,代码来源:VardefManager.php
示例19: preFilter
/**
* Renders the change language form and handles its submission
* @param CFilterChain $filterChain
* @return boolean whether to continue execution
*/
protected function preFilter($filterChain)
{
if (isset($_POST['ChangeLanguageForm'])) {
$model = new ChangeLanguageForm();
$model->attributes = $_POST['ChangeLanguageForm'];
if ($model->validate()) {
// Get the display name of the new language
$languages = LanguageManager::getAvailableLanguages();
$newLanguage = $languages[$model->language];
// Update user's default language
if ($model->setDefault) {
$user = User::model()->findByPk(Yii::app()->user->id);
$user->language = $model->language;
// Don't rehash the password, it hasn't been changed
$user->inhibitPasswordHash();
$user->save();
}
// Update and inform
Yii::app()->languageManager->setCurrent($model->language);
Yii::app()->user->setFlash('success', Yii::t('Language', 'Language changed to {newLanguage}', array('{newLanguage}' => $newLanguage)));
}
}
return true;
}
开发者ID:pweisenburger,项目名称:xbmc-video-server,代码行数:29,代码来源:ChangeLanguageFilter.php
示例20: return_module_language
/**
* This function retrieves a module's language file and returns the array of strings included.
*
* @param string $language specific language to load
* @param string $module module name to load strings for
* @param bool $refresh optional, true if you want to rebuild the language strings
* @return array lang strings
*/
function return_module_language($language, $module, $refresh = false)
{
global $mod_strings;
global $sugar_config;
global $currentModule;
// Jenny - Bug 8119: Need to check if $module is not empty
if (empty($module)) {
$stack = debug_backtrace();
$GLOBALS['log']->warn("Variable module is not in return_module_language " . var_export($stack, true));
return array();
}
if (!$refresh) {
$cache_key = LanguageManager::getLanguageCacheKey($module, $language);
// Check for cached value
$cache_entry = sugar_cache_retrieve($cache_key);
if (!empty($cache_entry)) {
return $cache_entry;
}
}
// Store the current mod strings for later
$temp_mod_strings = $mod_strings;
$loaded_mod_strings = array();
$language_used = $language;
$default_language = $sugar_config['default_language'];
if (empty($language)) {
$language = $default_language;
}
// Bug 21559 - So we can get all the strings defined in the template, refresh
// the vardefs file if the cached language file doesn't exist.
if (!file_exists($GLOBALS['sugar_config']['cache_dir'] . 'modules/' . $module . '/language/' . $language . '.lang.php') && !empty($GLOBALS['beanList'][$module])) {
$object = $GLOBALS['beanList'][$module];
if ($object == 'aCase') {
$object = 'Case';
}
VardefManager::refreshVardefs($module, $object);
}
$loaded_mod_strings = LanguageManager::loadModuleLanguage($module, $language, $refresh);
// cn: bug 6048 - merge en_us with requested language
if ($language != $sugar_config['default_language']) {
$loaded_mod_strings = sugarArrayMerge(LanguageManager::loadModuleLanguage($module, $sugar_config['default_language'], $refresh), $loaded_mod_strings);
}
// Load in en_us strings by default
if ($language != 'en_us' && $sugar_config['default_language'] != 'en_us') {
$loaded_mod_strings = sugarArrayMerge(LanguageManager::loadModuleLanguage($module, 'en_us', $refresh), $loaded_mod_strings);
}
// If we are in debug mode for translating, turn on the prefix now!
if ($sugar_config['translation_string_prefix']) {
foreach ($loaded_mod_strings as $entry_key => $entry_value) {
$loaded_mod_strings[$entry_key] = $language_used . ' ' . $entry_value;
}
}
$return_value = $loaded_mod_strings;
if (!isset($mod_strings)) {
$mod_strings = $return_value;
} else {
$mod_strings = $temp_mod_strings;
}
$cache_key = LanguageManager::getLanguageCacheKey($module, $language);
sugar_cache_put($cache_key, $return_value);
return $return_value;
}
开发者ID:razorinc,项目名称:sugarcrm-example,代码行数:69,代码来源:utils.php
注:本文中的LanguageManager类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论