Bugfix: language of ConfigBasic.html was not changed properly when a different language was choosen here. Note: there's a similair bug on ConfigLanguage_p.html

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@2921 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
(no author) 18 years ago
parent 892b9f2fc4
commit e59ff8b657

@ -225,24 +225,22 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http
if (defaultFiles.length == 0) defaultFiles = new String[] {"index.html"};
}
/*
* Returns the path of a (existing) localized File, or the english one, if not availible.
* @param path is relative from htroot
* @return the function returns a Filehandle to the translated file, or if not availitble to the english one.
*/
/** Returns a path to the localized or default file according to the htLocaleSelection (from he switchboard)
* @param path relative from htroot */
public static File getLocalizedFile(String path){
plasmaSwitchboard switchboard=plasmaSwitchboard.getSwitchboard();
// create htLocaleDefault, htLocalePath
return getLocalizedFile(path, switchboard.getConfig("htLocaleSelection","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("") */
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"));
//htLocaleSelection = switchboard.getConfig("htLocaleSelection","default");
// find locales or alternatives in htDocsPath
String htLocaleSelection = switchboard.getConfig("htLocaleSelection","default");
// look if we have a localization of that file
if (!(htLocaleSelection.equals("default"))) {
File localePath = new File(htLocalePath, htLocaleSelection + "/" + path);
if (localePath.exists())
if (!(localeSelection.equals("default"))) {
File localePath = new File(htLocalePath, localeSelection + "/" + path);
if (localePath.exists()) // avoid "NoSuchFile" troubles if the "localeSelection" is misspelled
return localePath;
}
return new File(htDefaultPath, path);
@ -443,7 +441,13 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http
// locate the file
if (!(path.startsWith("/"))) path = "/" + path; // attach leading slash
File targetFile = getLocalizedFile(path);
// a different language can be desired (by i.e. ConfigBasic.html) than the one stored in the htLocaleSelection
String localeSelection = switchboard.getConfig("htLocaleSelection","default");
if (args != null)
localeSelection = args.get("language", localeSelection);
File targetFile = getLocalizedFile(path, localeSelection);
String targetExt = conProp.getProperty("EXT","");
targetClass = rewriteClassFile(new File(htDefaultPath, path));
if (path.endsWith("/")) {
@ -1013,7 +1017,6 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http
// now make a class out of the stream
try {
if (useTemplateCache) {
SoftReference ref = (SoftReference) templateMethodCache.get(classFile);
if (ref != null) {
m = (Method) ref.get();

Loading…
Cancel
Save