Commit d89d474d authored by Matt Tucker's avatar Matt Tucker Committed by matt

Locale fixes.


git-svn-id: http://svn.igniterealtime.org/svn/repos/messenger/trunk@1053 b35dd754-fafc-0310-a699-88a17e54d16e
parent 5c2f0377
......@@ -102,10 +102,10 @@ you are making a Simplified Chinese translation:</p>
<p>To test your translation, copy the translated resource bundle file (example,
messenger_i18n_de.properties) to the <tt>lib/</tt> directory of your Jive Messenger
installation. Make sure Jive Messenger is stopped and then edit the <tt>conf/jive-messenger.xml</tt>
file. Set the <tt>adminConsole.locale</tt> property to match your new resource
file. Set the <tt>locale</tt> property to match your new resource
bundle such as "de" or "zh_CN". Start Jive Messenger and the admin console
should now be using your translation. If you still see English text you may have
named your bundle incorrectly or used the wrong value for the <tt>adminConsole.locale</tt>
named your bundle incorrectly or used the wrong value for the <tt>locale</tt>
property.</p>
<p>Once your translation is complete and tested, please submit it to the Jive Messenger
......
......@@ -19,7 +19,6 @@
<adminConsole>
<port>9090</port>
<securePort>9091</securePort>
<locale>en</locale>
<!-- By default, only the user with the username "admin" can login
to the admin console. Alternatively, you can specify a comma-delimitted
list usernames that should be authorized to login by setting the
......@@ -27,6 +26,8 @@
<!-- <authorizedUsernames></authorizedUsernames> -->
</adminConsole>
<locale>en</locale>
<!-- Example LDAP settings -->
<!--
<ldap>
......
......@@ -13,7 +13,6 @@ package org.jivesoftware.database;
import org.jivesoftware.util.ClassUtils;
import org.jivesoftware.util.Log;
import org.jivesoftware.messenger.JiveGlobals;
import java.io.IOException;
import java.sql.*;
import java.util.Properties;
......@@ -399,8 +398,7 @@ public class ConnectionPool implements Runnable {
if (mysqlUseUnicode) {
Properties props = new Properties();
String encoding = JiveGlobals.getCharacterEncoding();
props.put("characterEncoding", encoding);
props.put("characterEncoding", "UTF-8");
props.put("useUnicode", "true");
if (username != null) {
props.put("user", username);
......
......@@ -52,8 +52,6 @@ public class JiveGlobals {
private static String JIVE_CONFIG_FILENAME = "jive-messenger.xml";
private static final String DEFAULT_CHAR_ENCODING = "UTF-8";
/**
* Location of the jiveHome directory. All configuration files should be
* located here.
......@@ -67,7 +65,6 @@ public class JiveGlobals {
private static Locale locale = null;
private static TimeZone timeZone = null;
private static String characterEncoding = null;
private static DateFormat dateFormat = null;
private static DateFormat dateTimeFormat = null;
......@@ -80,14 +77,16 @@ public class JiveGlobals {
*/
public static Locale getLocale() {
if (locale == null) {
if (properties != null) {
String language = (String)properties.get("locale.language");
if (xmlProperties != null) {
String [] localeArray = ((String)xmlProperties.getProperty("locale")).split("_");
String language = localeArray[0];
if (language == null) {
language = "";
}
String country = (String)properties.get("locale.country");
if (country == null) {
country = "";
String country = "";
if (localeArray.length == 2) {
country = localeArray[1];
}
// If no locale info is specified, return the system default Locale.
if (language.equals("") && country.equals("")) {
......@@ -114,8 +113,8 @@ public class JiveGlobals {
public static void setLocale(Locale newLocale) {
locale = newLocale;
// Save values to Jive properties.
setProperty("locale.country", locale.getCountry());
setProperty("locale.language", locale.getLanguage());
setXMLProperty("locale", locale.toString());
// Reset the date formatter objects
dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM, locale);
dateTimeFormat = DateFormat.getDateTimeInstance(DateFormat.MEDIUM,
......@@ -124,85 +123,6 @@ public class JiveGlobals {
dateTimeFormat.setTimeZone(timeZone);
}
/**
* Returns the character set that Jive uses for encoding. This
* is used for displaying content in skins, sending email watch
* updates, etc. The default encoding is ISO-8895-1, which is suitable for
* most Latin languages. If you need to support double byte character sets
* such as Chinese or Japanese, it's recommend that you use utf-8
* as the charset (Unicode). Unicode offers simultaneous support for a
* large number of languages and is easy to convert into native charsets
* as necessary. You may also specifiy any other charset that is supported
* by your JVM. A list of encodings supported by the Sun JVM can be found
* <a href="http://java.sun.com/j2se/1.3/docs/guide/intl/encoding.doc.html">
* here.</a><p>
*
* In order for a particular encoding to work (such as Unicode), your
* application server and database may need to be specially configured.
* Please consult your server documentation for more information. For
* example, SQLServer has a special column type for Unicode text, and the
* Resin application server can be configured to use a custom charset by
* adding a &lt;character-encoding&gt; element to the web.xml/resin.conf
* file. Any Servlet 2.3 compliant application servers also supports the
* method HttpServletRequest.setCharacterEncoding(String). A Servlet 2.3
* Filter called SetCharacterEncodingFilter is installed in the default
* Jive Messenger web.xml file, which will set the incoming character encoding
* to the one reported by this method.
*
* @return the global Jive character encoding.
*/
public static String getCharacterEncoding() {
if (characterEncoding == null) {
if (properties != null) {
String charEncoding = (String)properties.get("locale.characterEncoding");
if (charEncoding != null) {
characterEncoding = charEncoding;
}
else {
// The default encoding is ISO-8859-1. We use the version of
// the encoding name that seems to be most widely compatible.
characterEncoding = DEFAULT_CHAR_ENCODING;
}
}
else {
return DEFAULT_CHAR_ENCODING;
}
}
return characterEncoding;
}
/**
* Sets the character set that Jive uses for encoding. This
* is used for displaying content in skins, sending email watch
* updates, etc. The default encoding is ISO-8859-1, which is suitable for
* most Latin languages. If you need to support double byte character sets
* such as Chinese or Japanese, it's recommend that you use utf-8
* as the charset (Unicode). Unicode offers simultaneous support for a
* large number of languages and is easy to convert into native charsets
* as necessary. You may also specifiy any other charset that is supported
* by your JVM. A list of encodings supported by the Sun JVM can be found
* <a href="http://java.sun.com/j2se/1.3/docs/guide/intl/encoding.doc.html">
* here.</a><p>
*
* In order for a particular encoding to work (such as Unicode), your
* application server and database may need to be specially configured.
* Please consult your server documentation for more information. For
* example, SQLServer has a special column type for Unicode text, and the
* Resin application server can be configured to use a custom charset by
* adding a &lt;character-encoding&gt; element to the web.xml/resin.conf
* file. Any Servlet 2.3 compliant application servers also supports the
* method HttpServletRequest.setCharacterEncoding(String). A Servlet 2.3
* Filter called SetCharacterEncodingFilter is installed in the default
* Jive Messenger web.xml file, which will set the incoming character encoding
* to the one reported by this method.
*
* @param characterEncoding the global Jive character encoding.
*/
public static void setCharacterEncoding(String characterEncoding) {
JiveGlobals.characterEncoding = characterEncoding;
setProperty("locale.characterEncoding", characterEncoding);
}
/**
* Returns the global TimeZone used by Jive. The default is the VM's
* default time zone.
......@@ -306,7 +226,6 @@ public class JiveGlobals {
messengerHome = mHome;
locale = null;
timeZone = null;
characterEncoding = null;
dateFormat = null;
dateTimeFormat = null;
......
......@@ -91,11 +91,13 @@
<tr>
<td class="c1"><fmt:message key="index.uptime" /></td>
<td>
<% DateFormat formatter = DateFormat.getDateTimeInstance(DateFormat.MEDIUM, DateFormat.MEDIUM);
<%
String uptimeDisplay = null;
if ("en".equals(JiveGlobals.getLocale().getLanguage())) {
long now = System.currentTimeMillis();
long lastStarted = webManager.getXMPPServer().getServerInfo().getLastStarted().getTime();
long uptime = (now - lastStarted) / 1000L;
String uptimeDisplay = null;
if (uptime < 60) {
uptimeDisplay = "Less than 1 minute";
}
......@@ -107,15 +109,16 @@
long days = uptime / (60*60);
uptimeDisplay = "Approx " + days + ((days==1) ? " hour" : " hours");
}
}
%>
<% if (uptimeDisplay != null) { %>
<%= uptimeDisplay %> --
<%= uptimeDisplay %> -- started
<% } %>
started <%= formatter.format(webManager.getXMPPServer().getServerInfo().getLastStarted()) %>
<%= JiveGlobals.formatDateTime(webManager.getXMPPServer().getServerInfo().getLastStarted()) %>
<% if (webManager.getXMPPServer().isStandAlone()){ %>
&nbsp;&nbsp;<input type="submit" value="<fmt:message key="global.stop" />" name="stop" <%= ((serverOn) ? "" : "disabled") %>>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment