You are viewing a plain text version of this content. The canonical link for it is here.
Posted to apache-bugdb@apache.org by Rainer Scherg <Ra...@rexroth.de> on 1998/11/20 16:25:21 UTC

mod_negotiation/3430: Enhancement: MultiViews, Multi-Language Documents

>Number:         3430
>Category:       mod_negotiation
>Synopsis:       Enhancement: MultiViews, Multi-Language Documents
>Confidential:   no
>Severity:       non-critical
>Priority:       medium
>Responsible:    apache
>State:          open
>Class:          change-request
>Submitter-Id:   apache
>Arrival-Date:   Fri Nov 20 07:30:02 PST 1998
>Last-Modified:
>Originator:     Rainer.Scherg@rexroth.de
>Organization:
apache
>Release:        
>Environment:
Sun Solaris 2.5.1, gcc 2.7
>Description:

Enhancement-Request for MultiViews-Feature
------------------------------------------


 The situation (just to state the problem):

 - Having a complete webserver providing documents
   in several languages based on availibility and
   content/topics.

     - Document (MIME) types containing different language
       information may be (e.g.):
           .htm, .txt, .pdf, .doc, .xls, .gif


 - the selection of the language should be done by
   selection "preferred language" thru the browser.
   (Accept header information?)

 - The webserver selects the best matching document
   (language) for the selected MIME-Type. (as today)


 How should the documents be stored:
   
     test.htm            = doc in default language
     test.en.htm         = doc in english
     test.de.htm         = [etc.]
     ...
     test.pdf            = pdf doc in default language
     test.en.pdf         = [etc.]
     ...


 Requesting the document:

     http://...../test.htm   (returns best htm-match)
     http://...../test.pdf   (returns best pdf-match)
         

 Advantage:
     
   - No add. navigation to the multilanguage docs
     needed = easy to handle (e.g.: in an IntraNet docs
     mostly will be provided and maintained by
     "standard users" and not by webmasters)
    
     You just do the navigation between the default language
     documents.


 Why the enhancement request to the current MultiViews:
  
   - The current MultiViews handling is hard to understand & to
     handle by "standard users" (we are already trying to use
     MultiViews in our international IntraNet).

   - e.g. "test.htm.en" will not be correctly recognized by
     most programs (e.g. html editors).


 
 The Enhancement Request (Proposal):
 -----------------------------------

 1. Config-directive for standard language, handling
    the language for e.g. "test.htm".

      >> LanguageDefault       en          #  (test.htm = Lang. en)

    [Right now, apache sometimes return wrong (lang.) docs.]
    [see also: PR#1180]
 

 2. Telling Apache what MIME-types could have multilingual
    content (minimize impact on server = don't guess).
    
      >> LanguageTypes   .htm .html .shtml .gif .jpg .cgi .pl


 3. Don't change the mime-type (file extension) of the document:
    use "test.de.htm" instead "test.htm.de".



Possible References:
PR#1180, PR#2944, PR#3299


Tnx for listening -- Rainer



[sorry for the long text, but this topic is hard to understand, if you
 didn't run into these problems.]
>How-To-Repeat:

>Fix:

>Audit-Trail:
>Unformatted:
[In order for any reply to be added to the PR database, ]
[you need to include <ap...@Apache.Org> in the Cc line ]
[and leave the subject line UNCHANGED.  This is not done]
[automatically because of the potential for mail loops. ]
[If you do not include this Cc, your reply may be ig-   ]
[nored unless you are responding to an explicit request ]
[from a developer.                                      ]
[Reply only with text; DO NOT SEND ATTACHMENTS!         ]




Re: [PATCH] adding a DefaultLanguage directive

Posted by Rodent of Unusual Size <Ke...@Golux.Com>.
Paul Sutton wrote:
> 
> This patch implements a DefaultLanguage directive. It sets the language to
> apply to files with no explicit language set via AddLanguage. Typical use
> would be to set HTML files as English with:

+1 (tested).
-- 
#ken	P-)}

Ken Coar                    <http://Web.Golux.Com/coar/>
Apache Group member         <http://www.apache.org/>
"Apache Server for Dummies" <http://Web.Golux.Com/coar/ASFD/>

Re: [PATCH] adding a DefaultLanguage directive

Posted by Dirk-Willem van Gulik <di...@jrc.it>.

On Mon, 23 Nov 1998, Paul Sutton wrote:

> On 20 Nov 1998, Rainer Scherg wrote:
> > >Number:         3430
> > >Synopsis:       Enhancement: MultiViews, Multi-Language Documents
> > [...]
> >  The Enhancement Request (Proposal):
> >  -----------------------------------
> > 
> >  1. Config-directive for standard language, handling
> >     the language for e.g. "test.htm".
> > 
> >       >> LanguageDefault       en          #  (test.htm = Lang. en)
> > 
> >     [Right now, apache sometimes return wrong (lang.) docs.]
> >     [see also: PR#1180]
> 
> PR#1180 and PR#3430 both request a way to specify a default language for
> documents which don't have an explicit language extension. This is
> useful for sites moving to multiviews/language negotiation which will
> typically already have a lot of resources in a common language, and do not
> want to rename every file.

Although another way to do this is of course (if you only want the
labeling) to just add Charset=xx;Language=xx to the right line in
the mime file.
 
> This patch implements a DefaultLanguage directive. It sets the language to
> apply to files with no explicit language set via AddLanguage. Typical use
> would be to set HTML files as English with:

Hmm.. yet another reason to rewrite mod_negotiation; as this is again a
bit too subtle to do it dynamic.

Perhaps a marker in the docs that the user is encouraged NOT to mix this
with dynamic language or content-type negotiation might be in order.

Dw
 
>   <Files *.html>
>   DefaultLanguage en
>   </Files>
> 
> Paul
> 
> Index: mod_mime.c
> ===================================================================
> RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_mime.c,v
> retrieving revision 1.45
> diff -u -r1.45 mod_mime.c
> --- mod_mime.c	1998/10/23 19:28:53	1.45
> +++ mod_mime.c	1998/11/23 09:24:50
> @@ -81,6 +81,7 @@
>  
>      char *type;                 /* Type forced with ForceType  */
>      char *handler;              /* Handler forced with SetHandler */
> +    char *default_language;     /* Language if no AddLanguage ext found */
>  } mime_dir_config;
>  
>  module MODULE_VAR_EXPORT mime_module;
> @@ -98,6 +99,7 @@
>  
>      new->type = NULL;
>      new->handler = NULL;
> +    new->default_language = NULL;
>  
>      return new;
>  }
> @@ -107,13 +109,13 @@
>      mime_dir_config *base = (mime_dir_config *) basev;
>      mime_dir_config *add = (mime_dir_config *) addv;
>      mime_dir_config *new =
> -	(mime_dir_config *) ap_palloc(p, sizeof(mime_dir_config));
> +        (mime_dir_config *) ap_palloc(p, sizeof(mime_dir_config));
>      int i;
>      handlers_info *hand;
>  
>      hand = (handlers_info *) add->handlers_remove->elts;
>      for (i = 0; i < add->handlers_remove->nelts; i++) {
> -	ap_table_unset(base->handlers, hand[i].name);
> +        ap_table_unset(base->handlers, hand[i].name);
>      }
>  
>      new->forced_types = ap_overlay_tables(p, add->forced_types,
> @@ -127,6 +129,8 @@
>  
>      new->type = add->type ? add->type : base->type;
>      new->handler = add->handler ? add->handler : base->handler;
> +    new->default_language = add->default_language ? 
> +        add->default_language : base->default_language;
>  
>      return new;
>  }
> @@ -182,7 +186,7 @@
>      handlers_info *hand;
>  
>      if (*ext == '.') {
> -	++ext;
> +        ++ext;
>      }
>      hand = (handlers_info *) ap_push_array(mcfg->handlers_remove);
>      hand->name = ap_pstrdup(cmd->pool, ext);
> @@ -219,6 +223,9 @@
>       "a handler name"},
>      {"TypesConfig", set_types_config, NULL, RSRC_CONF, TAKE1,
>       "the MIME types config file"},
> +    {"DefaultLanguage", ap_set_string_slot, 
> +     (void*)XtOffsetOf(mime_dir_config, default_language), OR_FILEINFO, TAKE1,
> +     "language to use for documents with no other language file extension" },
>      {NULL}
>  };
>  
> @@ -250,7 +257,7 @@
>  
>      if (!(f = ap_pcfg_openfile(p, types_confname))) {
>          ap_log_error(APLOG_MARK, APLOG_ERR, s,
> -		     "httpd: could not open mime types log file %s.", types_confname);
> +                     "httpd: could not open mime types log file %s.", types_confname);
>          exit(1);
>      }
>  
> @@ -347,6 +354,20 @@
>              r->handler = orighandler;
>          }
>  
> +    }
> +
> +    /* Set default language, if none was specified by the extensions
> +     * and we have a DefaultLanguage setting in force
> +     */
> +
> +    if (!r->content_languages && conf->default_language) {
> +        const char **new;
> +
> +        r->content_language = conf->default_language; /* back compat. only */
> +        if (!r->content_languages)
> +            r->content_languages = ap_make_array(r->pool, 2, sizeof(char *));
> +        new = (const char **) ap_push_array(r->content_languages);
> +        *new = conf->default_language;
>      }
>  
>      /* Check for overrides with ForceType/SetHandler */
> 
> 


