View | Details | Raw Unified | Return to bug 3865 | Differences between
and this patch

Collapse All | Expand All

(-)classes/i18n/Locale.inc.php (-1 / +20 lines)
 Lines 28-34    Link Here 
28
28
29
class Locale extends PKPLocale {
29
class Locale extends PKPLocale {
30
	/**
30
	/**
31
	 * Get all supported locales for the current context.
31
	 * Get all supported UI locales for the current context.
32
	 * @return array
32
	 * @return array
33
	 */
33
	 */
34
	function getSupportedLocales() {
34
	function getSupportedLocales() {
 Lines 47-52    Link Here 
47
	}
47
	}
48
48
49
	/**
49
	/**
50
	 * Get all supported form locales for the current context.
51
	 * @return array
52
	 */
53
	function getSupportedFormLocales() {
54
		static $supportedFormLocales;
55
		if (!isset($supportedFormLocales)) {
56
			if (defined('SESSION_DISABLE_INIT') || !Config::getVar('general', 'installed')) {
57
				$supportedFormLocales = Locale::getAllLocales();
58
			} elseif (($journal =& Request::getJournal())) {
59
				$supportedFormLocales = $journal->getSupportedFormLocaleNames();
60
			} else {
61
				$site =& Request::getSite();
62
				$supportedFormLocales = $site->getSupportedLocaleNames();
63
			}
64
		}
65
		return $supportedFormLocales;
66
	}
67
68
	/**
50
	 * Return the key name of the user's currently selected locale (default
69
	 * Return the key name of the user's currently selected locale (default
51
	 * is "en_US" for U.S. English).
70
	 * is "en_US" for U.S. English).
52
	 * @return string
71
	 * @return string
(-)classes/journal/Journal.inc.php (+25 lines)
 Lines 82-87    Link Here 
82
	}
82
	}
83
83
84
	/**
84
	/**
85
	 * Return associative array of all locales supported by forms on the site.
86
	 * These locales are used to provide a language toggle on the main site pages.
87
	 * @return array
88
	 */
89
	function &getSupportedFormLocaleNames() {
90
		$supportedLocales =& $this->getData('supportedFormLocales');
91
92
		if (!isset($supportedLocales)) {
93
			$supportedLocales = array();
94
			$localeNames =& Locale::getAllLocales();
95
96
			$locales = $this->getSetting('supportedFormLocales');
97
			if (!isset($locales) || !is_array($locales)) {
98
				$locales = array();
99
			}
100
101
			foreach ($locales as $localeKey) {
102
				$supportedLocales[$localeKey] = $localeNames[$localeKey];
103
			}
104
		}
105
106
		return $supportedLocales;
107
	}
108
109
	/**
85
	 * Get "localized" journal page title (if applicable).
110
	 * Get "localized" journal page title (if applicable).
86
	 * param $home boolean get homepage title
111
	 * param $home boolean get homepage title
87
	 * @return string
112
	 * @return string
(-)classes/manager/form/LanguageSettingsForm.inc.php (-12 / +24 lines)
 Lines 32-38    Link Here 
32
		parent::Form('manager/languageSettings.tpl');
32
		parent::Form('manager/languageSettings.tpl');
33
33
34
		$this->settings = array(
34
		$this->settings = array(
35
			'supportedLocales' => 'object'
35
			'supportedLocales' => 'object',
36
			'supportedFormLocales' => 'object'
36
		);
37
		);
37
38
38
		$site =& Request::getSite();
39
		$site =& Request::getSite();
 Lines 68-75    Link Here 
68
69
69
		$this->setData('primaryLocale', $journal->getPrimaryLocale());
70
		$this->setData('primaryLocale', $journal->getPrimaryLocale());
70
71
71
		if ($this->getData('supportedLocales') == null || !is_array($this->getData('supportedLocales'))) {
72
		foreach (array('supportedFormLocales', 'supportedLocales') as $name) {
72
			$this->setData('supportedLocales', array());
73
			if ($this->getData($name) == null || !is_array($this->getData($name))) {
74
				$this->setData($name, array());
75
			}
73
		}
76
		}
74
	}
77
	}
75
78
 Lines 81-88    Link Here 
81
		$vars[] = 'primaryLocale';
84
		$vars[] = 'primaryLocale';
82
		$this->readUserVars($vars);
85
		$this->readUserVars($vars);
83
86
84
		if ($this->getData('supportedLocales') == null || !is_array($this->getData('supportedLocales'))) {
87
		foreach (array('supportedFormLocales', 'supportedLocales') as $name) {
85
			$this->setData('supportedLocales', array());
88
			if ($this->getData($name) == null || !is_array($this->getData($name))) {
89
				$this->setData($name, array());
90
			}
86
		}
91
		}
87
	}
92
	}
88
93
 Lines 94-112    Link Here 
94
		$settingsDao =& DAORegistry::getDAO('JournalSettingsDAO');
99
		$settingsDao =& DAORegistry::getDAO('JournalSettingsDAO');
95
100
96
		// Verify additional locales
101
		// Verify additional locales
97
		$supportedLocales = array();
102
		foreach (array('supportedLocales', 'supportedFormLocales') as $name) {
98
		foreach ($this->getData('supportedLocales') as $locale) {
103
			$$name = array();
99
			if (Locale::isLocaleValid($locale) && in_array($locale, $this->availableLocales)) {
104
			foreach ($this->getData($name) as $locale) {
100
				array_push($supportedLocales, $locale);
105
				if (Locale::isLocaleValid($locale) && in_array($locale, $this->availableLocales)) {
106
					array_push($$name, $locale);
107
				}
101
			}
108
			}
102
		}
109
		}
103
110
104
		$primaryLocale = $this->getData('primaryLocale');
111
		$primaryLocale = $this->getData('primaryLocale');
105
112
106
		if ($primaryLocale != null && !empty($primaryLocale) && !in_array($primaryLocale, $supportedLocales)) {
113
		// Make sure at least the primary locale is chosen as available
107
			array_push($supportedLocales, $primaryLocale);
114
		if ($primaryLocale != null && !empty($primaryLocale)) {
115
			foreach (array('supportedLocales', 'supportedFormLocales') as $name) {
116
				if (!in_array($primaryLocale, $$name)) {
117
					array_push($$name, $primaryLocale);
118
				}
119
			}
108
		}
120
		}
109
		$this->setData('supportedLocales', $supportedLocales);
121
		$this->setData('supportedLocales', $supportedLocales);
122
		$this->setData('supportedFormLocales', $supportedFormLocales);
110
123
111
		foreach ($this->_data as $name => $value) {
124
		foreach ($this->_data as $name => $value) {
112
			if (!in_array($name, array_keys($this->settings))) continue;
125
			if (!in_array($name, array_keys($this->settings))) continue;
 Lines 122-128    Link Here 
122
		$journal->setPrimaryLocale($this->getData('primaryLocale'));
135
		$journal->setPrimaryLocale($this->getData('primaryLocale'));
123
		$journalDao->updateJournal($journal);
136
		$journalDao->updateJournal($journal);
124
	}
137
	}
125
126
}
138
}
127
139
128
?>
140
?>
(-)locale/en_US/manager.xml (+2 lines)
 Lines 25-30    Link Here 
25
	<message key="manager.groups.enableBoard.description"><![CDATA[Under <a href="{$aboutEditorialTeamUrl}">People</a> in About the Journal:]]></message>
25
	<message key="manager.groups.enableBoard.description"><![CDATA[Under <a href="{$aboutEditorialTeamUrl}">People</a> in About the Journal:]]></message>
26
	<message key="manager.groups.noneCreated">No editorial team positions have been created.</message>
26
	<message key="manager.groups.noneCreated">No editorial team positions have been created.</message>
27
	<message key="manager.journalManagement">Journal Management</message>
27
	<message key="manager.journalManagement">Journal Management</message>
28
	<message key="manager.language.ui">UI</message>
29
	<message key="manager.language.forms">Forms</message>
28
	<message key="manager.language.confirmDefaultSettingsOverwrite">This will replace any locale-specific journal settings you had for this locale</message>
30
	<message key="manager.language.confirmDefaultSettingsOverwrite">This will replace any locale-specific journal settings you had for this locale</message>
29
	<message key="manager.language.reloadLocalizedDefaultSettings">Reload locale-specific default settings</message>
31
	<message key="manager.language.reloadLocalizedDefaultSettings">Reload locale-specific default settings</message>
30
	<message key="manager.languages.languageInstructions"><![CDATA[OJS can be made available to users in any of several supported languages. As well, OJS can operate as a multilingual system, providing users with an ability to toggle between languages on each page, and allowing certain data to be entered in several additional languages.<br /><br/>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.]]></message>
32
	<message key="manager.languages.languageInstructions"><![CDATA[OJS can be made available to users in any of several supported languages. As well, OJS can operate as a multilingual system, providing users with an ability to toggle between languages on each page, and allowing certain data to be entered in several additional languages.<br /><br/>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.]]></message>
(-)templates/manager/languageSettings.tpl (-14 / +20 lines)
 Lines 22-54    Link Here 
22
22
23
<table class="data" width="100%">
23
<table class="data" width="100%">
24
<tr valign="top">
24
<tr valign="top">
25
	<td width="20%" class="label">{fieldLabel name="primaryLocale" required="true" key="locale.primary"}</td>
25
	<td width="20%" rowspan="2" class="label">{fieldLabel name="primaryLocale" required="true" key="locale.primary"}</td>
26
	<td width="80%" colspan="2" class="value"><select id="primaryLocale" name="primaryLocale" size="1" class="selectMenu">
26
	<td width="80%" colspan="3" class="value">
27
	{foreach from=$availableLocales key=localeKey item=localeName}
27
		<select id="primaryLocale" name="primaryLocale" size="1" class="selectMenu">
28
		<option value="{$localeKey|escape}"{if $localeKey == $primaryLocale} selected="selected"{/if}>{$localeName|escape}</option>
28
			{html_options options=$availableLocales selected=$primaryLocale}
29
	{/foreach}
29
		</select>
30
	</select></td>
30
	</td>
31
</tr>
31
</tr>
32
<tr valign="top">
32
<tr valign="top">
33
	<td>&nbsp;</td>
33
	<td colspan="3" class="value"><span class="instruct">{translate key="manager.languages.primaryLocaleInstructions"}</span></td>
34
	<td colspan="2" class="value"><span class="instruct">{translate key="manager.languages.primaryLocaleInstructions"}</span></td>
35
</tr>
34
</tr>
36
<tr valign="top">
35
<tr valign="top">
37
	<td class="label">{fieldLabel suppressId="true" name="supportedLocales" key="locale.supported"}</td>
36
	<td class="label" rowspan="2">{fieldLabel suppressId="true" name="supportedLocales" key="locale.supported"}</td>
38
	<td colspan="2" class="value">
37
	<td colspan="3" class="value">
39
		<table class="data" width="100%">
38
		<table class="data" width="100%">
39
		<tr valign="top">
40
			<td width="20%">&nbsp;</td>
41
			<td align="center" width="10%">{translate key="manager.language.ui"}</td>
42
			<td align="center" width="10%">{translate key="manager.language.forms"}</td>
43
			<td width="60%">&nbsp;</td>
44
		</tr>
40
		{foreach from=$availableLocales key=localeKey item=localeName}
45
		{foreach from=$availableLocales key=localeKey item=localeName}
41
			<tr>
46
			<tr>
42
				<td width="30%"><input type="checkbox" name="supportedLocales[]" id="supportedLocales-{$localeKey|escape}" value="{$localeKey|escape}"{if in_array($localeKey, $supportedLocales)} checked="checked"{/if}/> <label for="supportedLocales-{$localeKey|escape}">{$localeName|escape}</label></td>
47
				<td>{$localeName|escape}</td>
43
				<td width="70%"><a href="{url op="reloadLocalizedDefaultSettings" localeToLoad=$localeKey}" onclick="return confirm('{translate|escape:"jsparam" key="manager.language.confirmDefaultSettingsOverwrite"}')" class="action">{translate key="manager.language.reloadLocalizedDefaultSettings"}</a></td>
48
				<td align="center"><input type="checkbox" name="supportedLocales[]" value="{$localeKey|escape}"{if in_array($localeKey, $supportedLocales)} checked="checked"{/if}/></td>
49
				<td align="center"><input type="checkbox" name="supportedFormLocales[]" value="{$localeKey|escape}"{if in_array($localeKey, $supportedFormLocales)} checked="checked"{/if}/></td>
50
				<td><a href="{url op="reloadLocalizedDefaultSettings" localeToLoad=$localeKey}" onclick="return confirm('{translate|escape:"jsparam" key="manager.language.confirmDefaultSettingsOverwrite"}')" class="action">{translate key="manager.language.reloadLocalizedDefaultSettings"}</a></td>
44
			</tr>
51
			</tr>
45
		{/foreach}
52
		{/foreach}
46
		</table>
53
		</table>
47
	</td>
54
	</td>
48
</tr>
55
</tr>
49
<tr valign="top">
56
<tr valign="top">
50
	<td>&nbsp;</td>
57
	<td colspan="3" class="value"><span class="instruct">{translate key="manager.languages.supportedLocalesInstructions"}</span></td>
51
	<td colspan="2" class="value"><span class="instruct">{translate key="manager.languages.supportedLocalesInstructions"}</span></td>
52
</tr>
58
</tr>
53
</table>
59
</table>
54
60

Return to bug 3865