Partilhar via


lang Attribute

  Microsoft Speech Technologies Homepage

Specifies which language the grammar refers to.

HTML <grammar lang="lang">
JScript grammar.lang = lang

Remarks

The value of the lang attribute follows the definition found in the Internet Engineering Task Force (IETF) RFC1766 specification. The RFC1766 specification allows for a rich suite of languages, although not all are supported by the Speech Application SDK. The tags are case insensitive. The language tag is a string composed of one or more parts. The first part is a two-character designation of the basic language. For example, "en" is for English; "no," Norwegian; "fr," French; "de," German. The second part is separated by a hyphen and designates the variation or dialect of the language. "en-US" is for United States English, "en-cockney" is for Cockney English.

The lang attribute has scope within the page element where it is declared.

  • If unspecified, a higher level element in the page propagates the lang value down to grammar element.
  • If the lang attribute is specified in multiple places, the language ID follows an order of precedence from the lowest scope to the highest scope. For example, the language ID specified within a grammar file is the lowest scope, followed by the lang attribute in a grammar element, followed by an lang attribute in a listen element. For external grammars, it may even be overridden by an lang attribute specified within the target grammar.
  • If lang is completely unspecified, a platform-specific value is used.

Example

The following code demonstrates the use of the lang attribute to identify an English-U.S. grammar.

<salt:grammar name="cities" xmlns="http://www.w3.org/2001/06/grammar" lang="en-US">
  <grammar root="root" version="1.0" tag-format="semantics-ms/1.0">
    <rule id="root">
      <item repeat="0-1">from </item>
      <ruleref name="#cities" />
    </rule>
    <rule id="cities">
      <one-of>
        <item> Cambridge </item>
        <item> Seattle   </item>
        <item> London    </item>
      </one-of>
    </rule>
  </grammar>
</salt:grammar>

See Also

grammar Element |  listen Element | lang Attribute (listen)