Multi-Language Support

Appweb supports the ability to create and manage multi-language web applications. The support includes a language-aware Routing Engine and a set of configuration file directives to configure and control response language selection.

When a client sends a request, the HTTP headers typically include an Accept-Language 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.

Language Document Organization

There are two organization models supported by Appweb for multi-language applications:

Appweb manages these models via the AddLanguageDir and AddLanguageSuffix directives.

Language Configuration Directives

Three directives control the language configuration on a per-route basis: AddLanguageDir, AddLanguageSuffix and DefaultLanguage.

ISO Language Tags

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 RFC 1766 — Tags for the identification of Languages and country codes defined in ISO 3166-1.

AddLanguageDir Directive

The AddLanguageDir directive is used when language content is stored in separate directories. This directive defines a supported language tag 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 Accept-Language HTTP header.

<Route /info/>
    AddLanguageDir en /path/to/english-docs
</Route>

AddLanguageSuffix Directive

The AddLanguageSuffix directive defines a supported language tag 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 Accept-Language 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.

<Route /info/>
    AddLanguageSuffix en eng before
</Route>

With this configuration, a request for /index.html will resolve to index.eng.html.

DefaultLanguage

The DefaultLanguage directive defines the language to use when the the client Accept-Language HTTP header is either absent or requests a non-supported language.

<Route />
    DefaultLanguage en
</Route>

© Embedthis Software, 2003-2015. All rights reserved.