Support i18n in directory
[lgpl/argeo-commons.git] / org.argeo.util / src / org / argeo / util / directory / ldap / LdapEntry.java
index f34de7eb5022f5ed6b7f7603b801c3cca30898c2..823bc9502e6eb9a57c9e51e6d381c9c29b94f9c8 100644 (file)
@@ -4,6 +4,7 @@ import java.util.Arrays;
 import java.util.Collection;
 import java.util.Dictionary;
 import java.util.List;
+import java.util.Locale;
 import java.util.Set;
 import java.util.StringJoiner;
 import java.util.TreeSet;
@@ -42,4 +43,14 @@ public interface LdapEntry {
                currentObjectClasses.forEach((s) -> values.add(s));
                properties.put(LdapAttrs.objectClasses.name(), values.toString());
        }
+
+       public static Object getLocalized(Dictionary<String, Object> properties, String key, Locale locale) {
+               if (locale == null)
+                       return null;
+               Object value = null;
+               value = properties.get(key + ";lang-" + locale.getLanguage() + "-" + locale.getCountry());
+               if (value == null)
+                       value = properties.get(key + ";lang-" + locale.getLanguage());
+               return value;
+       }
 }