fixed great mess with localization paths. the problem was:

automatic re-translation after update did not work. hopefully now

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@3952 6c8d7289-2bf4-0310-a012-ef5d649a1542
This commit is contained in:
orbiter 2007-07-04 10:32:30 +00:00
parent 53266e6497
commit a9e73b6852
9 changed files with 55 additions and 67 deletions

View File

@ -79,8 +79,8 @@ public class ConfigBasic {
ConfigBasic config = new ConfigBasic(); ConfigBasic config = new ConfigBasic();
plasmaSwitchboard sb = (plasmaSwitchboard) env; plasmaSwitchboard sb = (plasmaSwitchboard) env;
serverObjects prop = new serverObjects(); serverObjects prop = new serverObjects();
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();
String lang = env.getConfig("htLocaleSelection", "default"); String lang = env.getConfig("locale.language", "default");
int authentication = sb.adminAuthenticated(header); int authentication = sb.adminAuthenticated(header);
if (authentication < 2) { if (authentication < 2) {
@ -227,7 +227,7 @@ public class ConfigBasic {
prop.put("defaultName", env.getConfig("peerName", "")); prop.put("defaultName", env.getConfig("peerName", ""));
prop.put("defaultUser", "admin"); prop.put("defaultUser", "admin");
prop.put("defaultPort", env.getConfig("port", "8080")); 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 changed
if (lang.equals("default")) { if (lang.equals("default")) {
prop.put("langDeutsch", 0); prop.put("langDeutsch", 0);
prop.put("langEnglish", 1); prop.put("langEnglish", 1);

View File

@ -71,7 +71,7 @@ public class ConfigLanguage_p {
//listManager.switchboard = (plasmaSwitchboard) env; //listManager.switchboard = (plasmaSwitchboard) env;
serverObjects prop = new serverObjects(); serverObjects prop = new serverObjects();
plasmaSwitchboard switchboard = (plasmaSwitchboard) env; 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 //Fallback
//prop.put("currentlang", ""); //is done by Translationtemplate //prop.put("currentlang", ""); //is done by Translationtemplate
@ -141,7 +141,7 @@ public class ConfigLanguage_p {
langName = (String) langNames.get(langKey); langName = (String) langNames.get(langKey);
prop.put("langlist_"+(i+1)+"_file", langFiles[i]); prop.put("langlist_"+(i+1)+"_file", langFiles[i]);
prop.put("langlist_"+(i+1)+"_name", ((langName == null) ? langKey : langName)); 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_"+(i+1)+"_selected", "selected");
prop.put("langlist_0_selected", " "); // reset Default prop.put("langlist_0_selected", " "); // reset Default
} else { } else {
@ -152,7 +152,7 @@ public class ConfigLanguage_p {
prop.put("langlist", (i+1)); prop.put("langlist", (i+1));
//is done by Translationtemplate //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)); //prop.put("currentlang", ((langName == null) ? "default" : langName));
return prop; return prop;
} }

View File

@ -79,19 +79,6 @@ import de.anomic.yacy.yacySeedUploader;
public class SettingsAck_p { public class SettingsAck_p {
private static boolean nothingChanged; 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) { public static serverObjects respond(httpHeader header, serverObjects post, serverSwitch env) {
// return variable that accumulates replacements // return variable that accumulates replacements

View File

@ -105,7 +105,7 @@ public final class Settings_p {
prop.put("peerName", env.getConfig("peerName", "nameless")); prop.put("peerName", env.getConfig("peerName", "nameless"));
prop.put("staticIP", env.getConfig("staticIP", "")); 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"; if (peerLang.equals("default")) peerLang = "en";
prop.put("peerLang", peerLang); prop.put("peerLang", peerLang);

View File

@ -10,7 +10,7 @@
// //
// $LastChangedDate$ // $LastChangedDate$
// $LastChangedRevision$ // $LastChangedRevision$
// $LastChangedBy$ // $LastChangedBy: $
// //
// This program is free software; you can redistribute it and/or modify // 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 // 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) { public static HashMap langMap(serverSwitch env) {
String[] ms = env.getConfig("htLocaleLang", "").split(","); String[] ms = env.getConfig("locale.lang", "").split(",");
HashMap map = new HashMap(); HashMap map = new HashMap();
int p; int p;
for (int i = 0; i < ms.length; i++) { 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) { public static boolean changeLang(serverSwitch env, String langPath, String lang) {
if ((lang.equals("default")) || (lang.equals("default.lng"))) { if ((lang.equals("default")) || (lang.equals("default.lng"))) {
env.setConfig("htLocaleSelection", "default"); env.setConfig("locale.language", "default");
return true; return true;
} }
String htRootPath = env.getConfig("htRootPath", "htroot"); String htRootPath = env.getConfig("htRootPath", "htroot");
File sourceDir = new File(env.getRootPath(), htRootPath); 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 // .lng
//File destDir = new File(env.getRootPath(), htRootPath + "/locale/" + lang.substring(0, lang.length() - 4));// cut //File destDir = new File(env.getRootPath(), htRootPath + "/locale/" + lang.substring(0, lang.length() - 4));// cut
// .lng // .lng
@ -265,7 +265,7 @@ public class translator {
//if (translator.translateFiles(sourceDir, destDir, translationFile, "html")) { //if (translator.translateFiles(sourceDir, destDir, translationFile, "html")) {
if(translator.translateFilesRecursive(sourceDir, destDir, if(translator.translateFilesRecursive(sourceDir, destDir,
translationFile, "html,template,inc", "locale")){ 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 { try {
BufferedWriter bw = new BufferedWriter(new PrintWriter(new FileWriter(new File(destDir, "version")))); BufferedWriter bw = new BufferedWriter(new PrintWriter(new FileWriter(new File(destDir, "version"))));
bw.write(env.getConfig("svnRevision", "Error getting Version")); bw.write(env.getConfig("svnRevision", "Error getting Version"));

View File

@ -194,8 +194,7 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http
// create htLocaleDefault, htLocalePath // create htLocaleDefault, htLocalePath
if (htDefaultPath == null) htDefaultPath = new File(switchboard.getRootPath(), switchboard.getConfig("htDefaultPath","htroot")); if (htDefaultPath == null) htDefaultPath = new File(switchboard.getRootPath(), switchboard.getConfig("htDefaultPath","htroot"));
if (htLocalePath == null) htLocalePath = new File(switchboard.getConfig("htLocalePath","DATA/HTDOCS/locale")); if (htLocalePath == null) htLocalePath = new File(switchboard.getConfig("locale.translated_html","DATA/LOCALE/htroot"));
//htLocaleSelection = switchboard.getConfig("htLocaleSelection","default");
} }
} }
@ -206,18 +205,18 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http
if (defaultFiles.length == 0) defaultFiles = new String[] {"index.html"}; if (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 */ * @param path relative from htroot */
public static File getLocalizedFile(String path){ 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 /** Returns a path to the localized or default file according to the parameter localeSelection
* @param path relative from htroot * @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){ public static File getLocalizedFile(String path, String localeSelection){
if (htDefaultPath == null) htDefaultPath = new File(switchboard.getRootPath(), switchboard.getConfig("htDefaultPath","htroot")); 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"))) { if (!(localeSelection.equals("default"))) {
File localePath = new File(htLocalePath, localeSelection + "/" + path); File localePath = new File(htLocalePath, localeSelection + "/" + path);
@ -423,8 +422,8 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http
// locate the file // locate the file
if (!(path.startsWith("/"))) path = "/" + path; // attach leading slash if (!(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 // a different language can be desired (by i.e. ConfigBasic.html) than the one stored in the locale.language
String localeSelection = switchboard.getConfig("htLocaleSelection","default"); String localeSelection = switchboard.getConfig("locale.language","default");
if (args != null && (args.containsKey("language"))) if (args != null && (args.containsKey("language")))
{ {
// TODO 9.11.06 Bost: a class with information about available languages is needed. // TODO 9.11.06 Bost: a class with information about available languages is needed.

View File

@ -226,8 +226,8 @@ public class migration {
sb.setConfig("parseableMimeTypes.ICAP", value); sb.setConfig("parseableMimeTypes.ICAP", value);
} }
//Locales in DATA, because DATA must be writable, htroot not. //Locales in DATA, because DATA must be writable, htroot not.
if(sb.getConfig("htLocalePath", "htroot/locale").equals("htroot/locale")){ if(sb.getConfig("locale.translated_html", "DATA/LOCALE/htroot").equals("htroot/locale")){
sb.setConfig("htLocalePath", "DATA/HTDOCS/locale"); sb.setConfig("locale.translated_html", "DATA/LOCALE/htroot");
} }
// migration for port forwarding settings // migration for port forwarding settings

View File

@ -383,50 +383,47 @@ public final class yacy {
serverSystem.openBrowser((server.withSSL()?"https":"http") + "://localhost:" + serverCore.getPortNr(port) + "/" + browserPopUpPage, browserPopUpApplication); serverSystem.openBrowser((server.withSSL()?"https":"http") + "://localhost:" + serverCore.getPortNr(port) + "/" + browserPopUpPage, browserPopUpApplication);
} }
//Copy the shipped locales into DATA // Copy the shipped locales into DATA, existing files are overwritten
final File localesPath = new File(homePath, sb.getConfig("localesPath", "DATA/LOCALE")); final File locale_work = new File(homePath, sb.getConfig("locale.work", "DATA/LOCALE/locales"));
final File defaultLocalesPath = new File(homePath, "locales"); final File locale_source = new File(homePath, sb.getConfig("locale.source", "locales"));
try{ try{
final File[] defaultLocales = defaultLocalesPath.listFiles(); final File[] locale_source_files = locale_source.listFiles();
localesPath.mkdirs(); locale_work.mkdirs();
for(int i=0;i < defaultLocales.length; i++){ File target;
if(defaultLocales[i].getName().endsWith(".lng")) for (int i=0; i < locale_source_files.length; i++){
serverFileUtils.copy(defaultLocales[i], new File(localesPath, defaultLocales[i].getName())); 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){ }catch(NullPointerException e){
serverLog.logSevere("STARTUP", "Nullpointer Exception while copying the default Locales"); serverLog.logSevere("STARTUP", "Nullpointer Exception while copying the default Locales");
} }
//regenerate Locales from Translationlist, if needed //regenerate Locales from Translationlist, if needed
final String lang = sb.getConfig("htLocaleSelection", ""); final String lang = sb.getConfig("locale.language", "");
if(! lang.equals("") && ! lang.equals("default") ){ //locale is used if (!lang.equals("") && !lang.equals("default")) { //locale is used
String currentRev = ""; String currentRev = "";
try{ 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(); currentRev = br.readLine();
br.close(); br.close();
}catch(IOException e){ }catch(IOException e){
//Error //Error
} }
try{ //seperate try, because we want this, even if the file "version" does not exist. if (!currentRev.equals(sb.getConfig("svnRevision", ""))) try { //is this another version?!
if(! currentRev.equals(sb.getConfig("svnRevision", "")) ){ //is this another version?! final File sourceDir = new File(sb.getConfig("htRootPath", "htroot"));
final File sourceDir = new File(sb.getConfig("htRootPath", "htroot")); final File destDir = new File(sb.getConfig("locale.translated_html", "DATA/LOCALE/htroot"), lang);
final File destDir = new File(sb.getConfig("htLocalePath", "DATA/HTDOCS/locale"), lang); if (translator.translateFilesRecursive(sourceDir, destDir, new File(locale_work, lang + ".lng"), "html,template,inc", "locale")){ //translate it
//write the new Versionnumber
if(translator.translateFilesRecursive(sourceDir, destDir, new File("DATA/LOCALE/"+lang+".lng"), "html,template,inc", "locale")){ //translate it final BufferedWriter bw = new BufferedWriter(new PrintWriter(new FileWriter(new File(destDir, "version"))));
//write the new Versionnumber bw.write(sb.getConfig("svnRevision", "Error getting Version"));
final BufferedWriter bw = new BufferedWriter(new PrintWriter(new FileWriter(new File(destDir, "version")))); bw.close();
bw.write(sb.getConfig("svnRevision", "Error getting Version"));
bw.close();
}
} }
}catch(IOException e){ } catch (IOException e) {}
//Error
}
} }
// registering shutdown hook // registering shutdown hook

View File

@ -116,6 +116,10 @@ httpdMinIdleSessions = 5
htRootPath = htroot htRootPath = htroot
htTemplatePath = htroot/env/templates htTemplatePath = htroot/env/templates
# the htroot path
# root path for the httpd file server
htDefaultPath=htroot
# individual htroot folder # individual htroot folder
# every user may publicise her/his own web pages # every user may publicise her/his own web pages
# these pages shall be placed in the path defined here # 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 htLocaleLang defines a list of language options as <dir>/<named-language>
# the <dir> must exist as sub-path to htLocalePath # the <dir> must exist as sub-path to htLocalePath
# the htLocaleSelection selects from the given locales, value=one-of-<dir> # the htLocaleSelection selects from the given locales, value=one-of-<dir>
htDefaultPath=htroot locale.source=locales
htLocalePath=DATA/HTROOT/locale locale.work=DATA/LOCALE/locales
htLocaleLang=default/English,de/Deutsch,fr/Fran&ccedil;ais,nl/Nederlands,it/Italiano,es/Espa&ntilde;ol,pt/Portug&ecirc;s,fi/Suomi,se/Svenska,dk/Dansk,gr/E&lambda;&lambda;&eta;v&iota;&kappa;&alpha;,sk/Slovensky locale.translated_html=DATA/LOCALE/htroot
htLocaleSelection=default locale.lang=default/English,de/Deutsch,fr/Fran&ccedil;ais,nl/Nederlands,it/Italiano,es/Espa&ntilde;ol,pt/Portug&ecirc;s,fi/Suomi,se/Svenska,dk/Dansk,gr/E&lambda;&lambda;&eta;v&iota;&kappa;&alpha;,sk/Slovensky
locale.language=default
# virtual host for httpdFileServlet access # virtual host for httpdFileServlet access
# for example http://<fileHost>/ shall access the file servlet and # for example http://<fileHost>/ shall access the file servlet and