Re: [PATCH] adding a DefaultLanguage directive

Posted by Dirk-Willem van Gulik <di...@jrc.it>.
On Mon, 23 Nov 1998, Paul Sutton wrote:

Actually Paul, you do realize that if one combines this patch
with DefaultLanguage setting in the srm.conf file (and some
message during install/compile) to make sure people set it
right! that this could be the first GOOD thing ever done since
netscape broke Accept with their */*.

Dw

> On 20 Nov 1998, Rainer Scherg wrote:
> > >Number:         3430
> > >Synopsis:       Enhancement: MultiViews, Multi-Language Documents
> > [...]
> >  The Enhancement Request (Proposal):
> >  -----------------------------------
> > 
> >  1. Config-directive for standard language, handling
> >     the language for e.g. "test.htm".
> > 
> >       >> LanguageDefault       en          #  (test.htm = Lang. en)
> > 
> >     [Right now, apache sometimes return wrong (lang.) docs.]
> >     [see also: PR#1180]
> 
> PR#1180 and PR#3430 both request a way to specify a default language for
> documents which don't have an explicit language extension. This is
> useful for sites moving to multiviews/language negotiation which will
> typically already have a lot of resources in a common language, and do not
> want to rename every file.
> 
> This patch implements a DefaultLanguage directive. It sets the language to
> apply to files with no explicit language set via AddLanguage. Typical use
> would be to set HTML files as English with:
> 
>   <Files *.html>
>   DefaultLanguage en
>   </Files>
> 
> Paul
> 
> Index: mod_mime.c
> ===================================================================
> RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_mime.c,v
> retrieving revision 1.45
> diff -u -r1.45 mod_mime.c
> --- mod_mime.c	1998/10/23 19:28:53	1.45
> +++ mod_mime.c	1998/11/23 09:24:50
> @@ -81,6 +81,7 @@
>  
>      char *type;                 /* Type forced with ForceType  */
>      char *handler;              /* Handler forced with SetHandler */
> +    char *default_language;     /* Language if no AddLanguage ext found */
>  } mime_dir_config;
>  
>  module MODULE_VAR_EXPORT mime_module;
> @@ -98,6 +99,7 @@
>  
>      new->type = NULL;
>      new->handler = NULL;
> +    new->default_language = NULL;
>  
>      return new;
>  }
> @@ -107,13 +109,13 @@
>      mime_dir_config *base = (mime_dir_config *) basev;
>      mime_dir_config *add = (mime_dir_config *) addv;
>      mime_dir_config *new =
> -	(mime_dir_config *) ap_palloc(p, sizeof(mime_dir_config));
> +        (mime_dir_config *) ap_palloc(p, sizeof(mime_dir_config));
>      int i;
>      handlers_info *hand;
>  
>      hand = (handlers_info *) add->handlers_remove->elts;
>      for (i = 0; i < add->handlers_remove->nelts; i++) {
> -	ap_table_unset(base->handlers, hand[i].name);
> +        ap_table_unset(base->handlers, hand[i].name);
>      }
>  
>      new->forced_types = ap_overlay_tables(p, add->forced_types,
> @@ -127,6 +129,8 @@
>  
>      new->type = add->type ? add->type : base->type;
>      new->handler = add->handler ? add->handler : base->handler;
> +    new->default_language = add->default_language ? 
> +        add->default_language : base->default_language;
>  
>      return new;
>  }
> @@ -182,7 +186,7 @@
>      handlers_info *hand;
>  
>      if (*ext == '.') {
> -	++ext;
> +        ++ext;
>      }
>      hand = (handlers_info *) ap_push_array(mcfg->handlers_remove);
>      hand->name = ap_pstrdup(cmd->pool, ext);
> @@ -219,6 +223,9 @@
>       "a handler name"},
>      {"TypesConfig", set_types_config, NULL, RSRC_CONF, TAKE1,
>       "the MIME types config file"},
> +    {"DefaultLanguage", ap_set_string_slot, 
> +     (void*)XtOffsetOf(mime_dir_config, default_language), OR_FILEINFO, TAKE1,
> +     "language to use for documents with no other language file extension" },
>      {NULL}
>  };
>  
> @@ -250,7 +257,7 @@
>  
>      if (!(f = ap_pcfg_openfile(p, types_confname))) {
>          ap_log_error(APLOG_MARK, APLOG_ERR, s,
> -		     "httpd: could not open mime types log file %s.", types_confname);
> +                     "httpd: could not open mime types log file %s.", types_confname);
>          exit(1);
>      }
>  
> @@ -347,6 +354,20 @@
>              r->handler = orighandler;
>          }
>  
> +    }
> +
> +    /* Set default language, if none was specified by the extensions
> +     * and we have a DefaultLanguage setting in force
> +     */
> +
> +    if (!r->content_languages && conf->default_language) {
> +        const char **new;
> +
> +        r->content_language = conf->default_language; /* back compat. only */
> +        if (!r->content_languages)
> +            r->content_languages = ap_make_array(r->pool, 2, sizeof(char *));
> +        new = (const char **) ap_push_array(r->content_languages);
> +        *new = conf->default_language;
>      }
>  
>      /* Check for overrides with ForceType/SetHandler */
> 
> 


