localization Support for Includes

git-svn-id: https://svn.berlios.de/svnroot/repos/yacy/trunk@923 6c8d7289-2bf4-0310-a012-ef5d649a1542
pull/1/head
allo 19 years ago
parent 371fd67ecf
commit 7ca60f97bf

@ -79,7 +79,7 @@ public class Status {
yacyCore.peerActions.updateMySeed(); yacyCore.peerActions.updateMySeed();
if (((plasmaSwitchboard) env).adminAuthenticated(header) >= 2) { if (((plasmaSwitchboard) env).adminAuthenticated(header) >= 2) {
prop.put("privateStatusTable", new File(env.getRootPath(), "htroot/Status_p.inc").toString()); prop.put("privateStatusTable", "Status_p.inc");
} else { } else {
prop.put("privateStatusTable", ""); prop.put("privateStatusTable", "");
} }

@ -373,7 +373,8 @@ public final class httpTemplate {
if ((!filename.equals("")) && (!filename.equals(dflt))) { if ((!filename.equals("")) && (!filename.equals(dflt))) {
BufferedReader br = null; BufferedReader br = null;
try{ try{
br = new BufferedReader(new InputStreamReader(new FileInputStream( filename ))); //br = new BufferedReader(new InputStreamReader(new FileInputStream( filename ))); //Simple Include
br = new BufferedReader( new InputStreamReader(new FileInputStream( httpdFileHandler.getLocalizedFile(filename) )) ); //YaCy (with Locales)
//Read the Include //Read the Include
while( (line = br.readLine()) != null ){ while( (line = br.readLine()) != null ){
include+=line+de.anomic.server.serverCore.crlfString; include+=line+de.anomic.server.serverCore.crlfString;

@ -212,6 +212,28 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http
serverLog.logWarning("HTTPDFileHandler", "Content-MD5 support not availabel ..."); serverLog.logWarning("HTTPDFileHandler", "Content-MD5 support not availabel ...");
} }
} }
/*
* 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.
*/
public static File getLocalizedFile(String path){
plasmaSwitchboard switchboard=plasmaSwitchboard.getSwitchboard();
// create htLocaleDefault, htLocalePath
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())
return localePath;
}
return new File(htDefaultPath, path);
}
// private void textMessage(OutputStream out, int retcode, String body) throws IOException { // private void textMessage(OutputStream out, int retcode, String body) throws IOException {
// httpd.sendRespondHeader( // httpd.sendRespondHeader(
@ -455,13 +477,7 @@ public final class httpdFileHandler extends httpdAbstractHandler implements http
path.endsWith("csv") || path.endsWith("csv") ||
path.endsWith("pac")) { path.endsWith("pac")) {
// find locales or alternatives in htDocsPath targetFile = getLocalizedFile(path);
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()) targetFile = localePath;
}
// call rewrite-class // call rewrite-class
serverObjects tp = new serverObjects(); serverObjects tp = new serverObjects();

Loading…
Cancel
Save