server-locale.jsp 8.91 KB
Newer Older
1 2 3 4
<%--
  -	$Revision$
  -	$Date$
  -
5
  - Copyright (C) 2004-2008 Jive Software. All rights reserved.
6
  -
7 8 9 10 11 12 13 14 15 16 17
  - Licensed under the Apache License, Version 2.0 (the "License");
  - you may not use this file except in compliance with the License.
  - You may obtain a copy of the License at
  -
  -     http://www.apache.org/licenses/LICENSE-2.0
  -
  - Unless required by applicable law or agreed to in writing, software
  - distributed under the License is distributed on an "AS IS" BASIS,
  - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  - See the License for the specific language governing permissions and
  - limitations under the License.
18 19
--%>

20 21 22 23
<%@ page import="org.jivesoftware.util.JiveGlobals,
                 org.jivesoftware.util.LocaleUtils,
                 org.jivesoftware.util.Log,
                 org.jivesoftware.util.ParamUtils"
24
%>
25 26 27 28
<%@ page import="java.util.HashMap"%>
<%@ page import="java.util.Locale"%>
<%@ page import="java.util.Map"%>
<%@ page import="java.util.TimeZone"%>
29

30 31
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
32

33 34 35
<jsp:useBean id="webManager" class="org.jivesoftware.util.WebManager"  />
<% webManager.init(request, response, session, application, out ); %>

36 37
<%  // Get parameters //
    String localeCode = ParamUtils.getParameter(request,"localeCode");
38
    String timeZoneID = ParamUtils.getParameter(request,"timeZoneID");
39 40
    boolean save = request.getParameter("save") != null;

41 42
    // TODO: We're not displaying this error ever.
    Map<String,String> errors = new HashMap<String,String>();
43
    if (save) {
44 45 46 47
        // Set the timezeone
        try {
            TimeZone tz = TimeZone.getTimeZone(timeZoneID);
            JiveGlobals.setTimeZone(tz);
48
            // Log the event
49
            webManager.logEvent("updated time zone to "+tz.getID(), tz.toString());
50 51
        }
        catch (Exception e) {
52
            Log.error(e);
53
        }
54
        if (localeCode != null) {
55
            Locale newLocale = LocaleUtils.localeCodeToLocale(localeCode.trim());
56 57 58 59 60
            if (newLocale == null) {
                errors.put("localeCode","");
            }
            else {
                JiveGlobals.setLocale(newLocale);
61
                // Log the event
62
                webManager.logEvent("updated locale to "+newLocale.getDisplayName(), null);
63 64 65 66 67 68 69
                response.sendRedirect("server-locale.jsp?success=true");
                return;
            }
        }
    }

    Locale locale = JiveGlobals.getLocale();
70 71 72 73 74 75

    // Get the time zone list.
    String[][] timeZones = LocaleUtils.getTimeZoneList();

    // Get the current time zone.
    TimeZone timeZone = JiveGlobals.getTimeZone();
76 77
%>

78 79 80 81 82 83
<html>
    <head>
        <title><fmt:message key="locale.title" /></title>
        <meta name="pageID" content="server-locale"/>
        <meta name="helpPage" content="edit_server_properties.html"/>
    </head>
84
    <body>
85 86 87 88 89 90

<p>
<fmt:message key="locale.title.info" />
</p>


91 92 93 94 95 96 97
<!-- BEGIN locale settings -->
<form action="server-locale.jsp" method="post" name="sform">
	<div class="jive-contentBoxHeader">
		<fmt:message key="locale.system.set" />
	</div>
	<div class="jive-contentBox">
		<p>
98 99
        <b><fmt:message key="locale.current" />:</b> <%= locale.getDisplayName(locale) %> /
            <%= LocaleUtils.getTimeZoneName(JiveGlobals.getTimeZone().getID(), locale) %>
100 101 102 103
        </p>

        <%  boolean usingPreset = false;
            Locale[] locales = Locale.getAvailableLocales();
104 105 106 107 108
            for (Locale locale1 : locales) {
                usingPreset = locale1.equals(locale);
                if (usingPreset) {
                    break;
                }
109 110 111
            }
        %>

112
        <p><b><fmt:message key="language.choose" />:</b></p>
113 114 115 116 117

        <table cellspacing="0" cellpadding="3" border="0">
        <tbody>
            <tr>
                <td>
118
                    <input type="radio" name="localeCode" value="cs_CZ" <%= ("cs_CZ".equals(locale.toString()) ? "checked" : "") %>
119 120 121
                     id="loc01" />
                </td>
                <td colspan="2">
122
                    <label for="loc01">Czech (cs_CZ)</label>
123 124 125 126
                </td>
            </tr>
            <tr>
                <td>
127
                    <input type="radio" name="localeCode" value="de" <%= ("de".equals(locale.toString()) ? "checked" : "") %>
