diff options
author | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2009-05-07 12:20:42 +0000 |
---|---|---|
committer | Lyubomir Marinov <lyubomir.marinov@jitsi.org> | 2009-05-07 12:20:42 +0000 |
commit | 5e0cb0a19794128a86b0caa213f81c122c81689e (patch) | |
tree | f251d7fa65299dcd1db46a1c34851e0552a68477 /src/net/java/sip | |
parent | 9b9e16ee0ee55650bcdd078c7c95a0b96d4e0cfa (diff) | |
download | jitsi-5e0cb0a19794128a86b0caa213f81c122c81689e.zip jitsi-5e0cb0a19794128a86b0caa213f81c122c81689e.tar.gz jitsi-5e0cb0a19794128a86b0caa213f81c122c81689e.tar.bz2 |
Supports country code (in addition to language code) when dealing with locales because the language properties files contain it and are not loaded without the modifications of this commit.
Diffstat (limited to 'src/net/java/sip')
6 files changed, 74 insertions, 24 deletions
diff --git a/src/net/java/sip/communicator/impl/resources/ResourceManagementServiceImpl.java b/src/net/java/sip/communicator/impl/resources/ResourceManagementServiceImpl.java index 3d11c92..16f0e4e 100644 --- a/src/net/java/sip/communicator/impl/resources/ResourceManagementServiceImpl.java +++ b/src/net/java/sip/communicator/impl/resources/ResourceManagementServiceImpl.java @@ -79,9 +79,8 @@ public class ResourceManagementServiceImpl String defaultLocale = (String)ResourceManagementActivator. getConfigurationService().getProperty(DEFAULT_LOCALE_CONFIG); if(defaultLocale != null) - { - Locale.setDefault(new Locale(defaultLocale)); - } + Locale.setDefault( + ResourceManagementServiceUtils.getLocale(defaultLocale)); languagePack = (LanguagePack) getDefaultResourcePack(LanguagePack.class.getName(), diff --git a/src/net/java/sip/communicator/plugin/defaultresourcepack/DefaultLanguagePackImpl.java b/src/net/java/sip/communicator/plugin/defaultresourcepack/DefaultLanguagePackImpl.java index 74f2bf9..f6f6b83 100644 --- a/src/net/java/sip/communicator/plugin/defaultresourcepack/DefaultLanguagePackImpl.java +++ b/src/net/java/sip/communicator/plugin/defaultresourcepack/DefaultLanguagePackImpl.java @@ -11,7 +11,6 @@ import java.util.*; import net.java.sip.communicator.service.resources.*; /** - * * @author Damian Minkov */ public class DefaultLanguagePackImpl @@ -44,17 +43,17 @@ public class DefaultLanguagePackImpl while (fsEnum.hasMoreElements()) { String fileName = ((URL)fsEnum.nextElement()).getFile(); - int localeIndex = fileName.indexOf('_'); if(localeIndex != -1) { - String localeName = + String localeId = fileName.substring( localeIndex + 1, fileName.indexOf('.', localeIndex)); - availableLocales.add(new Locale(localeName)); + availableLocales.add( + ResourceManagementServiceUtils.getLocale(localeId)); } } } diff --git a/src/net/java/sip/communicator/plugin/generalconfig/ConfigurationManager.java b/src/net/java/sip/communicator/plugin/generalconfig/ConfigurationManager.java index c753945..59ec530 100644 --- a/src/net/java/sip/communicator/plugin/generalconfig/ConfigurationManager.java +++ b/src/net/java/sip/communicator/plugin/generalconfig/ConfigurationManager.java @@ -6,9 +6,10 @@ */ package net.java.sip.communicator.plugin.generalconfig; -import java.util.Locale; +import java.util.*; + import net.java.sip.communicator.service.configuration.*; -import net.java.sip.communicator.service.resources.ResourceManagementService; +import net.java.sip.communicator.service.resources.*; public class ConfigurationManager { @@ -466,13 +467,14 @@ public class ConfigurationManager public static Locale getCurrentLanguage() { - String locale = (String)configService. - getProperty(ResourceManagementService.DEFAULT_LOCALE_CONFIG); + String localeId + = configService.getString( + ResourceManagementService.DEFAULT_LOCALE_CONFIG); - if(locale != null) - return new Locale(locale); - else - return Locale.getDefault(); + return + (localeId != null) + ? ResourceManagementServiceUtils.getLocale(localeId) + : Locale.getDefault(); } public static void setLanguage(Locale locale) diff --git a/src/net/java/sip/communicator/service/resources/LanguagePack.java b/src/net/java/sip/communicator/service/resources/LanguagePack.java index cc2732c..e136264 100644 --- a/src/net/java/sip/communicator/service/resources/LanguagePack.java +++ b/src/net/java/sip/communicator/service/resources/LanguagePack.java @@ -9,13 +9,13 @@ package net.java.sip.communicator.service.resources; import java.util.*; /** - * * @author Damian Minkov */ public interface LanguagePack extends ResourcePack { - public String RESOURCE_NAME_DEFAULT_VALUE = "DefaultLanguagePack"; + public static final String RESOURCE_NAME_DEFAULT_VALUE + = "DefaultLanguagePack"; /** * Returns a <tt>Map</tt>, containing all [key, value] pairs for the given diff --git a/src/net/java/sip/communicator/service/resources/ResourceManagementServiceUtils.java b/src/net/java/sip/communicator/service/resources/ResourceManagementServiceUtils.java index 048baec..d2f95a6 100644 --- a/src/net/java/sip/communicator/service/resources/ResourceManagementServiceUtils.java +++ b/src/net/java/sip/communicator/service/resources/ResourceManagementServiceUtils.java @@ -6,6 +6,8 @@ */
package net.java.sip.communicator.service.resources;
+import java.util.*;
+
import org.osgi.framework.*;
/**
@@ -13,17 +15,66 @@ import org.osgi.framework.*; */
public final class ResourceManagementServiceUtils
{
+
+ /**
+ * Constructs a new <code>Locale</code> instance from a specific locale
+ * identifier which can either be a two-letter language code or contain a
+ * two-letter language code and a two-letter country code in the form
+ * <code><language>_<country></code>.
+ *
+ * @param localeId
+ * the locale identifier describing the new <code>Locale</code>
+ * instance to be created
+ * @return a new <code>Locale</code> instance with language and country (if
+ * specified) matching the given locale identifier
+ */
+ public static Locale getLocale(String localeId)
+ {
+ int underscoreIndex = localeId.indexOf('_');
+ String language;
+ String country;
+
+ if (underscoreIndex == -1)
+ {
+ language = localeId;
+ country = "";
+ }
+ else
+ {
+ language = localeId.substring(0, underscoreIndex);
+ country = localeId.substring(underscoreIndex + 1);
+ }
+ return new Locale(language, country);
+ }
+
+ /**
+ * Gets the <code>ResourceManagementService</code> instance registered in a
+ * specific <code>BundleContext</code> (if any).
+ *
+ * @param bundleContext
+ * the <code>BundleContext</code> to be checked for a registered
+ * <code>ResourceManagementService</code>
+ * @return a <code>ResourceManagementService</code> instance registered in
+ * the specified <code>BundleContext</code> if any; otherwise,
+ * <tt>null</tt>
+ */
public static ResourceManagementService getService(
BundleContext bundleContext)
{
- ServiceReference ref =
- bundleContext.getServiceReference(ResourceManagementService.class
- .getName());
+ ServiceReference ref
+ = bundleContext.getServiceReference(
+ ResourceManagementService.class.getName());
- return (ref == null) ? null : (ResourceManagementService) bundleContext
- .getService(ref);
+ return
+ (ref == null)
+ ? null
+ : (ResourceManagementService) bundleContext.getService(ref);
}
+ /**
+ * Prevents the creation of <code>ResourceManagementServiceUtils</code>
+ * instances.
+ */
private ResourceManagementServiceUtils()
{
}
diff --git a/src/net/java/sip/communicator/util/xml/XMLUtils.java b/src/net/java/sip/communicator/util/xml/XMLUtils.java index 039bb3f..22c3ce0 100644 --- a/src/net/java/sip/communicator/util/xml/XMLUtils.java +++ b/src/net/java/sip/communicator/util/xml/XMLUtils.java @@ -7,7 +7,6 @@ package net.java.sip.communicator.util.xml; import java.io.*; -import java.nio.charset.*; import java.util.*; import javax.xml.transform.*; @@ -26,7 +25,7 @@ import net.java.sip.communicator.util.*; */ public class XMLUtils { - private static Logger logger = Logger.getLogger(XMLUtils.class); + private static final Logger logger = Logger.getLogger(XMLUtils.class); /** * Extracts from node the attribute with the specified name. |