diff -u -r1.12 Conference.inc.php --- classes/conference/Conference.inc.php 27 May 2009 20:25:50 -0000 1.12 +++ classes/conference/Conference.inc.php 3 Jul 2009 00:35:51 -0000 @@ -240,6 +240,31 @@ } /** + * Return associative array of all locales supported by forms on the site. + * These locales are used to provide a language toggle on the main site pages. + * @return array + */ + function &getSupportedFormLocaleNames() { + $supportedLocales =& $this->getData('supportedFormLocales'); + + if (!isset($supportedLocales)) { + $supportedLocales = array(); + $localeNames =& Locale::getAllLocales(); + + $locales = $this->getSetting('supportedFormLocales'); + if (!isset($locales) || !is_array($locales)) { + $locales = array(); + } + + foreach ($locales as $localeKey) { + $supportedLocales[$localeKey] = $localeNames[$localeKey]; + } + } + + return $supportedLocales; + } + + /** * Get "localized" conference page title (if applicable). * param $home boolean get homepage title * @return string diff -u -r1.22 Locale.inc.php --- classes/i18n/Locale.inc.php 12 May 2009 19:37:50 -0000 1.22 +++ classes/i18n/Locale.inc.php 3 Jul 2009 00:35:52 -0000 @@ -27,7 +27,7 @@ class Locale extends PKPLocale { /** - * Get all supported locales for the current context. + * Get all supported UI locales for the current context. * @return array */ function getSupportedLocales() { @@ -46,6 +46,25 @@ } /** + * Get all supported form locales for the current context. + * @return array + */ + function getSupportedFormLocales() { + static $supportedFormLocales; + if (!isset($supportedFormLocales)) { + if (defined('SESSION_DISABLE_INIT') || !Config::getVar('general', 'installed')) { + $supportedFormLocales = Locale::getAllLocales(); + } elseif (($conference =& Request::getConference())) { + $supportedFormLocales = $conference->getSupportedFormLocaleNames(); + } else { + $site =& Request::getSite(); + $supportedFormLocales = $site->getSupportedLocaleNames(); + } + } + return $supportedFormLocales; + } + + /** * Return the key name of the user's currently selected locale (default * is "en_US" for U.S. English). * @return string diff -u -r1.13 LanguageSettingsForm.inc.php --- classes/manager/form/LanguageSettingsForm.inc.php 12 May 2009 19:37:50 -0000 1.13 +++ classes/manager/form/LanguageSettingsForm.inc.php 3 Jul 2009 00:35:52 -0000 @@ -31,7 +31,8 @@ parent::Form('manager/languageSettings.tpl'); $this->settings = array( - 'supportedLocales' => 'object' + 'supportedLocales' => 'object', + 'supportedFormLocales' => 'object' ); $site =& Request::getSite(); @@ -67,8 +68,10 @@ $this->setData('primaryLocale', $conference->getPrimaryLocale()); - if ($this->getData('supportedLocales') == null || !is_array($this->getData('supportedLocales'))) { - $this->setData('supportedLocales', array()); + foreach (array('supportedFormLocales', 'supportedLocales') as $name) { + if ($this->getData($name) == null || !is_array($this->getData($name))) { + $this->setData($name, array()); + } } } @@ -80,8 +83,10 @@ $vars[] = 'primaryLocale'; $this->readUserVars($vars); - if ($this->getData('supportedLocales') == null || !is_array($this->getData('supportedLocales'))) { - $this->setData('supportedLocales', array()); + foreach (array('supportedFormLocales', 'supportedLocales') as $name) { + if ($this->getData($name) == null || !is_array($this->getData($name))) { + $this->setData($name, array()); + } } } @@ -93,19 +98,27 @@ $settingsDao =& DAORegistry::getDAO('ConferenceSettingsDAO'); // Verify additional locales - $supportedLocales = array(); - foreach ($this->getData('supportedLocales') as $locale) { - if (Locale::isLocaleValid($locale) && in_array($locale, $this->availableLocales)) { - array_push($supportedLocales, $locale); + foreach (array('supportedLocales', 'supportedFormLocales') as $name) { + $$name = array(); + foreach ($this->getData($name) as $locale) { + if (Locale::isLocaleValid($locale) && in_array($locale, $this->availableLocales)) { + array_push($$name, $locale); + } } } $primaryLocale = $this->getData('primaryLocale'); - if ($primaryLocale != null && !empty($primaryLocale) && !in_array($primaryLocale, $supportedLocales)) { - array_push($supportedLocales, $primaryLocale); + // Make sure at least the primary locale is chosen as available + if ($primaryLocale != null && !empty($primaryLocale)) { + foreach (array('supportedLocales', 'supportedFormLocales') as $name) { + if (!in_array($primaryLocale, $$name)) { + array_push($$name, $primaryLocale); + } + } } $this->setData('supportedLocales', $supportedLocales); + $this->setData('supportedFormLocales', $supportedFormLocales); foreach ($this->_data as $name => $value) { if (!in_array($name, array_keys($this->settings))) continue; @@ -121,7 +134,6 @@ $conference->setPrimaryLocale($this->getData('primaryLocale')); $conferenceDao->updateConference($conference); } - } ?> diff -u -r1.16 manager.xml --- locale/en_US/manager.xml 23 Jun 2009 22:21:35 -0000 1.16 +++ locale/en_US/manager.xml 3 Jul 2009 00:35:58 -0000 @@ -33,6 +33,8 @@ Organizing Team in About the Conference:]]> No organizing team positions have been created. There are no import/export plugins currently installed. + UI + Forms
If a language supported by OCS is not listed below, ask your site administrator to install the language from the site administration interface. For instructions on adding support for new languages, please consult the OCS documentation.]]>
Sorry, no additional languages are available. Contact your site administrator if you wish to use additional languages with this conference. This will be the default language for the conference site. diff -u -r1.9 languageSettings.tpl --- templates/manager/languageSettings.tpl 8 Apr 2009 20:01:39 -0000 1.9 +++ templates/manager/languageSettings.tpl 3 Jul 2009 00:36:01 -0000 @@ -6,7 +6,7 @@ * * Form to edit conference language settings. * - * $Id: languageSettings.tpl,v 1.9 2009/04/08 20:01:39 asmecher Exp $ + * $Id: languageSettings.tpl,v 1.26 2009/07/03 00:11:18 asmecher Exp $ *} {strip} {assign var="pageTitle" value="common.languages"} @@ -22,25 +22,36 @@ - - + + - - - + + -
{fieldLabel name="primaryLocale" required="true" key="locale.primary"}{fieldLabel name="primaryLocale" required="true" key="locale.primary"} + +
  {translate key="manager.languages.primaryLocaleInstructions"}
{fieldLabel suppressId="true" name="supportedLocales" key="locale.supported"}{foreach from=$availableLocales key=localeKey item=localeName} -
- {/foreach}
{fieldLabel suppressId="true" name="supportedLocales" key="locale.supported"} + + + + + + + {foreach from=$availableLocales key=localeKey item=localeName} + + + + + + {/foreach} +
 {translate key="manager.language.ui"}{translate key="manager.language.forms"}
{$localeName|escape}
+
  {translate key="manager.languages.supportedLocalesInstructions"}