zhxy/http服务器/appweb-4.3.4-0/doc/guide/appweb/users/lang.html

159 lines
8.7 KiB
HTML

<!-- BeginDsi "dsi/head.html" -->
<!DOCTYPE html>
<html lang="en">
<head>
<title>Embedthis Appweb 4.3.4 Documentation</title>
<meta name="keywords" content="embedded web server, web server software, embedded HTTP, application web server,
embedded server, small web server, HTTP server, library web server, library HTTP, HTTP library" />
<meta name="description" content="Embedthis Sofware provides commercial and open source embedded web servers for
devices and applications." />
<meta name="robots" content="index,follow" />
<link href="../../../doc.css" rel="stylesheet" type="text/css" />
<link href="../../../print.css" rel="stylesheet" type="text/css" media="print"/>
<!--[if IE]>
<link href="../../../iehacks.css" rel="stylesheet" type="text/css" />
<![endif]-->
<link href="http://www.google.com/cse/style/look/default.css" type="text/css" rel="stylesheet" />
</head>
<body>
<div class="top">
<a class="logo" href="http://appwebserver.org/">&nbsp;</a>
<div class="topRight">
<div class="search">
<div id="cse-search-form"></div>
<div class="version">Embedthis Appweb 4.3.4</div>
</div>
</div>
<div class="crumbs">
<a href="../../../index.html">Home</a>
<!-- EndDsi -->
&gt; <a href="index.html">Users Guide</a> &gt; <b>Multi-Language Support</b>
</div>
</div>
<div class="content">
<div class="contentRight">
<h1>Quick Nav</h1>
<ul class="nav">
<li><a href="#overview">Overview</a></li>
<li><a href="#configuration">Route Configuration</a></li>
</ul>
<!-- BeginDsi "dsi/usersGuideSeeAlso.html" -->
<h1>See Also</h1>
<ul class="nav">
<li><a href="../../../guide/appweb/users/index.html">User Guide Overview</a></li>
<li><a href="../../../guide/appweb/users/configuration.html">Configuring Appweb</a></li>
<li><a href="../../../guide/appweb/users/ports.html">Ports and Binding</a></li>
<li><a href="../../../guide/appweb/users/lang.html">Multi-Language Support</a></li>
<li><a href="../../../guide/appweb/users/authentication.html">User Authorization</a></li>
<li><a href="../../../guide/appweb/users/logFiles.html">Log Files</a></li>
<li><a href="../../../guide/appweb/users/vhosts.html">Virtual Hosts</a></li>
<li><a href="../../../guide/appweb/users/security.html">Security Considerations</a></li>
<li><a href="../../../guide/appweb/users/ssl.html">SSL</a></li>
<li><a href="../../../guide/appweb/users/modules.html">Appweb Modules</a></li>
<li><a href="../../../guide/appweb/users/stages.html">Pipeline Stages</a></li>
<li><a href="../../../guide/appweb/users/client.html">HTTP Client</a></li>
<li><a href="../../../guide/appweb/users/webSockets.html">WebSockets</a></li>
<li><a href="../../../guide/appweb/users/frameworks.html">Web Frameworks</a></li>
<li><a href="../../../ref/appweb/architecture.html">Appweb Architecture</a></li>
</ul>
<!-- EndDsi -->
</div>
<div class="contentLeft">
<h1>Multi-Language Support</h1>
<a id="overview"></a>
<p>Appweb supports the ability to create and manage multi-language web applications. The support includes
a language-aware <a href="routing.html">Routing Engine</a> and a set of
<a href="configuration.html#directives">configuration file directives</a> to configure and control
response language selection.</p>
<p>When a client sends a request, the HTTP headers typically include an <em>Accept-Language</em> HTTP header that
specifies the client's language preference for the request. The Appweb routing engine listens for this
header and will modify the request to select response content of the appropriate language.</p>
<a id="documents"></a>
<h2 class="section">Language Document Organization</h2>
<p>There are two organization models supported by Appweb for multi-language applications:</p>
<ul>
<li>Separate directories for each language content, and </li>
<li>Unified storage for content with a language suffix integrated into each document filename.</li>
</ul>
<p>Appweb manages these models via the <em>AddLanguageDir</em> and <em>AddLanguageSuffix</em>
directives.</p>
<a id="configuration"></a>
<h2 class="section">Language Configuration Directives</h2>
<p>Three directives control the language configuration on a per-route basis:
<em>AddLanguageDir</em>, <em>AddLanguageSuffix</em> and <em>DefaultLanguage</em>.
<a id="isotag"></a>
<h3>ISO Language Tags</h3>
<p>The AddLanguageDir and AddLanguageSuffix directives add support for a single language and so a typical Appweb
configuration file will have multiple such directives. These directives specify the language via
a language tag as defined by <a href="http://www.faqs.org/rfcs/rfc1766.html">RFC 1766 &mdash; Tags for the
identification of Languages</a> and country codes defined
in <a href="http://www.iso.org/iso/iso-3166-1_decoding_table">ISO 3166-1</a>.</p>
<h3>AddLanguageDir Directive</h3>
<p>The AddLanguageDir directive is used when language content is stored in separate directories. This directive
defines a supported language
<a href="#isotag">tag</a>
with an associated directory of language for
the language specific content.
When a client request is received, the appropriate language directory will be selected by the routing engine
using the language specified by the client's <em>Accept-Language</em> HTTP header.</p>
<pre>
&lt;Route /info/&gt;
AddLanguageDir en /path/to/english-docs
&lt;/Route&gt;
</pre>
<h3>AddLanguageSuffix Directive</h3>
<p>The AddLanguageSuffix directive defines a supported language
<a href="#isotag">tag</a> with an associated filename suffix. When
a client request is received, the appropriate language will be selected using the language
specified by the client's <em>Accept-Language</em> HTTP header. Then the document filename will be constructed
using the language suffix. The suffix can be positioned either before or after the document
extension via the directives "position" argument.</p>
<pre>
&lt;Route /info/&gt;
AddLanguageSuffix en eng before
&lt;/Route&gt;
</pre>
<p>With this configuration, a request for <em>/index.html</em> will resolve to <em>index.eng.html</em>.</p>
<h3>DefaultLanguage</h3>
<p>The DefaultLanguage directive defines the language to use when the the client <em>Accept-Language</em>
HTTP header is either absent or requests a non-supported language.</p>
<pre>
&lt;Route /&gt;
DefaultLanguage en
&lt;/Route&gt;
</pre>
</div>
</div>
<!-- BeginDsi "dsi/bottom.html" -->
<div class="bottom">
<p class="footnote">
<a href="../../../product/copyright.html" >&copy; Embedthis Software LLC, 2003-2013.
All rights reserved. Embedthis, Appweb, ESP, Ejscript and Embedthis GoAhead are trademarks of Embedthis Software LLC.</a>
</p>
</div>
<script src="http://www.google.com/jsapi" type="text/javascript"></script>
<script type="text/javascript">
google.load('search', '1', {language : 'en'});
google.setOnLoadCallback(function() {
var customSearchControl = new google.search.CustomSearchControl(
'000262706376373952077:1hs0lhenihk');
customSearchControl.setResultSetSize(google.search.Search.FILTERED_CSE_RESULTSET);
var options = new google.search.DrawOptions();
options.enableSearchboxOnly("http://appwebserver.org/search.html");
customSearchControl.draw('cse-search-form', options);
}, true);
</script>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-179169-2']);
_gaq.push(['_trackPageview']);
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
</script>
</body>
</html>