Adding Localized Strings and Resources (Modeling Services)

[This content is no longer valid. For the latest information on "M", "Quadrant", SQL Server Modeling Services, and the Repository, see the Model Citizen blog.]

SQL Server Modeling Services contains support for localized strings and resources. This topic discusses how to add localized strings and resources to “M” models.

Adding a Localizable Field to an "M" Model

A localizable field is a string or resource field that requires multiple versions to support different languages or locales. In the Modeling Services database, localized strings are stored in the [System.Globalization].[Strings] view. Localized resources are stored in the [System.Globalization].[Resources] view. The identifier of both localized strings and resources is a text string with a maximum of 2083 characters. The following example shows how to add a field that can use this design.

module OrderSystem
{
    import System;

    Products :
    {( 
        HasFolderAndAutoId &
        {
            Name : Text;

            Description : Text where value.Count <= 2083;
        }
    )*};
}

In this example, there is an OrderSystem module that contains a Products extent. The Products extent contains two fields: Name and Description. The Description field is of type Text where the maximum number of characters is 2083. This field can participate in the localization design pattern of the Modeling Services database.

Adding Localizable Strings and Resources to the Database

The localized strings and resources must reside in the appropriate System.Globalization tables. One way to enter these strings is in the content of your “M” model. The following “M” code adds the English and French versions of a product description string to the StringsTable table.

module OrderSystem
{
    import System;
    import Repository.Item;
    import System.Globalization;


    System.Globalization::StringsTable
    {
        {
            Id => "ED12A02D-66FD-4AA3-A1BF-6EA265DB8D95",
            Folder => FoldersTable(PathsFolder("OrderSystemFolder")),
            Locale => LocalesTable("en-US"),
            String => "A red bicycle."
        },
        {
            Id => "ED12A02D-66FD-4AA3-A1BF-6EA265DB8D95",
            Folder => FoldersTable(PathsFolder("OrderSystemFolder")),
            Locale => LocalesTable("fr-FR"),
            String => "Une bicyclette rouge."
        }
    }
        
    Products :
    {( 
        HasFolderAndAutoId &
        {
            Name : Text;

            Description : Text where value.Count <= 2083;
        }
    )*}
    {
        { 
            Folder => FoldersTable(PathsFolder("OrderSystemFolder")), 
            Name => "B568", 
            Description => "ED12A02D-66FD-4AA3-A1BF-6EA265DB8D95" 
        }
    }
}

The product in this example is a bicycle. Both the English and French versions of the product description are added to the [System.Globalization].[StringsTable]. Note that the string identifier used is the text form of a GUID, "ED12A02D-66FD-4AA3-A1BF-6EA265DB8D95". This ensures uniqueness. This identifier is used for both the English and French entries. These entries indicate the proper locale for each record by adding a reference to the appropriate entry in the [System.Globalization].[LocalesTable] table. A Folder value is required as well. In this case it is assumed that the Folder OrderSystemFolder has been added to the target Modeling Services database.

The second part of the sample repeats the Products extent definition from the previous example. But it adds a new Products row at the end. Note that the Description field is assigned the identifier "ED12A02D-66FD-4AA3-A1BF-6EA265DB8D95" that references the strings added to the StringsTable.

Note that this same pattern exists for resources, such as icons or bitmaps. However, you use the ResourcesTable instead of the StringsTable for that work.

For more information about how to use these localized strings in code and ad hoc queries, see Localization Tasks (Modeling Services).

See Also

Concepts

SQL Server Modeling Services Patterns

Other Resources

SQL Server Modeling Services Localization Support