[PATCH] adding a DefaultLanguage directive

Posted by Paul Sutton <pa...@c2.net>.
On 20 Nov 1998, Rainer Scherg wrote:
> >Number:         3430
> >Synopsis:       Enhancement: MultiViews, Multi-Language Documents
> [...]
>  The Enhancement Request (Proposal):
>  -----------------------------------
> 
>  1. Config-directive for standard language, handling
>     the language for e.g. "test.htm".
> 
>       >> LanguageDefault       en          #  (test.htm = Lang. en)
> 
>     [Right now, apache sometimes return wrong (lang.) docs.]
>     [see also: PR#1180]

PR#1180 and PR#3430 both request a way to specify a default language for
documents which don't have an explicit language extension. This is
useful for sites moving to multiviews/language negotiation which will
typically already have a lot of resources in a common language, and do not
want to rename every file.

This patch implements a DefaultLanguage directive. It sets the language to
apply to files with no explicit language set via AddLanguage. Typical use
would be to set HTML files as English with:

  <Files *.html>
  DefaultLanguage en
  </Files>

Paul

Index: mod_mime.c
===================================================================
RCS file: /export/home/cvs/apache-1.3/src/modules/standard/mod_mime.c,v
retrieving revision 1.45
diff -u -r1.45 mod_mime.c
--- mod_mime.c	1998/10/23 19:28:53	1.45
+++ mod_mime.c	1998/11/23 09:24:50
@@ -81,6 +81,7 @@
 
     char *type;                 /* Type forced with ForceType  */
     char *handler;              /* Handler forced with SetHandler */
+    char *default_language;     /* Language if no AddLanguage ext found */
 } mime_dir_config;
 
 module MODULE_VAR_EXPORT mime_module;
