Localizing Extensions and Wizards

For Mechanical-based extensions and wizard, you have two ways of localizing captions for buttons, tabs, groups, object names, and so on:

  • callback <getlocalstring>

  • attribute localize

Callback <getlocalstring>

The callback <getlocalstring> is exposed on the interface level, providing a way for you to localize captions yourself. This callback has two parameters:

  • locale, which is the language for the caption

  • caption, which is the display text for the caption

The locale is passed in as a string using these language values:

LanguageValue
Englishen-us
Frenchfr
Germande
Japaneseja
Chinesezh

An example follows for using the callback <getlocalstring>.

XML Definition:

<interface>
    <toolbar name="Toolbar 1" caption="Toolbar">
            <entry name="custom_result_1" icon="hand" caption="Result">
                <callbacks>
                    <onclick>add_result1</onclick>
                </callbacks>
            </entry>
    <toolbar>
    
    <callbacks>
        <getlocalstring>GetLocalString</getlocalstring>
    </callbacks>
</interface>

IronPython Script:

localized_strings_french = {
    "Toolbar" : "Barre d'outil",
    "Result" : "Résultat"
}

def GetLocalString(caption, locale):
    if locale == "fr": 
        return localized_string_french[caption]


Note:  Because the callback <getlocalstring> can be called multiple times, you should define it in a way similar to the example.


Attribute localize

The attribute localize provides a way of passing the work of localizing to Mechanical. When localize is set to true, Mechanical's string table is used to localize the caption. This means that for Mechanical to be able to localize the caption, the caption must be a string ID retrieved from the file dsstringtable.xml.

The file dsstringtable.xml is a mapping from string IDs to localized strings. Because five languages are supported, there are five different versions of this file in the installation. For a given language, the file contains all strings that are used as captions in Mechanical, thereby providing an easy way of localizing extension captions if these same captions appear in Mechanical's user interface. If you use a string that is not present in dsstringtable.xml, the string is shown without any localization.

The attribute localize is available on the following tags: <action>, <entry>, <toolbar>, <property>, <propertygroup>, <object>, <load>, <solver>, <result>, and <step>. The string table file is located in ANSYS_INSTALL/aisol/DesignSpace/DSPages/Language/LOCALE/xml/dsstringtable.xml.

An example follows for using localize="true".

<property name="Mag" caption="ID_MagnitudeProperty" localize="true">
</property>