server-locale.jsp 6.93 KB
Newer Older
1 2 3 4
<%--
  -	$Revision$
  -	$Date$
  -
5
  - Copyright (C) 2004-2005 Jive Software. All rights reserved.
6 7 8 9 10
  -
  - This software is published under the terms of the GNU Public License (GPL),
  - a copy of which is included in this distribution.
--%>

11 12 13 14
<%@ page import="org.jivesoftware.util.JiveGlobals,
                 org.jivesoftware.util.LocaleUtils,
                 org.jivesoftware.util.Log,
                 org.jivesoftware.util.ParamUtils"
15
%>
16 17 18 19
<%@ page import="java.util.HashMap"%>
<%@ page import="java.util.Locale"%>
<%@ page import="java.util.Map"%>
<%@ page import="java.util.TimeZone"%>
20 21 22 23 24 25

<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jstl/fmt_rt" prefix="fmt" %>

<%  // Get parameters //
    String localeCode = ParamUtils.getParameter(request,"localeCode");
26
    String timeZoneID = ParamUtils.getParameter(request,"timeZoneID");
27 28 29 30
    boolean save = request.getParameter("save") != null;

    Map errors = new HashMap();
    if (save) {
31 32 33 34 35 36
        // Set the timezeone
        try {
            TimeZone tz = TimeZone.getTimeZone(timeZoneID);
            JiveGlobals.setTimeZone(tz);
        }
        catch (Exception e) {
37
            Log.error(e);
38
        }
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53
        Locale newLocale = null;
        if (localeCode != null) {
            newLocale = LocaleUtils.localeCodeToLocale(localeCode.trim());
            if (newLocale == null) {
                errors.put("localeCode","");
            }
            else {
                JiveGlobals.setLocale(newLocale);
                response.sendRedirect("server-locale.jsp?success=true");
                return;
            }
        }
    }

    Locale locale = JiveGlobals.getLocale();
54 55 56 57 58 59

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

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

62 63 64 65 66 67
<html>
    <head>
        <title><fmt:message key="locale.title" /></title>
        <meta name="pageID" content="server-locale"/>
        <meta name="helpPage" content="edit_server_properties.html"/>
    </head>
68
    <body>
69 70 71 72 73 74

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


75 76 77 78 79 80 81
<!-- 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>
82 83
        <b><fmt:message key="locale.current" />:</b> <%= locale.getDisplayName(locale) %> /
            <%= LocaleUtils.getTimeZoneName(JiveGlobals.getTimeZone().getID(), locale) %>
84 85 86 87 88 89 90 91 92 93
        </p>

        <%  boolean usingPreset = false;
            Locale[] locales = Locale.getAvailableLocales();
            for (int i=0; i<locales.length; i++) {
                usingPreset = locales[i].equals(locale);
                if (usingPreset) { break; }
            }
        %>

94
        <p><b><fmt:message key="language.choose" />:</b></p>
95 96 97 98 99

        <table cellspacing="0" cellpadding="3" border="0">
        <tbody>
            <tr>
                <td>
100
                    <input type="radio" name="localeCode" value="cs_CZ" <%= ("cs_CZ".equals(locale.toString()) ? "checked" : "") %>
101 102 103
                     id="loc01" />
                </td>
                <td colspan="2">
104
                    <label for="loc01">Czech (cs_CZ)</label>
105 106 107 108
                </td>
            </tr>
            <tr>
                <td>
109
                    <input type="radio" name="localeCode" value="de" <%= ("de".equals(locale.toString()) ? "checked" : "") %>
110 111
                     id="loc02" />
                </td>
112 113
                <td colspan="2">
                    <label for="loc02">Deutsch (de)</label>
114 115
                </td>
            </tr>
116 117
            <tr>
                <td>
118
                    <input type="radio" name="localeCode" value="en" <%= ("en".equals(locale.toString()) ? "checked" : "") %>
119 120 121
                     id="loc03" />
                </td>
                <td colspan="2">
122
                    <label for="loc03">English (en)</label>
123 124 125 126
                </td>
            </tr>
            <tr>
                <td>
127
                    <input type="radio" name="localeCode" value="es" <%= ("es".equals(locale.toString()) ? "checked" : "") %>
128 129 130
                     id="loc04" />
                </td>
                <td colspan="2">
131
                    <label for="loc04">Espa&ntilde;ol (es)</label>
132 133 134 135
                </td>
            </tr>
            <tr>
                <td>
136
                    <input type="radio" name="localeCode" value="fr" <%= ("fr".equals(locale.toString()) ? "checked" : "") %>
137 138 139
                     id="loc05" />
                </td>
                <td colspan="2">
140
                    <label for="loc05">Fran&ccedil;ais (fr)</label>
141 142
                </td>
            </tr>
143 144
            <tr>
                <td>
145
                    <input type="radio" name="localeCode" value="nl" <%= ("nl".equals(locale.toString()) ? "checked" : "") %>
146 147
                     id="loc06" />
                </td>
148
                <td colspan="2">
149
                    <label for="loc06">Nederlands (nl)</label>
150 151 152 153
                </td>
            </tr>
            <tr>
                <td>
154
                    <input type="radio" name="localeCode" value="pl_PL" <%= ("pl_PL".equals(locale.toString()) ? "checked" : "") %>
155 156
                     id="loc07" />
                </td>
157
                <td colspan="2">
158
                    <label for="loc07">Polski (pl_PL)</label>
159 160 161 162
                </td>
            </tr>
            <tr>
                <td>
163
                    <input type="radio" name="localeCode" value="pt_BR" <%= ("pt_BR".equals(locale.toString()) ? "checked" : "") %>
164 165
                     id="loc08" />
                </td>
166 167 168 169 170 171 172 173 174
                <td colspan="2">
                    <label for="loc08">Portugu&ecirc;s Brasileiro (pt_BR)</label>
                </td>
            </tr>
            <tr>
                <td>
                    <input type="radio" name="localeCode" value="zh_CN" <%= ("zh_CN".equals(locale.toString()) ? "checked" : "") %>
                     id="loc09" />
                </td>
175 176 177 178
                <td>
                    <a href="#" onclick="document.sform.localeCode[1].checked=true; return false;"><img src="images/language_zh_CN.gif" border="0" /></a>
                </td>
                <td>
179
                    <label for="loc09">Simplified Chinese (zh_CN)</label>
180 181
                </td>
            </tr>
182 183
        </tbody>
        </table>
184

185 186 187 188 189 190 191 192 193 194 195 196 197 198
        <br>

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

        <select size="1" name="timeZoneID">
        <%  for (int i=0; i<timeZones.length; i++) {
                String selected = "";
                if (timeZone.getID().equals(timeZones[i][0].trim())) {
                    selected = " selected";
                }
        %>
            <option value="<%= timeZones[i][0] %>"<%= selected %>><%= timeZones[i][1] %>
        <%  } %>
        </select>
199
	</div>
200
<input type="submit" name="save" value="<fmt:message key="global.save_settings" />">
201
</form>
202
<!-- END locale settings -->
203

204 205 206

</body>
</html>