Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
Automatic regeneration of Locales on Restart with a new (SVN) Version
allo829096915083
diff --git a/htroot/Language_p.java b/htroot/Language_p.javaindex dda5cf7e0..1accd7f0f 100644--- a/htroot/Language_p.java+++ b/htroot/Language_p.java@@ -95,8 +95,9 @@ public class Language_p {env.setConfig("htLocaleSelection", "default");return true;}else{- File sourceDir = new File(env.getRootPath(), "htroot");- File destDir = new File(env.getRootPath(), "htroot/locale/"+lang.substring(0,lang.length()-4));//cut .lng+ String htRootPath = env.getConfig("htRootPath", "htroot");+ File sourceDir = new File(env.getRootPath(), htRootPath);+ File destDir = new File(env.getRootPath(), htRootPath + "/locale/"+lang.substring(0,lang.length()-4));//cut .lngFile translationFile = new File(langPath, lang);if(translator.translateFiles(sourceDir, destDir, translationFile, "html")){diff --git a/source/yacy.java b/source/yacy.javaindex 2963bb889..2f48d1015 100644--- a/source/yacy.java+++ b/source/yacy.java@@ -64,6 +64,9 @@*/+import java.io.BufferedReader;+import java.io.InputStreamReader;+import java.io.FileInputStream;import java.io.BufferedReader;import java.io.BufferedWriter;import java.io.ByteArrayOutputStream;@@ -104,6 +107,7 @@ import de.anomic.server.serverSystem;import de.anomic.server.logging.serverLog;import de.anomic.tools.enumerateFiles;import de.anomic.yacy.yacyCore;+import de.anomic.data.translator;public final class yacy {@@ -319,6 +323,34 @@ public final class yacy {}catch(NullPointerException e){serverLog.logError("STARTUP", "Nullpointer Exception while copying the default Locales");}++ //regenerate Locales from Translationlist, if needed+ String lang = sb.getConfig("htLocaleSelection", "");+ if(! lang.equals("") && ! lang.equals("default") ){ //locale is used+ String currentRev = "";+ try{+ BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File( sb.getConfig("htRootPath", "htroot"), "locale/"+lang+"/version" ))));+ currentRev = br.readLine();+ br.close();+ }catch(IOException e){+ //Error+ }++ try{ //seperate try, because we want this, even when the File "version2 does not exist.+ if(! currentRev.equals(sb.getConfig("svnRevision", "")) ){ //is this another version?!+ File sourceDir = new File(sb.getConfig("htRootPath", "htroot"));+ File destDir = new File(sourceDir, "locale/"+lang);+ if(translator.translateFiles(sourceDir, destDir, new File("DATA/LOCALE/"+lang+".lng"), "html")){ //translate it+ //write the new Versionnumber+ BufferedWriter bw = new BufferedWriter(new PrintWriter(new FileWriter(new File(destDir, "version"))));+ bw.write(sb.getConfig("svnRevision", "Error getting Version"));+ bw.close();+ }+ }+ }catch(IOException e){+ //Error+ }+ }// registering shutdown hookserverLog.logSystem("STARTUP", "Registering Shutdown Hook");