Skip to content

Commit

Permalink
Merge pull request #42 from IBMStreams/develop
Browse files Browse the repository at this point in the history
resolves #41
  • Loading branch information
markheger authored Jan 7, 2020
2 parents ba37518 + 8cf7ada commit c382bf5
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.ibm.streamsx.elasticsearch.i18n;

import java.text.MessageFormat;
import java.util.Locale;
import java.util.MissingResourceException;
import java.util.ResourceBundle;

Expand All @@ -13,18 +14,35 @@ public class Messages
// the messages* files are searched in the directory of this class
private static final String BUNDLE_NAME = "com.ibm.streamsx.elasticsearch.i18n.messages.messages"; //$NON-NLS-1$#

// load the bundle based on the current locale
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle(BUNDLE_NAME);
private static final ResourceBundle RESOURCE_BUNDLE = ResourceBundle.getBundle (BUNDLE_NAME);
private static final ResourceBundle FALLBACK_RESOURCE_BUNDLE = ResourceBundle.getBundle (BUNDLE_NAME, new Locale ("en", "US"));

private Messages()
{
}
private Messages() {
}

public static String getString(String key) {
try {
return getRawMsg (key);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}

public static String getString(String key, Object... params ) {
public static String getString (String key, Object... args) {
try {
return MessageFormat.format(RESOURCE_BUNDLE.getString(key), params);
String msg = getRawMsg (key);
if (args == null) return msg;
return MessageFormat.format (msg, args);
} catch (MissingResourceException e) {
return '!' + key + '!';
}
}

private static String getRawMsg (String key) throws MissingResourceException {
try {
return RESOURCE_BUNDLE.getString(key);
} catch (MissingResourceException e) {
return FALLBACK_RESOURCE_BUNDLE.getString(key);
}
}
}
6 changes: 5 additions & 1 deletion com.ibm.streamsx.elasticsearch/info.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ The Elasticsearch toolkit is an open source IBM Streams toolkit that provides ad
This is an overview of changes for major and minor version upgrades. For details see the Releases in public Github.
++ What is changed in version 2.1.2
* Globalization support: Introduced fallback message for non-translated error message
++ What is new in version 2.1.1
* Fix missing error text information in case of bulk request failures.
Expand Down Expand Up @@ -74,7 +78,7 @@ as they constitute serious security holes.
you can use this parameter to temporarily disable hostnam verification.
]]></info:description>
<info:version>2.1.1</info:version>
<info:version>2.1.2</info:version>
<info:requiredProductVersion>4.2.0.0</info:requiredProductVersion>
</info:identity>
<info:dependencies/>
Expand Down
2 changes: 1 addition & 1 deletion com.ibm.streamsx.elasticsearch/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<groupId>com.ibm.streamsx.elasticsearch</groupId>
<artifactId>streamsx.elasticsearch</artifactId>
<packaging>jar</packaging>
<version>2.1.0</version>
<version>2.1.2</version>
<dependencies>
<dependency>
<groupId>io.searchbox</groupId>
Expand Down

0 comments on commit c382bf5

Please sign in to comment.