* @param key the key to look up. may contain / but cannot start with one. for example: categories/water
* @return
*/
public static Map<String, String> translate(ServiceContext context, String type, String key) throws JDOMException, IOException {
String appPath = context.getAppPath();
XmlCacheManager cacheManager = context.getXmlCacheManager();
File loc = new File(appPath, "loc");
String typeWithExtension = "xml"+File.separator+type+".xml";
Map<String, String> translations = new HashMap<String, String>();
for (File file : loc.listFiles()) {
if(file.isDirectory() && new File(file, typeWithExtension).exists()) {
Element xml = cacheManager.get(context, true, loc.getAbsolutePath(), typeWithExtension, file.getName(), file.getName());
String translation = Xml.selectString(xml, key);
if(translation != null && !translation.trim().isEmpty()) {
translations.put(file.getName(), translation);
}
}