February 09, 2007

What's in a string?

Altiris Helpdesk String Resources

Developing solutions for a worldwide market would be a lot simpler if everyone used the same language, but we don't. Hence we need a mechanism to present our interface in any number of languages.

This article explores how Helpdesk supports globalization and explains how to customize the interface to meet your needs. There should be sufficient information here to allow you to translate the Helpdesk from English to languages which are not supported by Altiris.

Resource Libraries

Altiris Helpdesk is written in ASP.NET which allows you to globalize an application through the use of resource libraries. A resource library is essentially just a list of names and strings.

The globalization mechanism in ASP.NET works by removing all the content from the presentation layer (what you see when you view the pages on a browser) and replacing it with string identifiers. If you look at any of the templates you will see many of these names. The convention in Helpdesk is to prefix the name with "sid" so, for example, sidLabel is a string identifier that translates to "Label" in English. These names correspond to strings in resource libraries and you need separate resource libraries for each language you wish to support. When a user opens the web page, the resource manager tries to translate the string identifiers on the page to the language set as the preferred language in the user's browser. If it fails to find an appropriate language, it shows the default value which in this case is in English.

Adding a New Resource Library

Helpdesk provides a very convenient mechanism for adding new resource libraries using XML. These libraries are loaded after the supplied resource libraries, so they can be used to add new string identifiers or override values in the default libraries.

To add a new resource library:

  1. Browse to the AeXHD folder.
  2. This is usually at C:\Program Files\Altiris\Helpdesk\AeXHD, but will depend on where you installed your Altiris Solutions.

  3. Create a new folder in the AeXHD folder.
  4. You can give this folder any name you like. In the code here I will presume you have called it custom.

  5. Create an XML file in the new folder.
  6. Again you are free to give this file any name you choose, but I will call it customstrings.xml. This file will contain the new strings in xml format as shown below. When you create this file, I highly recommend that you save it using UTF-8 encoding. If you don't, any special characters in your strings will not be reproduced correctly. These will be the strings used for the default language which is usually English. Altiris recommends that you prefix your custom string identifiers with "csid" to avoid inadvertently overwriting any of the default strings.

    <?xml version="1.0" encoding="utf-8" ?>
       <strings>
          <string id="csidCompanyName">My Company</string>
       </strings>

  7. Create a file called custom.config in the AeXHD folder
  8. This file will add the new resource library to the solution resources when the application starts. Here is an example of the file contents:

    <?xml version="1.0" encoding="utf-8" ?>
       <custom.configuration>
          <resourceLibs>
             <resourceLib file="customstrings.xml" path="~/custom/" appcache="yes"/>
          </resourceLibs>
       </custom.configuration>

Supporting Additional Languages

To support languages other than English, just add subfolders to the custom folder which contains the customstrings.xml file. These folders should be named with the 2 or 4 letter code for the language you wish to support. For example if you want to add strings to support Spanish, add a subfolder called es to the custom folder. Copy the customstrings.xml file to this folder and open it with a text editor. Finally, translate the strings to the desired language. There is more information about this in the Helpdesk Solution 6.0 Product Guide.

Overriding the Default Strings

You can use the mechanism explained thus far, to override strings which are already defined in the Helpdesk simply by including a new definition for the string identifier in your customstrings.xml file. Indeed you can translate the entire Helpdesk into a new language by providing an XML file with the translations of all the defined strings.

One question that comes up regularly on the forums whenever someone wants to override a built-in string identifier, is "what identifier corresponds to the string...?". As the built-in strings are compiled into a dynamically linked library it is a little difficult to access them. I have translated the English version of the library into the XML format so you can just open a file with a text editor and copy the lines you need to your customstrings.xml file. You can download the file here: ResourceStrings.