Distributed Peer-to-Peer Web Search Engine and Intranet Search Appliance
Java decentralizedintranet-searchintranet-search-enginep2pp2p-networkprivacyprivacy-protectionsearch-enginesearchenginewebweb-search-enginewebsearchwebseearch-engine
better Translationsystem. You only need to escape Chars, which have special meanings in regexps. some you have to escape: ()[]{}
allobef3aaec381d
diff --git a/htroot/Language_p.html b/htroot/Language_p.htmlindex 53705e376..2544d0531 100644--- a/htroot/Language_p.html+++ b/htroot/Language_p.html@@ -10,8 +10,10 @@<h2>Language selection</h2><p>You can change the language of YaCy with translation files.+<br>-<b>Current language: #[currentlang]#</b>+<b>Current language:</b> <!-- lang -->default(english)<br>+<b>Languagefile Author:</b> <!-- author --><br><p><form action="Language_p.html">diff --git a/htroot/Language_p.java b/htroot/Language_p.javaindex a4c31ffbd..a3e84d295 100644--- a/htroot/Language_p.java+++ b/htroot/Language_p.java@@ -114,7 +114,7 @@ public class Language_p {String langPath = new File(env.getRootPath(), env.getConfig("langPath", "DATA/LOCALE")).toString();//Fallback- prop.put("currentlang", "");+ //prop.put("currentlang", ""); //is done by Translationtemplateprop.put("status", 0);//nothingString[] langFiles = listManager.getDirListing(langPath);@@ -184,8 +184,9 @@ public class Language_p {}prop.put("langlist", (i+1));- langName = (String) langNames.get(env.getConfig("htLocaleSelection", "default"));- prop.put("currentlang", ((langName == null) ? "default" : langName));+ //is done by Translationtemplate+ //langName = (String) langNames.get(env.getConfig("htLocaleSelection", "default"));+ //prop.put("currentlang", ((langName == null) ? "default" : langName));return prop;}diff --git a/locales/de.lng b/locales/de.lngindex 05633552e..0eb81e2bb 100644--- a/locales/de.lng+++ b/locales/de.lng@@ -1,40 +1,44 @@#English=German+<!-- lang -->default\(english\)=Deutsch+<!-- author -->=�bersetzer eintragen#-----------------------------------------------------------#index.html-P2P\ WEB\ SEARCH=P2P Web-Suche+P2P WEB SEARCH=P2P Web-Suche#only the Button"Search"="Suchen"-Enter\ search\ word\ list,\ separated\ by\ space\:=Geben Sie hier die Suchworte getrennt durch Leerzeichen ein:-Max.\ number\ of\ results\:=Max. Anzahl Ergebnisse:-order\ by\:=sortiert nach:+Enter search word list, separated by space:=Geben Sie hier die Suchworte getrennt durch Leerzeichen ein:+Max. number of results:=Max. Anzahl Ergebnisse:+order by:=sortiert nach:# ">" to avoid replacing value=>Quality-Date=>Qualität-Datum>Date-Quality=>Datum-Qualität-Resource\:=Quelle:-Max.\ search\ time=Max. Suchzeit-seconds=Sekunden+Resource:=Quelle:+Max. search time \(seconds\)=Max. Suchzeit (Sekunden)"URL mask":=URL-Maske#-------------------------------------------------------#IndexCreate_p.html-Index\ Creation=Index Erzeugung-You\ can\ define\ url's\ as\ start\ points\ for\ Web\ page\ crawling\ and\ start\ that\ crawling\ here\.=Du kannst hier URLs angeben, die gecrawlt werden sollen und dann das Crawling starten.+Index Creation=Index Erzeugung+You can define url's as start points for Web page crawling and start that crawling here.=Du kannst hier URLs angeben, die gecrawlt werden sollen und dann das Crawling starten.#-------------------------------------------------------#Status.html++#Das passt hier, aber wenn wo anders Protection steht eher nicht..,Protection=Sicherheit-Welcome\ to\ YaCy\!=Willkommen bei YaCy!-System\ version=Systemversion-Proxy\ host=Proxy Host-Remote\ proxy=Zweiter Proxy-This\ peer's\ address=Adresse dieses Peers-This\ peer's\ name=Name dieses Peers-This\ peer's\ statistics= Statistik dieses Peers-This\ peer's\ status=Status dieses Peers-Other\ peers=Andere Peers-Seed\ server=Seed Server-Auto-popup\ on\ start-up=Popup bei YaCy-Start-Online-mode=Onlinemodus\ No newline at end of file++Welcome to YaCy!=Willkommen bei YaCy!+System version=Systemversion+Proxy host=Proxy Host+Remote proxy=Zweiter Proxy+This peer's address=Adresse dieses Peers+This peer's name=Name dieses Peers+This peer's statistics= Statistik dieses Peers+This peer's status=Status dieses Peers+Other peers=Andere Peers+Seed server=Seed Server+Auto-popup on start-up=Popup bei YaCy-Start+Online-mode=Onlinemodusdiff --git a/source/de/anomic/data/translator.java b/source/de/anomic/data/translator.javaindex 07927f706..7b38bc72a 100644--- a/source/de/anomic/data/translator.java+++ b/source/de/anomic/data/translator.java@@ -52,43 +52,66 @@ import java.io.InputStreamReader;import java.io.BufferedWriter;import java.io.FileWriter;import java.io.IOException;-import java.util.Properties;+import java.util.Hashtable;import java.util.Enumeration;+import java.util.Iterator;+import java.util.Vector;import de.anomic.server.logging.serverLog;+import de.anomic.data.listManager;/*** Wordlist based translator*- * Uses a Property file with phrases or single words to translate a string or a file+ * Uses a Property like file with phrases or single words to translate a string or a file* */public class translator {- public static String translate(String source, Properties translationList){- Enumeration keys = translationList.propertyNames();+ public static String translate(String source, Hashtable translationList){+ Enumeration keys = translationList.keys();String result = source;String key = "";while(keys.hasMoreElements()){key = (String)keys.nextElement();- result = result.replaceAll(key, translationList.getProperty(key));+ result = result.replaceAll(key, (String)translationList.get(key));//System.out.println("Replaced \""+key+"\" by \""+translationList.getProperty(key)+"\""); //DEBUG}return result;}- public static boolean translateFile(File sourceFile, File destFile, File translationFile){- Properties translationList = new Properties();+ public static Hashtable loadTranslationsList(File translationFile){+ Hashtable translationList = new Hashtable();FileInputStream fileIn = null;- try{- translationList.load(fileIn = new FileInputStream(translationFile));- return translateFile(sourceFile, destFile, translationList);- }catch(IOException e){- return false;- } finally {- if (fileIn!=null)try{fileIn.close();}catch(Exception e){}- }++ Vector list = listManager.getListArray(translationFile);+ Iterator it = list.iterator();+ String line = "";+ String value = "";+ String[] splitted;++ while(it.hasNext()){+ line = (String)it.next();+ if(! line.startsWith("#")){+ splitted = line.split("=");+ if(splitted.length == 2){+ translationList.put(splitted[0], splitted[1]);+ }else if(splitted.length > 2){+ value = "";+ for(int i = splitted.length-1;i>=1;i--){+ value += splitted[i];+ }+ translationList.put(splitted[0], value);+ }else{ //Invalid line+ }+ }+ }+ return translationList;+ }+ public static boolean translateFile(File sourceFile, File destFile, File translationFile){+ Hashtable translationList = loadTranslationsList(translationFile);+ return translateFile(sourceFile, destFile, translationList);}- public static boolean translateFile(File sourceFile, File destFile, Properties translationList){+ public static boolean translateFile(File sourceFile, File destFile, Hashtable translationList){String content = "";String line = "";@@ -121,19 +144,11 @@ public class translator {}public static boolean translateFiles(File sourceDir, File destDir, File translationFile, String extension){- Properties translationList = new Properties();- FileInputStream fileIn = null;- try{- translationList.load(fileIn = new FileInputStream(translationFile));+ Hashtable translationList = loadTranslationsList(translationFile);return translateFiles(sourceDir, destDir, translationList, extension);- }catch(IOException e){- return false;- } finally {- if (fileIn!=null)try{fileIn.close();}catch(Exception e){}- }}- public static boolean translateFiles(File sourceDir, File destDir, Properties translationList, String extension){+ public static boolean translateFiles(File sourceDir, File destDir, Hashtable translationList, String extension){destDir.mkdirs();File[] sourceFiles = sourceDir.listFiles();for(int i=0;i<sourceFiles.length;i++){