@@ -98,6 +99,7 @@
 
     new->type = NULL;
     new->handler = NULL;
+    new->default_language = NULL;
 
     return new;
 }
@@ -107,13 +109,13 @@
     mime_dir_config *base = (mime_dir_config *) basev;
     mime_dir_config *add = (mime_dir_config *) addv;
     mime_dir_config *new =
-	(mime_dir_config *) ap_palloc(p, sizeof(mime_dir_config));
+        (mime_dir_config *) ap_palloc(p, sizeof(mime_dir_config));
     int i;
     handlers_info *hand;
 
     hand = (handlers_info *) add->handlers_remove->elts;
     for (i = 0; i < add->handlers_remove->nelts; i++) {
-	ap_table_unset(base->handlers, hand[i].name);
+        ap_table_unset(base->handlers, hand[i].name);
     }
 
     new->forced_types = ap_overlay_tables(p, add->forced_types,
@@ -127,6 +129,8 @@
 
     new->type = add->type ? add->type : base->type;
     new->handler = add->handler ? add->handler : base->handler;
+    new->default_language = add->default_language ? 
+        add->default_language : base->default_language;
 
     return new;
 }
@@ -182,7 +186,7 @@
     handlers_info *hand;
 
     if (*ext == '.') {
-	++ext;
+        ++ext;
     }
     hand = (handlers_info *) ap_push_array(mcfg->handlers_remove);
     hand->name = ap_pstrdup(cmd->pool, ext);
