mirror of https://github.com/apache/lucene.git
LUCENE-10213: Use unicode escapes in message property files in Luke (remove hacks)
This commit is contained in:
parent
ded915b29b
commit
98b17952f9
|
@ -57,6 +57,13 @@ tasks.withType(Jar) {
|
|||
}
|
||||
}
|
||||
|
||||
// Process UTF8 property files to unicode escapes.
|
||||
tasks.withType(ProcessResources).configureEach { task ->
|
||||
task.filesMatching("**/messages*.properties", {
|
||||
filteringCharset = 'UTF-8'
|
||||
filter(EscapeUnicode)
|
||||
})
|
||||
}
|
||||
|
||||
// Configure "stand-alone" JAR with proper dependency classpath links.
|
||||
task standaloneJar(type: Jar) {
|
||||
|
|
|
@ -20,6 +20,14 @@
|
|||
This is Luke, Apache Lucene low-level index inspection and repair utility.
|
||||
|
||||
Luke requires Java ${required.java.version}. You can start it with:
|
||||
```
|
||||
java -jar ${luke.cmd}
|
||||
```
|
||||
|
||||
or, using Java modules:
|
||||
|
||||
```
|
||||
java --module-path . --add-modules org.apache.logging.log4j --module lucene.luke
|
||||
```
|
||||
|
||||
Happy index hacking!
|
||||
|
|
|
@ -17,13 +17,8 @@
|
|||
|
||||
package org.apache.lucene.luke.app.desktop.util;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.Locale;
|
||||
import java.util.PropertyResourceBundle;
|
||||
import java.util.ResourceBundle;
|
||||
|
||||
/** Utilities for accessing message resources. */
|
||||
|
@ -41,33 +36,8 @@ public class MessageUtils {
|
|||
return new MessageFormat(pattern, Locale.ENGLISH).format(args);
|
||||
}
|
||||
|
||||
// https://stackoverflow.com/questions/4659929/how-to-use-utf-8-in-resource-properties-with-resourcebundle
|
||||
private static ResourceBundle.Control UTF8_RESOURCEBUNDLE_CONTROL =
|
||||
new ResourceBundle.Control() {
|
||||
@Override
|
||||
public ResourceBundle newBundle(
|
||||
String baseName, Locale locale, String format, ClassLoader loader, boolean reload)
|
||||
throws IllegalAccessException, InstantiationException, IOException {
|
||||
String bundleName = toBundleName(baseName, locale);
|
||||
String resourceName = toResourceName(bundleName, "properties");
|
||||
try (InputStream is = loader.getResourceAsStream(resourceName)) {
|
||||
return new PropertyResourceBundle(new InputStreamReader(is, StandardCharsets.UTF_8));
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private static ResourceBundle bundle;
|
||||
|
||||
static {
|
||||
Class<?> self = MessageUtils.class;
|
||||
if (self.getModule().isNamed()) {
|
||||
bundle = ResourceBundle.getBundle(MESSAGE_BUNDLE_BASENAME, Locale.ENGLISH, self.getModule());
|
||||
} else {
|
||||
bundle =
|
||||
ResourceBundle.getBundle(
|
||||
MESSAGE_BUNDLE_BASENAME, Locale.ENGLISH, UTF8_RESOURCEBUNDLE_CONTROL);
|
||||
}
|
||||
}
|
||||
private static ResourceBundle bundle =
|
||||
ResourceBundle.getBundle(MESSAGE_BUNDLE_BASENAME, Locale.ENGLISH);
|
||||
|
||||
private MessageUtils() {}
|
||||
}
|
||||
|
|
|
@ -15,6 +15,9 @@
|
|||
# limitations under the License.
|
||||
#
|
||||
|
||||
# This file must use UTF8 encoding. UTF8 is replaced with unicode
|
||||
# escapes at build time.
|
||||
|
||||
# Common
|
||||
label.status=Status:
|
||||
label.help=Help
|
||||
|
|
Loading…
Reference in New Issue