Поделиться через


How to Use MessageManager

If you are using MessageManager to manage localized message handling through the RC.xml file, you use the RCxml2resx tool (located in the %Commerce_Server_Root%\Tools folder) to convert your RC.xml file to .resx files, and then create satellite assemblies for the MessageManager object by using the .resx files. Commerce Server Core Systems uses satellite assemblies to store language-dependent string resources. To review the process for using MessageManager, see What is MessageManager? This topic outlines the procedures that you must follow to implement MessageManager for a Commerce Server Core Systems site.

Implementing MessageManager consists of these steps:

  • Create or modify the RC.xml file that contains the localized message strings.

  • Use the RCxml2resx command-line tool to convert the RC.xml file to a .resx file.

  • Generate satellite assemblies by using the Resource File Generator (ResGen.exe) and Assembly Linker (Al.exe) command-line tools, or by using Visual Studio 2008.

  • Edit the Web.config file to specify that Commerce Server Core Systems should use the new resources.

To modify the RC.xml file

  1. Create a new RC.xml file or edit an existing file.

  2. Add your message strings to the file for each locale. See the example later in this topic for more information.

  3. Save the file.

To convert RC.xml files to .resx files

  1. Click Start, point to Programs, point to Microsoft Visual Studio 2008, point to Visual Studio 2005 Tools or Visual Studio 2008, and then click Visual Studio 2005 Command Prompt or Visual Studio 2008 Command Prompt.

  2. In the Visual Studio 2008 Command Prompt window, type the following command:

    RCxml2resx   <XMLFilePath>   [<outputFile[.ext]>]
    

    Press ENTER.

    If you omit the output file name, the .resx file will have the same name as the .xml file. If you omit the output file name extension, the default extension .resx will be used.

    The following command converts the RC.xml file that is located in the c:\inetpub\wwwroot\CommerceWebApp folder to a new MessageManagerResources.resx file:

    RCxml2resx C:\Inetpub\wwwroot\CommerceWebApp\rc.xml MessageManagerResources.resx
    

    Note

    The RCxml2resx tool generates one .resx file for each language in the XML file. The previous example generates two files: MessageManagerResources.en-US.resx and MessageManagerResources.fr-FR.resx.

To convert .resx files to resource files

  1. Click Start, point to Programs, point to Microsoft Visual Studio 2008, point to Visual Studio 2008 Tools, and then click Visual Studio 2008 Command Prompt.

  2. In the Visual Studio 2008 Command Prompt window, type the following command:

    ResGen <inputFile.ext>   [<outputFile.ext>]
    

    Press ENTER.

    For example, to generate a resource file for the en-US and fr-FR resources, type the following command:

    ResGen MessageManagerResources.en-US.resx
    ResGen MessageManagerResources.fr-FR.resx
    

    Note

    Make sure that there is a folder for each culture for which you generated a resource file. For the previous example, make sure that there is an en_US and fr_FR folder in the \Bin folder under your Commerce Server Core Systems project in the \inetpub\wwwroot folder.

To create satellite assemblies by using Assembly Linker

  1. Click Start, point to Programs, point to Microsoft Visual Studio 2008, point to Visual Studio 2008 Tools, and then click Visual Studio 2008 Command Prompt.

  2. In the Visual Studio 2008 Command Prompt window, type the following command to run the Microsoft Assembly Linker (Al.exe):

    al /embed:<Resource> /culture:<culture name> /out:<filename>
    

    Press ENTER.

    For example, the following code creates the en-US and fr-FR culture satellite assemblies for the MessageManagerResource.en-US and MessageManagerResource.fr-FR resources:

    al /embed:MessageManagerResources.en-US.resources /culture:en-US /out:C:\inetpub\wwwroot\CommerceWebApplication\bin\en-us\CommerceWebApplication.resources.dll
    al /embed:MessageManagerResources.fr-FR.resources /culture:fr-FR /out:C:\Inetpub\wwwroot\CommerceWebApplication\bin\fr-FR\CommerceWebApplication.resources.dll
    

If you are building the satellite assemblies by using Assembly Linker, the base name will be the name of your resource file. For example, if you create a resource file that is named MessageManagerResources.en-US.resources, the base name will be MessageManagerResources.

To build satellite assemblies by using Visual Studio 2008

  1. Copy the .resx files you created or modified in the first procedure to your Commerce Server Core Systems Project directory.

  2. Start Visual Studio 2008, and then open your Commerce Server Core Systems project.

  3. In Visual Studio 2008, on the File menu, click Add Existing Items.

  4. In the Add Existing Item - <Project Name> dialog box, select the .resx files you copied in step 1, and then click Open.

  5. On the Build menu, click Build Solution.

Visual Studio 2008 generates the satellite assemblies for you.

If you are using Visual Studio 2008 to build your satellite assemblies, follow the steps in the next procedure to obtain the base name.

To obtain the base name for your satellite assemblies

  1. Click Start, point to Programs, point to Microsoft Visual Studio 2008, point to Visual Studio 2008 Tools, and then click Visual Studio 2008 Command Prompt.

  2. In the Visual Studio 2008Command Prompt window, type the following command, and then press ENTER:

    ildasm <satellite assembly>.resources.dll 
    
  3. In the IL DASM window, click the MANIFEST icon.

    You will see a section that resembles the following:

    .mresource public 'BaseName.en-US.resources' 
    

    The string in single quotation marks identifies the base name for your satellite assemblies. For example, if the string is 'CommerceWebApplication.MessageManagerResources.en-US.resources', the base name isCommerceWebApplication.MessageManagerResources. You must use this name to edit the Web.config file.

To edit the Web.config file

  1. Open the Web.config file and locate the messageManager tag.

  2. Within the messageManager tag, enter your compiled resources according to the following format (see the example later in this topic for more information):

    <messageManager>
    <cultures default="<type_default culture_name>" BaseName="<resource_name>" assembly="<satellite_assembly_name>">
                   <culture id="<culture_ID_1>" />
                   <culture id="<culture_ID_2>" />
                    .
                    .
                   <culture id="<culture_ID_n>" />
           </cultures>
           <resources>
                   <resource id="<resource_ID" />
           </resources>
    </messageManager>
    

Your message management system will now use the Commerce Server .NET Application Framework.

Example

The following code example shows the contents of an RC.xml file that contains a single string in English and French for a resource named pur_badsku.

<?xml version="1.0"?>
<MessageManager>
    <Language Name="English"    Locale="1033"/>
    <Language Name="French"     Locale="1036"/>
    <Entry Name="pur_badsku" Type="_Basket_Errors">
        <Value Language="English"> Please note that one or more
            items were removed from your order because the 
            product is no longer sold.
        </Value>
        <Value Language="French"> Notez qu'un ou plusieurs
            articles ont t supprims de votre commande car le 
            produit n'est plus en vente.
        </Value>
    </Entry>
</MessageManager>

The following code example shows how to modify the Web.config file to use the resource named pur_badsku that was defined in the previous example.

<messageManager>
    <cultures default="en-US" BaseName="MessageManagerResources" assembly="CommerceWebApplication">
        <culture id="en-US" />
        <culture id="fr-FR" />
    </cultures>
    <resources>
        <resource id="pur_badsku" />
    </resources>
</messageManager>

See Also

Other Resources

What is MessageManager?

International Considerations for Developing Pipelines

Developing with Core Systems Pipelines

Developing with Commerce Server Core Systems