Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
fixed great mess with localization paths. the problem was: automatic re-translation after update did not work. hopefully now
orbitera9e73b6852cd
diff --git a/htroot/ConfigBasic.java b/htroot/ConfigBasic.javaindex 2809611e1..3ceae6c73 100644--- a/htroot/ConfigBasic.java+++ b/htroot/ConfigBasic.java@@ -79,8 +79,8 @@ public class ConfigBasic {ConfigBasic config = new ConfigBasic();plasmaSwitchboard sb = (plasmaSwitchboard) env;serverObjects prop = new serverObjects();- String langPath = new File(env.getRootPath(), env.getConfig("langPath", "DATA/LOCALE")).toString();- String lang = env.getConfig("htLocaleSelection", "default");+ String langPath = new File(env.getRootPath(), env.getConfig("locale.work", "DATA/LOCALE/locales")).toString();+ String lang = env.getConfig("locale.language", "default");int authentication = sb.adminAuthenticated(header);if (authentication < 2) {@@ -227,7 +227,7 @@ public class ConfigBasic {prop.put("defaultName", env.getConfig("peerName", ""));prop.put("defaultUser", "admin");prop.put("defaultPort", env.getConfig("port", "8080"));- lang = env.getConfig("htLocaleSelection", "default"); // re-assign lang, may have changed+ lang = env.getConfig("locale.language", "default"); // re-assign lang, may have changedif (lang.equals("default")) {prop.put("langDeutsch", 0);prop.put("langEnglish", 1);diff --git a/htroot/ConfigLanguage_p.java b/htroot/ConfigLanguage_p.javaindex 469e78151..5e5a90853 100644--- a/htroot/ConfigLanguage_p.java+++ b/htroot/ConfigLanguage_p.java@@ -71,7 +71,7 @@ public class ConfigLanguage_p {//listManager.switchboard = (plasmaSwitchboard) env;serverObjects prop = new serverObjects();plasmaSwitchboard switchboard = (plasmaSwitchboard) env;- String langPath = new File(env.getRootPath(), env.getConfig("langPath", "DATA/LOCALE")).toString();+ String langPath = new File(env.getRootPath(), env.getConfig("locale.work", "DATA/LOCALE/locales")).toString();//Fallback//prop.put("currentlang", ""); //is done by Translationtemplate@@ -141,7 +141,7 @@ public class ConfigLanguage_p {langName = (String) langNames.get(langKey);prop.put("langlist_"+(i+1)+"_file", langFiles[i]);prop.put("langlist_"+(i+1)+"_name", ((langName == null) ? langKey : langName));- if(env.getConfig("htLocaleSelection", "default").equals(langKey)) {+ if(env.getConfig("locale.language", "default").equals(langKey)) {prop.put("langlist_"+(i+1)+"_selected", "selected");prop.put("langlist_0_selected", " "); // reset Default} else {@@ -152,7 +152,7 @@ public class ConfigLanguage_p {prop.put("langlist", (i+1));//is done by Translationtemplate- //langName = (String) langNames.get(env.getConfig("htLocaleSelection", "default"));+ //langName = (String) langNames.get(env.getConfig("locale.language", "default"));//prop.put("currentlang", ((langName == null) ? "default" : langName));return prop;}diff --git a/htroot/SettingsAck_p.java b/htroot/SettingsAck_p.javaindex 8c14c6be8..93ae17033 100644--- a/htroot/SettingsAck_p.java+++ b/htroot/SettingsAck_p.java@@ -79,19 +79,6 @@ import de.anomic.yacy.yacySeedUploader;public class SettingsAck_p {private static boolean nothingChanged;-- /*- public static HashMap langMap(serverSwitch env) {- String[] ms = env.getConfig("htLocaleLang", "").split(",");- HashMap map = new HashMap();- int p;- for (int i = 0; i < ms.length; i++) {- p = ms[i].indexOf("/");- if (p > 0) map.put(ms[i].substring(0, p), ms[i].substring(p + 1));- }- return map;- }- */public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {// return variable that accumulates replacementsdiff --git a/htroot/Settings_p.java b/htroot/Settings_p.javaindex 92d1bb580..948e74b74 100644--- a/htroot/Settings_p.java+++ b/htroot/Settings_p.java@@ -105,7 +105,7 @@ public final class Settings_p {prop.put("peerName", env.getConfig("peerName", "nameless"));prop.put("staticIP", env.getConfig("staticIP", ""));- String peerLang = env.getConfig("htLocaleSelection", "default");+ String peerLang = env.getConfig("locale.language", "default");if (peerLang.equals("default")) peerLang = "en";prop.put("peerLang", peerLang);diff --git a/source/de/anomic/data/translator.java b/source/de/anomic/data/translator.javaindex 15f2b36ce..22e9357f3 100644--- a/source/de/anomic/data/translator.java+++ b/source/de/anomic/data/translator.java@@ -10,7 +10,7 @@//// $LastChangedDate$// $LastChangedRevision$-// $LastChangedBy$+// $LastChangedBy: $//// This program is free software; you can redistribute it and/or modify// it under the terms of the GNU General Public License as published by@@ -238,7 +238,7 @@ public class translator {}public static HashMap langMap(serverSwitch env) {- String[] ms = env.getConfig("htLocaleLang", "").split(",");+ String[] ms = env.getConfig("locale.lang", "").split(",");HashMap map = new HashMap();int p;for (int i = 0; i < ms.length; i++) {@@ -251,12 +251,12 @@ public class translator {public static boolean changeLang(serverSwitch env, String langPath, String lang) {if ((lang.equals("default")) || (lang.equals("default.lng"))) {- env.setConfig("htLocaleSelection", "default");+ env.setConfig("locale.language", "default");return true;}String htRootPath = env.getConfig("htRootPath", "htroot");File sourceDir = new File(env.getRootPath(), htRootPath);- File destDir = new File(env.getConfig("htLocalePath","DATA/HTDOCS/locale"), lang.substring(0, lang.length() - 4));// cut+ File destDir = new File(env.getConfig("locale.translated_html","DATA/LOCALE/htroot"), lang.substring(0, lang.length() - 4));// cut// .lng//File destDir = new File(env.getRootPath(), htRootPath + "/locale/" + lang.substring(0, lang.length() - 4));// cut// .lng@@ -265,7 +265,7 @@ public class translator {//if (translator.translateFiles(sourceDir, destDir, translationFile, "html")) {if(translator.translateFilesRecursive(sourceDir, destDir,translationFile, "html,template,inc", "locale")){- env.setConfig("htLocaleSelection", lang.substring(0, lang.length() - 4));+ env.setConfig("locale.language", lang.substring(0, lang.length() - 4));try {BufferedWriter bw = new BufferedWriter(new PrintWriter(new FileWriter(new File(destDir, "version"))));bw.write(env.getConfig("svnRevision", "Error getting Version"));diff --git a/source/de/anomic/http/httpdFileHandler.java b/source/de/anomic/http/httpdFileHandler.javaindex 4da88f6b3..810773ef4 100644--- a/source/de/anomic/http/httpdFileHandler.java+++ b/source/de/anomic/http/httpdFileHandler.java@@ -194,8 +194,7 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http// create htLocaleDefault, htLocalePathif (htDefaultPath == null) htDefaultPath = new File(switchboard.getRootPath(), switchboard.getConfig("htDefaultPath","htroot"));- if (htLocalePath == null) htLocalePath = new File(switchboard.getConfig("htLocalePath","DATA/HTDOCS/locale"));- //htLocaleSelection = switchboard.getConfig("htLocaleSelection","default");+ if (htLocalePath == null) htLocalePath = new File(switchboard.getConfig("locale.translated_html","DATA/LOCALE/htroot"));}}@@ -206,18 +205,18 @@ public final class httpdFileHandler extends httpdAbstractHandler implements httpif (defaultFiles.length == 0) defaultFiles = new String[] {"index.html"};}- /** Returns a path to the localized or default file according to the htLocaleSelection (from he switchboard)+ /** Returns a path to the localized or default file according to the locale.language (from he switchboard)* @param path relative from htroot */public static File getLocalizedFile(String path){- return getLocalizedFile(path, switchboard.getConfig("htLocaleSelection","default"));+ return getLocalizedFile(path, switchboard.getConfig("locale.language","default"));}/** Returns a path to the localized or default file according to the parameter localeSelection* @param path relative from htroot- * @param localeSelection language of localized file; htLocaleSelection from switchboard is used if localeSelection.equals("") */+ * @param localeSelection language of localized file; locale.language from switchboard is used if localeSelection.equals("") */public static File getLocalizedFile(String path, String localeSelection){if (htDefaultPath == null) htDefaultPath = new File(switchboard.getRootPath(), switchboard.getConfig("htDefaultPath","htroot"));- if (htLocalePath == null) htLocalePath = new File(switchboard.getRootPath(), switchboard.getConfig("htLocalePath","htroot/locale"));+ if (htLocalePath == null) htLocalePath = new File(switchboard.getRootPath(), switchboard.getConfig("locale.translated_html","DATA/LOCALE/htroot"));if (!(localeSelection.equals("default"))) {File localePath = new File(htLocalePath, localeSelection + "/" + path);@@ -423,8 +422,8 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http// locate the fileif (!(path.startsWith("/"))) path = "/" + path; // attach leading slash- // a different language can be desired (by i.e. ConfigBasic.html) than the one stored in the htLocaleSelection- String localeSelection = switchboard.getConfig("htLocaleSelection","default");+ // a different language can be desired (by i.e. ConfigBasic.html) than the one stored in the locale.language+ String localeSelection = switchboard.getConfig("locale.language","default");if (args != null && (args.containsKey("language"))){// TODO 9.11.06 Bost: a class with information about available languages is needed.diff --git a/source/migration.java b/source/migration.javaindex 03b4d1787..e8994a492 100644--- a/source/migration.java+++ b/source/migration.java@@ -226,8 +226,8 @@ public class migration {sb.setConfig("parseableMimeTypes.ICAP", value);}//Locales in DATA, because DATA must be writable, htroot not.- if(sb.getConfig("htLocalePath", "htroot/locale").equals("htroot/locale")){- sb.setConfig("htLocalePath", "DATA/HTDOCS/locale");+ if(sb.getConfig("locale.translated_html", "DATA/LOCALE/htroot").equals("htroot/locale")){+ sb.setConfig("locale.translated_html", "DATA/LOCALE/htroot");}// migration for port forwarding settingsdiff --git a/source/yacy.java b/source/yacy.javaindex 6846dfdcc..e979d2e62 100644--- a/source/yacy.java+++ b/source/yacy.java@@ -383,50 +383,47 @@ public final class yacy {serverSystem.openBrowser((server.withSSL()?"https":"http") + "://localhost:" + serverCore.getPortNr(port) + "/" + browserPopUpPage, browserPopUpApplication);}- //Copy the shipped locales into DATA- final File localesPath = new File(homePath, sb.getConfig("localesPath", "DATA/LOCALE"));- final File defaultLocalesPath = new File(homePath, "locales");--+ // Copy the shipped locales into DATA, existing files are overwritten+ final File locale_work = new File(homePath, sb.getConfig("locale.work", "DATA/LOCALE/locales"));+ final File locale_source = new File(homePath, sb.getConfig("locale.source", "locales"));try{- final File[] defaultLocales = defaultLocalesPath.listFiles();- localesPath.mkdirs();- for(int i=0;i < defaultLocales.length; i++){- if(defaultLocales[i].getName().endsWith(".lng"))- serverFileUtils.copy(defaultLocales[i], new File(localesPath, defaultLocales[i].getName()));+ final File[] locale_source_files = locale_source.listFiles();+ locale_work.mkdirs();+ File target;+ for (int i=0; i < locale_source_files.length; i++){+ target = new File(locale_work, locale_source_files[i].getName());+ if (locale_source_files[i].getName().endsWith(".lng")) {+ if (target.exists()) target.delete();+ serverFileUtils.copy(locale_source_files[i], target);+ }}- serverLog.logInfo("STARTUP", "Copied the default locales to DATA/LOCALE");+ serverLog.logInfo("STARTUP", "Copied the default locales to " + locale_work.toString());}catch(NullPointerException e){serverLog.logSevere("STARTUP", "Nullpointer Exception while copying the default Locales");}//regenerate Locales from Translationlist, if needed- final String lang = sb.getConfig("htLocaleSelection", "");- if(! lang.equals("") && ! lang.equals("default") ){ //locale is used+ final String lang = sb.getConfig("locale.language", "");+ if (!lang.equals("") && !lang.equals("default")) { //locale is usedString currentRev = "";try{- final BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File( sb.getConfig("htLocalePath", "DATA/HTDOCS/locale"), lang+"/version" ))));+ final BufferedReader br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(sb.getConfig("locale.translated_html", "DATA/LOCALE/htroot"), lang+"/version" ))));currentRev = br.readLine();br.close();}catch(IOException e){//Error}- try{ //seperate try, because we want this, even if the file "version" does not exist.- if(! currentRev.equals(sb.getConfig("svnRevision", "")) ){ //is this another version?!- final File sourceDir = new File(sb.getConfig("htRootPath", "htroot"));- final File destDir = new File(sb.getConfig("htLocalePath", "DATA/HTDOCS/locale"), lang);-- if(translator.translateFilesRecursive(sourceDir, destDir, new File("DATA/LOCALE/"+lang+".lng"), "html,template,inc", "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"));- bw.close();- }+ if (!currentRev.equals(sb.getConfig("svnRevision", ""))) try { //is this another version?!+ final File sourceDir = new File(sb.getConfig("htRootPath", "htroot"));+ final File destDir = new File(sb.getConfig("locale.translated_html", "DATA/LOCALE/htroot"), lang);+ if (translator.translateFilesRecursive(sourceDir, destDir, new File(locale_work, lang + ".lng"), "html,template,inc", "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"));+ bw.close();}- }catch(IOException e){- //Error- }+ } catch (IOException e) {}}// registering shutdown hookdiff --git a/yacy.init b/yacy.initindex 88bdf96e2..d4453f55b 100644--- a/yacy.init+++ b/yacy.init@@ -116,6 +116,10 @@ httpdMinIdleSessions = 5htRootPath = htroothtTemplatePath = htroot/env/templates+# the htroot path+# root path for the httpd file server+htDefaultPath=htroot+# individual htroot folder# every user may publicise her/his own web pages# these pages shall be placed in the path defined here@@ -133,10 +137,11 @@ defaultFiles = ConfigBasic.html,index.html,default.html,search.html,console.html# The htLocaleLang defines a list of language options as <dir>/<named-language># the <dir> must exist as sub-path to htLocalePath# the htLocaleSelection selects from the given locales, value=one-of-<dir>-htDefaultPath=htroot-htLocalePath=DATA/HTROOT/locale-htLocaleLang=default/English,de/Deutsch,fr/Français,nl/Nederlands,it/Italiano,es/Español,pt/Portugês,fi/Suomi,se/Svenska,dk/Dansk,gr/Eλληvικα,sk/Slovensky-htLocaleSelection=default+locale.source=locales+locale.work=DATA/LOCALE/locales+locale.translated_html=DATA/LOCALE/htroot+locale.lang=default/English,de/Deutsch,fr/Français,nl/Nederlands,it/Italiano,es/Español,pt/Portugês,fi/Suomi,se/Svenska,dk/Dansk,gr/Eλληvικα,sk/Slovensky+locale.language=default# virtual host for httpdFileServlet access# for example http://<fileHost>/ shall access the file servlet and