recursive Translations!

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@1341 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
allo 19 years ago
parent 7f1192498a
commit fe2d983c3e

@ -89,9 +89,9 @@ public class Language_p {
// .lng
File translationFile = new File(langPath, lang);
if (translator.translateFiles(sourceDir, destDir, translationFile, "html")) {
// if(translator.translateFilesRecursive(sourceDir, destDir,
// translationFile, "html")){
//if (translator.translateFiles(sourceDir, destDir, translationFile, "html")) {
if(translator.translateFilesRecursive(sourceDir, destDir,
translationFile, "html,template", "locale")){
env.setConfig("htLocaleSelection", lang.substring(0, lang.length() - 4));
try {
BufferedWriter bw = new BufferedWriter(new PrintWriter(new FileWriter(new File(destDir, "version"))));

@ -1176,7 +1176,7 @@ Network==Netzwerk
#Log==Log
Settings==Einstellungen
#Performance==Performance
Language==Sprache
>Language==>Sprache
#Skins==Skins
Project Home==Pojektseite
Project News==Neuigkeiten

@ -55,6 +55,7 @@ import java.util.ArrayList;
import java.util.Enumeration;
import java.util.Hashtable;
import java.util.Iterator;
import java.util.Vector;
import de.anomic.server.logging.serverLog;
import de.anomic.data.listManager;
@ -154,18 +155,28 @@ public class translator {
return true;
}
public static boolean translateFiles(File sourceDir, File destDir, File translationFile, String extension){
public static boolean translateFiles(File sourceDir, File destDir, File translationFile, String extensions){
Hashtable translationLists = loadTranslationsLists(translationFile);
return translateFiles(sourceDir, destDir, translationLists, extension);
return translateFiles(sourceDir, destDir, translationLists, extensions);
}
public static boolean translateFiles(File sourceDir, File destDir, Hashtable translationLists, String extension){
public static boolean translateFiles(File sourceDir, File destDir, Hashtable translationLists, String extensions){
destDir.mkdirs();
File[] sourceFiles = sourceDir.listFiles();
Vector exts=listManager.string2vector(extensions);
boolean rightExtension;
Iterator it;
for(int i=0;i<sourceFiles.length;i++){
if(sourceFiles[i].getName().endsWith(extension)){
if(translationLists.containsKey(sourceFiles[i].getName())){
it=exts.iterator();
rightExtension=false;
while(it.hasNext()){
if(sourceFiles[i].getName().endsWith((String) it.next())){
rightExtension=true;
break;
}
}
if(rightExtension){
if(translationLists.containsKey(sourceFiles[i].getName())){ //TODO: relative Path to htroot
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{
@ -180,17 +191,24 @@ public class translator {
return true;
}
public static boolean translateFilesRecursive(File sourceDir, File destDir, File translationFile, String extension){
public static boolean translateFilesRecursive(File sourceDir, File destDir, File translationFile, String extensions, String notdir){
ArrayList dirList=listManager.getDirsRecursive(sourceDir);
dirList.add(sourceDir);
Iterator it=dirList.iterator();
String sourceName=sourceDir.getPath();
String destName=destDir.getPath();
File dir=null;
File dir2=null;
File file=null;
File file2=null;
while(it.hasNext()){
dir=(File)it.next();
dir2=new File(dir.getPath().replaceFirst(sourceName.replaceAll("\\\\", "\\\\"), destName));
translateFiles(dir, dir2, translationFile, extension);
file=(File)it.next();
//cuts the sourcePath and prepends the destPath
file2=new File(destDir, file.getPath().substring(sourceDir.getPath().length(), file.getPath().length()));
//file2=new File(file.getPath().replaceFirst(sourceName.replaceAll("\\\\", "\\\\"), destName));
if(file.isDirectory() && !file.getName().equals(notdir)){
//file2.mkdirs();
translateFiles(file, file2, translationFile, extensions);
//translateFilesRecursive(file, file2, translationFile, extension, notdir);
}/*else{
translateFiles(file, file2, translationFile, extension);
}*/
}
return true;
}

@ -439,8 +439,8 @@ public final class yacy {
if(! currentRev.equals(sb.getConfig("svnRevision", "")) ){ //is this another version?!
final File sourceDir = new File(sb.getConfig("htRootPath", "htroot"));
final File destDir = new File(sourceDir, "locale/"+lang);
if(translator.translateFiles(sourceDir, destDir, new File("DATA/LOCALE/"+lang+".lng"), "html")){ //translate it
//if(translator.translateFilesRecursive(sourceDir, destDir, new File("DATA/LOCALE/"+lang+".lng"), "html")){ //translate it
if(translator.translateFilesRecursive(sourceDir, destDir, new File("DATA/LOCALE/"+lang+".lng"), "html,template", "locale")){ //translate it
//write the new Versionnumber
final BufferedWriter bw = new BufferedWriter(new PrintWriter(new FileWriter(new File(destDir, "version"))));
bw.write(sb.getConfig("svnRevision", "Error getting Version"));

Loading…
Cancel
Save