本文整理汇总了PHP中Locale::getSupportedLocales方法的典型用法代码示例。如果您正苦于以下问题:PHP Locale::getSupportedLocales方法的具体用法?PHP Locale::getSupportedLocales怎么用?PHP Locale::getSupportedLocales使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Locale
的用法示例。
在下文中一共展示了Locale::getSupportedLocales方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: set
function set($locale) {
global $__locale, $__text, $service;
if (strtolower($locale) == 'auto') {
$locale = 'ko';
$supportedLanguages = Locale::getSupportedLocales();
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE']) && !empty($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
foreach (explode(',', $_SERVER['HTTP_ACCEPT_LANGUAGE']) as $_accepted) {
if (in_array($_accepted, $supportedLanguages)) {
$locale = $_accepted;
break;
}
}
}
}
list($common) = explode('-', $locale, 2);
Locale::refreshLocaleResource($locale);
if (file_exists($__locale['directory'] . '/' . $locale . '.php')) {
include($__locale['directory'] . '/' . $locale . '.php');
$__locale['locale'] = $locale;
return true;
} else if (($common != $locale) && file_exists($__locale['directory'] . '/' . $common . '.php')) {
include($__locale['directory'] . '/' . $common . '.php');
$__locale['locale'] = $common;
return true;
}
return false;
}
示例2: getLocale
/**
* Return the key name of the user's currently selected locale (default
* is "en_US" for U.S. English).
* @return string
*/
function getLocale()
{
static $currentLocale;
if (!isset($currentLocale)) {
if (defined('SESSION_DISABLE_INIT') || !Config::getVar('general', 'installed')) {
// If the locale is specified in the URL, allow
// it to override. (Necessary when locale is
// being set, as cookie will not yet be re-set)
$locale = Request::getUserVar('setLocale');
if (empty($locale) || !in_array($locale, array_keys(Locale::getSupportedLocales()))) {
$locale = Request::getCookieVar('currentLocale');
}
} else {
$sessionManager =& SessionManager::getManager();
$session =& $sessionManager->getUserSession();
$locale = $session->getSessionVar('currentLocale');
$journal =& Request::getJournal();
$site =& Request::getSite();
if (!isset($locale)) {
$locale = Request::getCookieVar('currentLocale');
}
if (isset($locale)) {
// Check if user-specified locale is supported
if ($journal != null) {
$locales =& $journal->getSupportedLocaleNames();
} else {
$locales =& $site->getSupportedLocaleNames();
}
if (!in_array($locale, array_keys($locales))) {
unset($locale);
}
}
if (!isset($locale)) {
// Use journal/site default
if ($journal != null) {
$locale = $journal->getPrimaryLocale();
}
if (!isset($locale)) {
$locale = $site->getPrimaryLocale();
}
}
}
if (!Locale::isLocaleValid($locale)) {
$locale = LOCALE_DEFAULT;
}
$currentLocale = $locale;
}
return $currentLocale;
}
示例3: smartyFormLanguageChooser
/**
* Add hidden form parameters for the localized fields for this form
* and display the language chooser field
* @param $params array
* @param $smarty object
*/
function smartyFormLanguageChooser($params, &$smarty)
{
// Echo back all non-current language field values so that they
// are not lost.
$formLocale = $smarty->get_template_vars('formLocale');
foreach ($this->getLocaleFieldNames() as $field) {
$values = $this->getData($field);
if (!is_array($values)) {
continue;
}
foreach ($values as $locale => $value) {
if ($locale != $formLocale) {
$this->_decomposeArray($field, $value, array($locale));
}
}
}
// Display the language selector widget.
$formLocale = $smarty->get_template_vars('formLocale');
echo '<div id="languageSelector"><select size="1" name="formLocale" id="formLocale" onchange="changeFormAction(\'' . htmlentities($params['form'], ENT_COMPAT, LOCALE_ENCODING) . '\', \'' . htmlentities($params['url'], ENT_QUOTES, LOCALE_ENCODING) . '\')" class="selectMenu">';
foreach (Locale::getSupportedLocales() as $locale => $name) {
echo '<option ' . ($locale == $formLocale ? 'selected="selected" ' : '') . 'value="' . htmlentities($locale, ENT_COMPAT, LOCALE_ENCODING) . '">' . htmlentities($name, ENT_COMPAT, LOCALE_ENCODING) . '</option>';
}
echo '</select></div>';
}
示例4: deleteBookForReviewById
/**
* Delete a book for review by book ID.
* @param $bookId int
*/
function deleteBookForReviewById($bookId)
{
$book =& $this->getBookForReview($bookId);
if ($book) {
// Delete authors
$this->bookForReviewAuthorDao->deleteAuthorsByBookForReview($bookId);
// Delete cover image files (for all locales) from the filesystem
import('file.PublicFileManager');
$publicFileManager = new PublicFileManager();
$locales = Locale::getSupportedLocales();
foreach ($locales as $locale) {
$publicFileManager->removeJournalFile($book->getJournalId(), $book->getFileName($locale));
}
// Delete settings
$this->update('DELETE FROM books_for_review_settings WHERE book_id = ?', $bookId);
// Delete book
$this->update('DELETE FROM books_for_review WHERE book_id = ?', $bookId);
}
}
示例5: getLocaleFrom3LetterIso
/**
* Translate an ISO639-2b compatible 3-letter string
* into the PKP locale identifier.
*
* This can be ambiguous if several locales are defined
* for the same language. In this case we'll use the
* primary locale to disambiguate.
*
* If that still doesn't determine a unique locale then
* we'll choose the first locale found.
*
* @param $iso3letter string
* @return string
*/
function getLocaleFrom3LetterIso($iso3Letter)
{
assert(strlen($iso3Letter) == 3);
$primaryLocale = Locale::getPrimaryLocale();
$localeCandidates = array();
$locales =& Locale::_getAllLocalesCacheContent();
foreach ($locales as $locale => $localeData) {
assert(isset($localeData['iso639-2b']));
if ($localeData['iso639-2b'] == $iso3Letter) {
if ($locale == $primaryLocale) {
// In case of ambiguity the primary locale
// overrides all other options so we're done.
return $primaryLocale;
}
$localeCandidates[] = $locale;
}
}
// Return null if we found no candidate locale.
if (empty($localeCandidates)) {
return null;
}
if (count($localeCandidates) > 1) {
// Check whether one of the candidate locales
// is a supported locale. If so choose the first
// supported locale.
$supportedLocales = Locale::getSupportedLocales();
foreach ($supportedLocales as $supportedLocale => $localeName) {
if (in_array($supportedLocale, $localeCandidates)) {
return $supportedLocale;
}
}
}
// If there is only one candidate (or if we were
// unable to disambiguate) then return the unique
// (first) candidate found.
return array_shift($localeCandidates);
}
示例6: smartyFBVElementMultilingual
function smartyFBVElementMultilingual($params, &$smarty, $content = null)
{
if (!isset($params['value']) || !is_array($params['value'])) {
$smarty->trigger_error('FBV: value parameter must be an array for multilingual elements');
}
if (!isset($params['name'])) {
$smarty->trigger_error('FBV: parameter must be set');
}
$required = isset($params['required']) ? $params['required'] : false;
$returner = '';
$values = $params['value'];
$name = $params['name'];
foreach (Locale::getSupportedLocales() as $locale => $localeName) {
// if the field is required, only set the main locale as required and others optional
if ($locale == Locale::getPrimaryLocale()) {
$params['required'] = $required;
} else {
$params['required'] = false;
}
$params['name'] = $name . "[{$locale}]";
$params['value'] = $values[$locale];
$returner .= $localeName . ' ' . $this->smartyFBVElement($params, $smarty, $content) . '<br />';
}
return $returner;
}
示例7: deleteItem
/**
* Delete a submissionChecklist
* @param $args array
* @param $request PKPRequest
* @return string Serialized JSON object
*/
function deleteItem($args, &$request)
{
$rowId = $request->getUserVar('rowId');
$router =& $request->getRouter();
$press =& $router->getContext($request);
// get all of the submissionChecklists
$submissionChecklistAll = $press->getSetting('submissionChecklist');
foreach (Locale::getSupportedLocales() as $locale => $name) {
if (isset($submissionChecklistAll[$locale][$rowId])) {
unset($submissionChecklistAll[$locale][$rowId]);
} else {
// only fail if the currently displayed locale was not set
// (this is the one that needs to be removed from the currently displayed grid)
if ($locale == Locale::getLocale()) {
$json = new JSON(false, Locale::translate('manager.setup.errorDeletingSubmissionChecklist'));
return $json->getString();
exit;
}
}
}
$press->updateSetting('submissionChecklist', $submissionChecklistAll, 'object', true);
$json = new JSON(true);
return $json->getString();
}
示例8: execute
/**
* Save email template.
*/
function execute($args, &$request)
{
$router =& $request->getRouter();
$press =& $router->getContext($request);
$submissionChecklistAll = $press->getSetting('submissionChecklist');
//FIXME: a bit of kludge to get unique submissionChecklist id's
$this->submissionChecklistId = $this->submissionChecklistId ? $this->submissionChecklistId : max(array_keys($submissionChecklistAll[Locale::getPrimaryLocale()])) + 1;
$checklistItem = $this->getData('checklistItem');
foreach (Locale::getSupportedLocales() as $locale => $name) {
$submissionChecklistAll[$locale][$this->submissionChecklistId]['content'] = $checklistItem[$locale];
}
$press->updateSetting('submissionChecklist', $submissionChecklistAll, 'object', true);
return true;
}