package org.apache.logging.log4j.core.lookup;

import java.util.MissingResourceException;
import java.util.ResourceBundle;
import org.apache.logging.log4j.core.LogEvent;
import org.apache.logging.log4j.core.config.plugins.Plugin;

@Plugin(
   name = "bundle",
   category = "Lookup"
)
public class ResourceBundleLookup implements StrLookup {
   public String lookup(String key) {
      if (key == null) {
         return null;
      } else {
         String[] keys = key.split(":");
         int keyLen = keys.length;
         if (keyLen != 2) {
            return null;
         } else {
            String bundleName = keys[0];
            String bundleKey = keys[1];

            try {
               return ResourceBundle.getBundle(bundleName).getString(bundleKey);
            } catch (MissingResourceException var7) {
               return null;
            }
         }
      }
   }

   public String lookup(LogEvent event, String key) {
      return this.lookup(key);
   }
}
