diff --git a/defaults/yacy.init b/defaults/yacy.init
index 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
must exist as sub-path to htLocalePath
# the htLocaleSelection selects from the given locales, value=one-of-
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
diff --git a/htroot/ConfigBasic.java b/htroot/ConfigBasic.java
index a29bf0010..e13636f8c 100644
--- a/htroot/ConfigBasic.java
+++ b/htroot/ConfigBasic.java
@@ -61,7 +61,7 @@ public class ConfigBasic {
// return variable that accumulates replacements
final 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.java
index 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 Translationtemplate
prop.put("status", "0");//nothing
- List langFiles = FileUtils.getDirListing(langPath, LANG_FILENAME_FILTER);
+ List 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 langNames = Translator.langMap(env);
diff --git a/source/de/anomic/data/Translator.java b/source/de/anomic/data/Translator.java
index 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 translationTable){
final Set keys = translationTable.keySet();
String result = source;
@@ -215,7 +217,7 @@ public class Translator {
}
public static Map 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 map = new HashMap();
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 langFiles(File langPath) {
+ return FileUtils.getDirListing(langPath, Translator.LANG_FILENAME_FILTER);
+ }
}
diff --git a/source/net/yacy/yacy.java b/source/net/yacy/yacy.java
index 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 popup
Tray.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 used
String 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 Versionnumber
final BufferedWriter bw = new BufferedWriter(new PrintWriter(new FileWriter(new File(destDir, "version"))));
bw.write(sb.getConfig("svnRevision", "Error getting Version"));