1 package net.sf.openrocket.l10n;
3 import java.util.Locale;
4 import java.util.MissingResourceException;
6 import net.sf.openrocket.startup.Application;
9 * A translator that suppresses MissingResourceExceptions and handles them gracefully.
10 * For the first missing key this class calls the exception handler, and afterwards
11 * always returns the key for missing translations.
13 * @author Sampo Niskanen <sampo.niskanen@iki.fi>
15 public class ExceptionSuppressingTranslator implements Translator {
17 static boolean errorReported = false;
19 private final Translator translator;
25 * @param translator the translator to use
27 public ExceptionSuppressingTranslator(Translator translator) {
28 this.translator = translator;
34 public String get(String key) {
36 return translator.get(key);
37 } catch (MissingResourceException e) {
46 private static synchronized void handleError(String key, MissingResourceException e) {
49 Application.getExceptionHandler().handleErrorCondition("Can not find translation for '" + key + "' locale=" + Locale.getDefault(), e);