You can use grammar rules for a culture to substitute a portion of a the global culture parsing grammar with strings, commands, or expressions specific to the culture or language. By defining a grammar rule, you can customize portions of the global culture parsing grammar based on the record's culture and/or language. This is useful if you do not want to create an entirely separate parsing grammar for each culture and instead use the global culture's grammar, customizing only specific portions of the global culture grammar for each culture.
This topic describes how to create a grammar rule for a culture.
Example Grammar Rule
You have a grammar that parses Western names. The structure of the pattern maybe the
same for all cultures
(<FirstName><MiddleName><LastName>
) and many
of the rules might match the same pattern or table. However, you also have
culture-specific tables for last names, and you want to use the appropriate table
based on the record's culture code.
To accomplish this, you could define a grammar rule for each culture that replaces
the <LastName>
element in the global culture with a reference
to the culture-specific table. For example, if you have a table of Dutch last names,
you would create a grammar rule for the Dutch (nl) culture as follows:
Name: LastName
Description: Dutch last names
Value: @Table("Dutch Last Names");