@@ -219,6 +223,9 @@
      "a handler name"},
     {"TypesConfig", set_types_config, NULL, RSRC_CONF, TAKE1,
      "the MIME types config file"},
+    {"DefaultLanguage", ap_set_string_slot, 
+     (void*)XtOffsetOf(mime_dir_config, default_language), OR_FILEINFO, TAKE1,
+     "language to use for documents with no other language file extension" },
     {NULL}
 };
 
@@ -250,7 +257,7 @@
 
     if (!(f = ap_pcfg_openfile(p, types_confname))) {
         ap_log_error(APLOG_MARK, APLOG_ERR, s,
-		     "httpd: could not open mime types log file %s.", types_confname);
+                     "httpd: could not open mime types log file %s.", types_confname);
         exit(1);
     }
 
@@ -347,6 +354,20 @@
             r->handler = orighandler;
         }
 
+    }
+
+    /* Set default language, if none was specified by the extensions
+     * and we have a DefaultLanguage setting in force
+     */
+
+    if (!r->content_languages && conf->default_language) {
+        const char **new;
+
+        r->content_language = conf->default_language; /* back compat. only */
+        if (!r->content_languages)
+            r->content_languages = ap_make_array(r->pool, 2, sizeof(char *));
+        new = (const char **) ap_push_array(r->content_languages);
+        *new = conf->default_language;
     }
 
     /* Check for overrides with ForceType/SetHandler */