Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
translator updates: - config string for chinese - do not copy the language file to DATA/LOCALE any more (and do not use them there, this is really confusing for new translators)
Michael Christen17f962fceb24
diff --git a/defaults/yacy.init b/defaults/yacy.initindex c233ebadb..dcb81f7de 100644--- a/defaults/yacy.init+++ b/defaults/yacy.init@@ -223,9 +223,7 @@ defaultFiles = index.html,index.htm,default.html,search.html,console.html,contro# the <dir> must exist as sub-path to htLocalePath# the htLocaleSelection selects from the given locales, value=one-of-<dir>locale.source=locales-locale.work=DATA/LOCALE/localeslocale.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/Slovenskylocale.language=default# virtual host for httpdFileServlet accessdiff --git a/htroot/ConfigBasic.java b/htroot/ConfigBasic.javaindex a29bf0010..e13636f8c 100644--- a/htroot/ConfigBasic.java+++ b/htroot/ConfigBasic.java@@ -61,7 +61,7 @@ public class ConfigBasic {// return variable that accumulates replacementsfinal Switchboard sb = (Switchboard) env;final serverObjects prop = new serverObjects();- final String langPath = env.getDataPath("locale.work", "DATA/LOCALE/locales").getAbsolutePath();+ final File langPath = new File(sb.getAppPath("locale.source", "locales").getAbsolutePath());String lang = env.getConfig("locale.language", "default");final int authentication = sb.adminAuthenticated(header);diff --git a/htroot/ConfigLanguage_p.java b/htroot/ConfigLanguage_p.javaindex 757bf44d2..d4c2126b2 100644--- a/htroot/ConfigLanguage_p.java+++ b/htroot/ConfigLanguage_p.java@@ -34,37 +34,35 @@ import java.io.File;import java.io.FileWriter;import java.io.IOException;import java.io.PrintWriter;+import java.util.Collections;import java.util.Iterator;import java.util.List;+import java.util.Map;import net.yacy.cora.protocol.ClientIdentification;import net.yacy.cora.protocol.RequestHeader;import net.yacy.kelondro.data.meta.DigestURI;import net.yacy.kelondro.util.FileUtils;import net.yacy.search.Switchboard;--import de.anomic.data.WorkTables;import de.anomic.data.Translator;+import de.anomic.data.WorkTables;import de.anomic.server.serverObjects;import de.anomic.server.serverSwitch;-import java.util.Collections;-import java.util.Map;public class ConfigLanguage_p {- private final static String LANG_FILENAME_FILTER = "^.*\\.lng$";-public static serverObjects respond(final RequestHeader header, final serverObjects post, final serverSwitch env) {final serverObjects prop = new serverObjects();- final String langPath = env.getDataPath("locale.work", "DATA/LOCALE/locales").getAbsolutePath();+ Switchboard sb = (Switchboard) env;+ final File langPath = new File(sb.getAppPath("locale.source", "locales").getAbsolutePath());//Fallback//prop.put("currentlang", ""); //is done by Translationtemplateprop.put("status", "0");//nothing- List<String> langFiles = FileUtils.getDirListing(langPath, LANG_FILENAME_FILTER);+ List<String> langFiles = Translator.langFiles(langPath);if (langFiles == null) {return prop;}@@ -128,7 +126,7 @@ public class ConfigLanguage_p {}//re-read language files- langFiles = FileUtils.getDirListing(langPath, LANG_FILENAME_FILTER);+ langFiles = Translator.langFiles(langPath);Collections.sort(langFiles);final Map<String, String> langNames = Translator.langMap(env);diff --git a/source/de/anomic/data/Translator.java b/source/de/anomic/data/Translator.javaindex ae449c95a..15c16052d 100644--- a/source/de/anomic/data/Translator.java+++ b/source/de/anomic/data/Translator.java@@ -40,17 +40,16 @@ import java.io.InputStreamReader;import java.io.OutputStreamWriter;import java.io.PrintWriter;import java.util.HashMap;+import java.util.List;+import java.util.Map;+import java.util.Set;import java.util.regex.Matcher;import java.util.regex.Pattern;import net.yacy.kelondro.logging.Log;import net.yacy.kelondro.util.FileUtils;import net.yacy.kelondro.util.Formatter;-import de.anomic.server.serverSwitch;-import java.util.List;-import java.util.Map;-import java.util.Set;/*** Wordlist based translator@@ -58,6 +57,9 @@ import java.util.Set;* Uses a Property like file with phrases or single words to translate a string or a file* */public class Translator {++ public final static String LANG_FILENAME_FILTER = "^.*\\.lng$";+public static String translate(final String source, final Map<String, String> translationTable){final Set<String> keys = translationTable.keySet();String result = source;@@ -215,7 +217,7 @@ public class Translator {}public static Map<String, String> langMap(final serverSwitch env) {- final String[] ms = env.getConfig("locale.lang", "").split(",");+ final String[] ms = "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,cn/汉语/漢語".split(",");final Map<String, String> map = new HashMap<String, String>();for (final String element : ms) {int p = element.indexOf('/');@@ -225,7 +227,7 @@ public class Translator {return map;}- public static boolean changeLang(final serverSwitch env, final String langPath, final String lang) {+ public static boolean changeLang(final serverSwitch env, final File langPath, final String lang) {boolean ret = false;if ("default".equals(lang) || "default.lng".equals(lang)) {@@ -256,4 +258,8 @@ public class Translator {}return ret;}++ public static List<String> langFiles(File langPath) {+ return FileUtils.getDirListing(langPath, Translator.LANG_FILENAME_FILTER);+ }}diff --git a/source/net/yacy/yacy.java b/source/net/yacy/yacy.javaindex bc875f7c7..4d6e2521f 100644--- a/source/net/yacy/yacy.java+++ b/source/net/yacy/yacy.java@@ -323,26 +323,8 @@ public final class yacy {// unlock yacyTray browser popupTray.lockBrowserPopup = false;- // Copy the shipped locales into DATA, existing files are overwritten- final File locale_work = sb.getDataPath("locale.work", "DATA/LOCALE/locales");- final File locale_source = sb.getAppPath("locale.source", "locales");- try{- final File[] locale_source_files = locale_source.listFiles();- mkdirsIfNeseccary(locale_work);- File target;- for (final File locale_source_file : locale_source_files) {- target = new File(locale_work, locale_source_file.getName());- if (locale_source_file.getName().endsWith(".lng")) {- if (target.exists()) delete(target);- FileUtils.copy(locale_source_file, target);- }- }- Log.logInfo("STARTUP", "Copied the default locales to " + locale_work.toString());- }catch(final NullPointerException e){- Log.logSevere("STARTUP", "Nullpointer Exception while copying the default Locales");- }-//regenerate Locales from Translationlist, if needed+ final File locale_source = sb.getAppPath("locale.source", "locales");final String lang = sb.getConfig("locale.language", "");if (!lang.equals("") && !lang.equals("default")) { //locale is usedString currentRev = "";@@ -357,7 +339,7 @@ public final class yacy {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.getDataPath("locale.translated_html", "DATA/LOCALE/htroot"), lang);- if (Translator.translateFilesRecursive(sourceDir, destDir, new File(locale_work, lang + ".lng"), "html,template,inc", "locale")){ //translate it+ if (Translator.translateFilesRecursive(sourceDir, destDir, new File(locale_source, lang + ".lng"), "html,template,inc", "locale")){ //translate it//write the new Versionnumberfinal BufferedWriter bw = new BufferedWriter(new PrintWriter(new FileWriter(new File(destDir, "version"))));bw.write(sb.getConfig("svnRevision", "Error getting Version"));