128 129
                     id="loc02" />
                </td>
130 131
                <td colspan="2">
                    <label for="loc02">Deutsch (de)</label>
132 133
                </td>
            </tr>
134 135
            <tr>
                <td>
136
                    <input type="radio" name="localeCode" value="en" <%= ("en".equals(locale.toString()) ? "checked" : "") %>
137 138 139
                     id="loc03" />
                </td>
                <td colspan="2">
140
                    <label for="loc03">English (en)</label>
141 142 143 144
                </td>
            </tr>
            <tr>
                <td>
145
                    <input type="radio" name="localeCode" value="es" <%= ("es".equals(locale.toString()) ? "checked" : "") %>
146 147 148
                     id="loc04" />
                </td>
                <td colspan="2">
149
                    <label for="loc04">Espa&ntilde;ol (es)</label>
150 151 152 153
                </td>
            </tr>
            <tr>
                <td>
154
                    <input type="radio" name="localeCode" value="fr" <%= ("fr".equals(locale.toString()) ? "checked" : "") %>
155 156 157
                     id="loc05" />
                </td>
                <td colspan="2">
158
                    <label for="loc05">Fran&ccedil;ais (fr)</label>
159 160
                </td>
            </tr>
161 162
            <tr>
                <td>
163
                    <input type="radio" name="localeCode" value="nl" <%= ("nl".equals(locale.toString()) ? "checked" : "") %>
164 165
                     id="loc06" />
                </td>
166
                <td colspan="2">
167
                    <label for="loc06">Nederlands (nl)</label>
168 169 170 171
                </td>
            </tr>
            <tr>
                <td>
172
                    <input type="radio" name="localeCode" value="pl_PL" <%= ("pl_PL".equals(locale.toString()) ? "checked" : "") %>
173 174
                     id="loc07" />
                </td>
175
                <td colspan="2">
176
                    <label for="loc07">Polski (pl_PL)</label>
177 178 179 180
                </td>
            </tr>
            <tr>
                <td>
181
                    <input type="radio" name="localeCode" value="pt_PT" <%= ("pt_PT".equals(locale.toString()) ? "checked" : "") %>
182 183
                     id="loc08" />
                </td>
184
                <td colspan="2">
185
                    <label for="loc08">Portugu&ecirc;s Portugal (pt_PT)</label>
186 187 188 189
                </td>
            </tr>
            <tr>
                <td>
190
                    <input type="radio" name="localeCode" value="pt_BR" <%= ("pt_BR".equals(locale.toString()) ? "checked" : "") %>
191 192
                     id="loc09" />
                </td>
193
                <td colspan="2">
194
                    <label for="loc09">Portugu&ecirc;s Brasileiro (pt_BR)</label>
195 196 197 198
                </td>
            </tr>
            <tr>
                <td>
199
                    <input type="radio" name="localeCode" value="ru_RU" <%= ("ru_RU".equals(locale.toString()) ? "checked" : "") %>
200 201
                     id="loc10" />
                </td>
202
                <td colspan="2">
203
                    <label for="loc10">&#x420;&#x443;&#x441;&#x441;&#x43A;&#x438;&#x439; (ru_RU)</label>
204 205 206 207
                </td>
            </tr>
            <tr>
                <td>
208
                    <input type="radio" name="localeCode" value="sk" <%= ("sk".equals(locale.toString()) ? "checked" : "") %>
209 210
                     id="loc11" />
                </td>
211 212 213 214 215 216 217 218 219
                <td colspan="2">
                    <label for="loc11">Sloven&#269;ina (sk)</label>
                </td>
            </tr>
            <tr>
                <td>
                    <input type="radio" name="localeCode" value="zh_CN" <%= ("zh_CN".equals(locale.toString()) ? "checked" : "") %>
                     id="loc12" />
                </td>
220
                <td>
221
                    <a href="#" onclick="document.sform.localeCode[1].checked=true; return false;"><img src="images/language_zh_CN.gif" border="0" alt="" /></a>
222 223
                </td>
                <td>
224
                    <label for="loc12">Simplified Chinese (zh_CN)</label>
225 226
                </td>
            </tr>
227 228
        </tbody>
        </table>
229

230 231 232 233 234
        <br>

        <p><b><fmt:message key="timezone.choose" />:</b></p>

        <select size="1" name="timeZoneID">
235 236 237 238 239
        <% for (String[] timeZone1 : timeZones) {
            String selected = "";
            if (timeZone.getID().equals(timeZone1[0].trim())) {
                selected = " selected";
            }
240
        %>
241 242
            <option value="<%= timeZone1[0] %>"<%= selected %>><%= timeZone1[1] %>
                <%  } %>
243
        </select>
244
	</div>
245
<input type="submit" name="save" value="<fmt:message key="global.save_settings" />">
246
</form>
247
<!-- END locale settings -->
248

249 250

</body>
251
</html>