How to: Specify a Culture in Text Templates

The culture directive lets you specify the culture that you want to use for text templates. The format used is ISO-3166, for example en-US for United States English. For more information, see Directive Syntax (Domain-Specific Languages) and Using the CultureInfo Class.

Procedure

To specify a culture for generating an output string

  • Add the following directive to the template.

    In this example, the French culture is specified.

    <#@ template culture="fr-FR" #>
    

    Note

    If you already have a template directive, add the culture parameter to the end of your existing directive.

Example

The following example converts 32.45 to the French culture using the "fr-FR" value. The example replaces the decimal point with a comma to produce the following output.

I have 32,45 Francs in my wallet.
<#@ template culture="fr-FR" #>
<#@ output extension=".txt" #>
<#
    double moneyInMyWallet = 32.45;
#>
I have <#= moneyInMyWallet #> Francs in my wallet.
<#@ template culture="fr-FR" #>
<#@ output extension=".txt" #>
<#
    Dim moneyInMyWallet as Double = 32.45
#>
I have <#= moneyInMyWallet #> Francs in my wallet.

See Also

Tasks

Walkthrough: Creating and Running Text Templates

Other Resources

Using Built-in Directives in Text Templates

Adding Code to Text Templates

Generating Artifacts By Using Text Templates

Change History

Date

History

Reason

July 2008

Rewrote and refactored project.

Content bug fix.