Skip to content

Commit

Permalink
Add functionality to load plugin messages (translations)
Browse files Browse the repository at this point in the history
  • Loading branch information
hmiguim committed Feb 21, 2024
1 parent f4e501c commit a35198b
Show file tree
Hide file tree
Showing 7 changed files with 352 additions and 288 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@
<akka.version>2.8.5</akka.version>
<apacheds.version>2.0.0.AM27</apacheds.version>
<httpcomponents.version>4.5.14</httpcomponents.version>
<commons_ip2.version>2.6.0</commons_ip2.version>
<commons_ip2.version>2.6.1</commons_ip2.version>
<metrics.version>3.2.6</metrics.version>
<roda_community_url>https://roda-community.org</roda_community_url>
<testng.groups>all</testng.groups>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.ResourceBundle;
import java.util.Set;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.function.Function;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

Expand Down Expand Up @@ -329,11 +331,22 @@ public DisposalHold load(String disposalHoldId) throws Exception {

private static HTTPServer prometheusMetricsServer;

private static Map<String, Function<Locale, ResourceBundle>> pluginMessageRegistry = new HashMap<>();

/** Private empty constructor */
private RodaCoreFactory() {
// do nothing
}

public static void addPluginMessagesProvider(String pluginId, Function<Locale, ResourceBundle> provider) {
LOGGER.info("Added resource bundle provider for {}", pluginId);
pluginMessageRegistry.put(pluginId, provider);
}

public static ResourceBundle getPluginMessages(String pluginId, Locale locale) {
return pluginMessageRegistry.get(pluginId).apply(locale);
}

public static void addDefaultConfiguration(String configuration) {
CONFIGURATIONS.add(configuration);
LOGGER.info("Added configuration: '{}'", configuration);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import java.nio.charset.Charset;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Collections;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Locale;
Expand All @@ -31,8 +30,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.google.common.collect.Iterators;

public class Messages {
private static final Logger LOGGER = LoggerFactory.getLogger(Messages.class);

Expand Down
Loading

0 comments on commit a35198b

Please sign in to comment.