Every dialog caption and message displayed to the user in Stonefield Query is defined in one or more resource files. There are two types of resource files: application and project. Application resource files are located in the Resources subdirectory of the SQWeb program folder. Project resource files are located on the Project_Data folder for the project.

A resource file is an XML file with resource elements providing key-value pairs. The key is used to locate a particular resource and the value is the string to display to the user. Here's an example, taken from resources.en.xml:

<resources>
    <resource>
        <key>fileMenuCaption</key>
        <value>File</value>
    </resource>
    <resource>
        <key>editButtonCaption</key>
        <value>Edit</value>
    </resource>
</resources>

Resource files are named according to the two-character language code for the language the resource file is for: "en" for English, "fr" for French, etc. For a user who wants to see English, resources.en.xml is used. Only languages that have resource files are available to users. Search the Internet for "ISO 639-1" to find a list of language codes.

To create resources in a different language, copy the contents of resources.en.xml in the Resources folder to another file with the appropriate name, such as resources.fr.xml for French. For each key-value pair in the file, replace the value with the equivalent in the desired language. For example, here's what part of resources.fr.xml would look like:

<resources>
    <resource>
        <key>fileMenuCaption</key>
        <value>Fichier</value>
    </resource>
    <resource>
        <key>editButtonCaption</key>
        <value>Modifier</value>
    </resource>
</resources>

Project resource files are intended to supplement and override the values in the application resource files. One purpose is to provide translations for the table and field captions and data group and role names. By default, the captions and names entered into Studio are displayed to the user as is in Stonefield Query. However, if you want a multi-lingual application, you probably also want the captions and names displayed in the user's language. To do that, choose the Create Resource File function in the File menu in Studio. This creates a file named resources.code.xml in the Project_Data folder, where code is the two-letter language code for the default language specified in the Default Language configuration setting. This file has the captions and names as both key and values. It also includes "english" elements showing the original values, making it easier to tell what needs to be translated. To create other language versions of this file, follow the steps mentioned earlier.

Another purpose of project resource files to the override the values in the application resource files. For example, if you'd rather display "Data group" as "Module," you could edit these entries in resources.en.xml in the Resources folder:

<resource>
    <key>dataGroupCaption</key>
    <value>Data Group</value>
</resource>
<resource>
    <key>datagroupsInRoleCaption</key>
    <value>Data Groups in role</value>
</resource>
<resource>
    <key>dataGroupsCaption</key>
    <value>Data Groups</value>
</resource>

However, the next time a new version of Stonefield Query is released, resources.en.xml is overwritten with a new copy and your custom changes are lost. Instead, create a custom project resources file with just the entries you want to override; for example:

<resources>
    <resource>
        <key>dataGroupCaption</key>
        <value>Module</value>
    </resource>
    <resource>
        <key>datagroupsInRoleCaption</key>
        <value>Modules in role</value>
    </resource>
    <resource>
        <key>dataGroupsCaption</key>
        <value>Modules</value>
    </resource>
</resources>

Name this file, for example, CustomResources.en.xml, and place it in the Project_Data folder for the project. To tell Stonefield Query to use this file, edit Settings.xml and add a new entry to the ProjectResourceFiles section. For example:

<ProjectResourceFiles>
    <ProjectResourceFile>
        <ResourcePrefix>Resources</ResourcePrefix>
        <ResourceMainCulture>en</ResourceMainCulture>
        <LocaleMainCulture>en-US</LocaleMainCulture>
    </ProjectResourceFile>
    <ProjectResourceFile>
        <ResourcePrefix>CustomResources</ResourcePrefix>
        <ResourceMainCulture>en</ResourceMainCulture>
        <LocaleMainCulture>en-US</LocaleMainCulture>
    </ProjectResourceFile>
</ProjectResourceFiles>

You can automate this task by choosing the Create Custom Resource File from the File menu in Studio. That function creates the XML file and updates Settings.xml accordingly.

If you want to programmatically get a specific resource in the language for the current user, use code like the following:

string resource = Application.Localizer.LanguageResources["keyValue"];

where "keyValue" is the resource key. To specify a different language, use something like:

string key = "langCode" + Application.Localizer.LanguageSeparator +
    "keyValue";
string resource = Application.Localizer.LanguageResources[key];

where "langCode" is the language code, such as "de" for German.

Stonefield Query also supports locale-specific resource files such as resources.FR-fr.xml. If present, they take top priority over language resources.