diff -u -r1.48 Locale.inc.php
--- classes/i18n/Locale.inc.php 12 May 2009 16:57:20 -0000 1.48
+++ classes/i18n/Locale.inc.php 2 Jul 2009 23:48:55 -0000
@@ -28,7 +28,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() {
@@ -47,6 +47,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 (($journal =& Request::getJournal())) {
+ $supportedFormLocales = $journal->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.33 Journal.inc.php
--- classes/journal/Journal.inc.php 27 May 2009 20:25:30 -0000 1.33
+++ classes/journal/Journal.inc.php 2 Jul 2009 23:48:55 -0000
@@ -82,6 +82,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" journal page title (if applicable).
* param $home boolean get homepage title
* @return string
diff -u -r1.17 LanguageSettingsForm.inc.php
--- classes/manager/form/LanguageSettingsForm.inc.php 12 May 2009 14:34:54 -0000 1.17
+++ classes/manager/form/LanguageSettingsForm.inc.php 2 Jul 2009 23:48:55 -0000
@@ -32,7 +32,8 @@
parent::Form('manager/languageSettings.tpl');
$this->settings = array(
- 'supportedLocales' => 'object'
+ 'supportedLocales' => 'object',
+ 'supportedFormLocales' => 'object'
);
$site =& Request::getSite();
@@ -68,8 +69,10 @@
$this->setData('primaryLocale', $journal->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());
+ }
}
}
@@ -81,8 +84,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());
+ }
}
}
@@ -94,19 +99,27 @@
$settingsDao =& DAORegistry::getDAO('JournalSettingsDAO');
// 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;
@@ -122,7 +135,6 @@
$journal->setPrimaryLocale($this->getData('primaryLocale'));
$journalDao->updateJournal($journal);
}
-
}
?>
diff -u -r1.16 manager.xml
--- locale/en_US/manager.xml 23 Jun 2009 22:21:25 -0000 1.16
+++ locale/en_US/manager.xml 2 Jul 2009 23:49:04 -0000
@@ -25,6 +25,8 @@
People in About the Journal:]]>
No editorial team positions have been created.
Journal Management
+ UI
+ Forms
This will replace any locale-specific journal settings you had for this locale
Reload locale-specific default settings
If a language supported by OJS 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 OJS documentation.]]>
diff -u -r1.25 languageSettings.tpl
--- templates/manager/languageSettings.tpl 8 Apr 2009 19:54:52 -0000 1.25
+++ templates/manager/languageSettings.tpl 2 Jul 2009 23:49:11 -0000
@@ -22,33 +22,39 @@
- | {fieldLabel name="primaryLocale" required="true" key="locale.primary"} |
- |
+ {fieldLabel name="primaryLocale" required="true" key="locale.primary"} |
+
+
+ |
- | |
- {translate key="manager.languages.primaryLocaleInstructions"} |
+ {translate key="manager.languages.primaryLocaleInstructions"} |
- | {fieldLabel suppressId="true" name="supportedLocales" key="locale.supported"} |
-
+ | {fieldLabel suppressId="true" name="supportedLocales" key="locale.supported"} |
+
|
- | |
- {translate key="manager.languages.supportedLocalesInstructions"} |
+ {translate key="manager.languages.supportedLocalesInstructions"} |