diff --git a/cgi-bin/help.c b/cgi-bin/help.c index 75f70d9..ac71b7a 100644 --- a/cgi-bin/help.c +++ b/cgi-bin/help.c @@ -38,7 +38,8 @@ main(int argc, /* I - Number of command-line arguments */ int i; /* Looping var */ const char *query; /* Search query */ const char *cache_dir; /* CUPS_CACHEDIR environment variable */ - const char *docroot; /* CUPS_DOCROOT environment variable */ + const char *docroot_env; /* CUPS_DOCROOT environment variable */ + char docroot[1024]; const char *helpfile, /* Current help file */ *helptitle = NULL; /* Current help title */ const char *topic; /* Current topic */ @@ -49,6 +50,7 @@ main(int argc, /* I - Number of command-line arguments */ cups_file_t *fp; /* Help file */ char line[1024]; /* Line from file */ int printable; /* Show printable version? */ + char *locale = NULL; /* @@ -75,8 +77,24 @@ main(int argc, /* I - Number of command-line arguments */ snprintf(filename, sizeof(filename), "%s/help.index", cache_dir); - if ((docroot = getenv("CUPS_DOCROOT")) == NULL) - docroot = CUPS_DOCROOT; + if ((docroot_env = getenv("CUPS_DOCROOT")) == NULL) + docroot_env = CUPS_DOCROOT; + + if(getenv("LANG")) + { + snprintf(docroot, sizeof(docroot), "%s.%s", docroot_env, getenv("LANG")); + locale=docroot+strlen(docroot_env)+1; + if(access(docroot,R_OK|X_OK)) + if(strrchr(locale, '.')) + *strrchr(locale, '.')='\0'; + if(access(docroot,R_OK|X_OK)) + if(strrchr(locale, '_')) + *strrchr(locale, '_')='\0'; + if(access(docroot,R_OK|X_OK)) + locale=NULL; + } + if(locale == NULL) + snprintf(docroot, sizeof(docroot), "%s", docroot_env); snprintf(directory, sizeof(directory), "%s/help", docroot);