Translationfile Division for different files

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@411 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
allo 20 years ago
parent 25a7d4c982
commit e6c381a2e2

@ -76,8 +76,9 @@ public class translator {
return result; return result;
} }
public static Hashtable loadTranslationsList(File translationFile){ public static Hashtable loadTranslationsLists(File translationFile){
Hashtable translationList = new Hashtable(); Hashtable lists = new Hashtable(); //list of translationLists for different files.
Hashtable translationList = new Hashtable(); //current Translation Table
FileInputStream fileIn = null; FileInputStream fileIn = null;
Vector list = listManager.getListArray(translationFile); Vector list = listManager.getListArray(translationFile);
@ -85,6 +86,7 @@ public class translator {
String line = ""; String line = "";
String value = ""; String value = "";
String[] splitted; String[] splitted;
String forFile="";
while(it.hasNext()){ while(it.hasNext()){
line = (String)it.next(); line = (String)it.next();
@ -100,12 +102,18 @@ public class translator {
translationList.put(splitted[0], value); translationList.put(splitted[0], value);
}else{ //Invalid line }else{ //Invalid line
} }
}else if(line.startsWith("#File: ")){
if(forFile != ""){
lists.put(forFile, translationList);
}
forFile=line.substring(7);
translationList=new Hashtable();
} }
} }
return translationList; return lists;
} }
public static boolean translateFile(File sourceFile, File destFile, File translationFile){ public static boolean translateFile(File sourceFile, File destFile, File translationFile){
Hashtable translationList = loadTranslationsList(translationFile); Hashtable translationList = (Hashtable)loadTranslationsLists(translationFile).get(sourceFile.getName());
return translateFile(sourceFile, destFile, translationList); return translateFile(sourceFile, destFile, translationList);
} }
@ -142,20 +150,24 @@ public class translator {
} }
public static boolean translateFiles(File sourceDir, File destDir, File translationFile, String extension){ public static boolean translateFiles(File sourceDir, File destDir, File translationFile, String extension){
Hashtable translationList = loadTranslationsList(translationFile); Hashtable translationLists = loadTranslationsLists(translationFile);
return translateFiles(sourceDir, destDir, translationList, extension); return translateFiles(sourceDir, destDir, translationLists, extension);
} }
public static boolean translateFiles(File sourceDir, File destDir, Hashtable translationList, String extension){ public static boolean translateFiles(File sourceDir, File destDir, Hashtable translationLists, String extension){
destDir.mkdirs(); destDir.mkdirs();
File[] sourceFiles = sourceDir.listFiles(); File[] sourceFiles = sourceDir.listFiles();
for(int i=0;i<sourceFiles.length;i++){ for(int i=0;i<sourceFiles.length;i++){
if(sourceFiles[i].getName().endsWith(extension)){ if(sourceFiles[i].getName().endsWith(extension)){
if(translateFile(sourceFiles[i], new File(destDir, sourceFiles[i].getName()), translationList)){ if(translationLists.containsKey(sourceFiles[i].getName())){
serverLog.logInfo("Translator", "Translated File: "+ sourceFiles[i].getName()); if(translateFile(sourceFiles[i], new File(destDir, sourceFiles[i].getName()), (Hashtable)translationLists.get(sourceFiles[i].getName()))){
serverLog.logInfo("Translator", "Translated File: "+ sourceFiles[i].getName());
}else{
serverLog.logError("Translator", "File Error while translating File "+sourceFiles[i].getName());
}
}else{ }else{
serverLog.logError("Translator", "File Error while translating File "+sourceFiles[i].getName()); serverLog.logInfo("Translator", "No translation for file: "+sourceFiles[i].getName());
} }
} }

Loading…
Cancel
Save