Click to Rate and Give Feedback
MSDN
MSDN Library
Visual Studio 2005
Visual Studio
Visual Studio SDK
 How to: Specify a Culture in Text T...
This page is specific to
Microsoft Visual Studio 2005/.NET Framework 2.0

Other versions are also available for the following:
Domain-Specific Language Tools 
How to: Specify a Culture in Text Templates 

You can add a template directive to text templates and use that directive to specify the culture that you want to use for those text templates. For more information, see Directive Syntax (Domain-Specific Languages) and Using the CultureInfo Class.

To specify a culture for generating an output string

  1. In Solution Explorer, right-click the text template file that you want to edit, and then click Open.

    The template opens in the editor.

  2. Add the following directive to the template. In this example, the French culture is specified.

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

    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 the comma to produce this output:

I have 32,45 Francs in my wallet.

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

To debug text templates, you must set the debug parameter of the template directive. For more information, see How to: Debug Text Templates.

Security

For more information, see Security of Text Templates.

See Also

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use | Trademarks | Privacy Statement
Page view tracker